ExTypesense.Cluster (ExTypesense v1.1.0)

View Source

Cluster specific operations.

More here: https://typesense.org/docs/latest/api/cluster-operations.html

Summary

Functions

Get stats about API endpoints.

Same as api_stats/1 but passes another connection.

Clears the cache

Same as clear_cache/0 but passes another connection.

Same as clear_cache/1 but passes another connection.

Get current RAM, CPU, Disk & Network usage metrics.

Same as cluster_metrics/1 but passes another connection.

Compaction of the underlying RocksDB database.

Same as compact_db/1 but passes another connection.

Creates a point-in-time snapshot of a Typesense node's state and data in the specified directory.

Same as create_snapshot/1 but passes another connection.

Get health information about a Typesense node.

Same as health/1 but passes another connection.

Enable logging of requests that take over a defined threshold of time.

Triggers a follower node to initiate the raft voting process, which triggers leader re-election.

Same as vote/0 but passes another connection.

Same as vote/1 but passes another connection.

Functions

api_stats()

(since 0.3.0)
@spec api_stats() :: {:ok, OpenApiTypesense.APIStatsResponse.t()} | :error

Get stats about API endpoints.

This endpoint returns average requests per second and latencies for all requests in the last 10 seconds.

api_stats(opts)

(since 1.0.0)
@spec api_stats(map() | OpenApiTypesense.Connection.t() | keyword()) ::
  {:ok, OpenApiTypesense.APIStatsResponse.t()} | :error

Same as api_stats/0

ExTypesense.api_stats([])

ExTypesense.api_stats(%{api_key: xyz, host: ...})

ExTypesense.api_stats(OpenApiTypesense.Connection.new())

api_stats(conn, opts)

(since 1.0.0)
@spec api_stats(
  map() | OpenApiTypesense.Connection.t(),
  keyword()
) :: {:ok, OpenApiTypesense.APIStatsResponse.t()} | :error

Same as api_stats/1 but passes another connection.

ExTypesense.api_stats(%{api_key: xyz, host: ...}, [])

ExTypesense.api_stats(OpenApiTypesense.Connection.new(), [])

clear_cache()

(since 1.0.0)
@spec clear_cache() :: {:ok, OpenApiTypesense.SuccessStatus.t()} | :error

Clears the cache

Responses of search requests that are sent with use_cache parameter are cached in a LRU cache. Clears cache completely.

clear_cache(opts)

(since 1.0.0)
@spec clear_cache(map() | OpenApiTypesense.Connection.t() | keyword()) ::
  {:ok, OpenApiTypesense.SuccessStatus.t()} | :error

Same as clear_cache/0 but passes another connection.

ExTypesense.clear_cache([])

ExTypesense.clear_cache(%{api_key: xyz, host: ...})

ExTypesense.clear_cache(OpenApiTypesense.Connection.new())

clear_cache(conn, opts)

(since 1.0.0)
@spec clear_cache(
  map() | OpenApiTypesense.Connection.t(),
  keyword()
) :: {:ok, OpenApiTypesense.SuccessStatus.t()} | :error

Same as clear_cache/1 but passes another connection.

ExTypesense.clear_cache(%{api_key: xyz, host: ...}, [])

ExTypesense.clear_cache(OpenApiTypesense.Connection.new(), [])

cluster_metrics()

(since 0.3.0)
@spec cluster_metrics() :: {:ok, map()} | :error

Get current RAM, CPU, Disk & Network usage metrics.

cluster_metrics(opts)

(since 1.0.0)
@spec cluster_metrics(map() | OpenApiTypesense.Connection.t() | keyword()) ::
  {:ok, map()} | :error

Same as cluster_metrics/0

ExTypesense.cluster_metrics([])

ExTypesense.cluster_metrics(%{api_key: xyz, host: ...})

ExTypesense.cluster_metrics(OpenApiTypesense.Connection.new())

cluster_metrics(conn, opts)

(since 1.0.0)
@spec cluster_metrics(
  map() | OpenApiTypesense.Connection.t(),
  keyword()
) :: {:ok, map()} | :error

Same as cluster_metrics/1 but passes another connection.

ExTypesense.cluster_metrics(%{api_key: xyz, host: ...}, [])

ExTypesense.cluster_metrics(OpenApiTypesense.Connection.new(), [])

compact_db()

(since 1.0.0)
@spec compact_db() :: {:ok, OpenApiTypesense.SuccessStatus.t()} | :error

Compaction of the underlying RocksDB database.

Typesense uses RocksDB to store your documents on the disk. If you do frequent writes or updates, you could benefit from running a compaction of the underlying RocksDB database. This could reduce the size of the database and decrease read latency. While the database will not block during this operation, we recommend running it during off-peak hours.

compact_db(opts)

(since 1.0.0)
@spec compact_db(map() | OpenApiTypesense.Connection.t() | keyword()) ::
  {:ok, OpenApiTypesense.SuccessStatus.t()} | :error

Same as compact_db/0

ExTypesense.compact_db([])

ExTypesense.compact_db(%{api_key: xyz, host: ...})

ExTypesense.compact_db(OpenApiTypesense.Connection.new())

compact_db(conn, opts)

(since 1.0.0)
@spec compact_db(
  map() | OpenApiTypesense.Connection.t(),
  keyword()
) :: {:ok, OpenApiTypesense.SuccessStatus.t()} | :error

Same as compact_db/1 but passes another connection.

ExTypesense.compact_db(%{api_key: xyz, host: ...}, [])

ExTypesense.compact_db(OpenApiTypesense.Connection.new(), [])

create_snapshot(opts)

(since 1.0.0)
@spec create_snapshot(keyword()) :: {:ok, OpenApiTypesense.SuccessStatus.t()} | :error

Creates a point-in-time snapshot of a Typesense node's state and data in the specified directory.

You can then backup the snapshot directory that gets created and later restore it as a data directory, as needed.

Options

  • snapshot_path: The directory on the server where the snapshot should be saved.

create_snapshot(conn, opts)

(since 1.0.0)
@spec create_snapshot(
  map() | OpenApiTypesense.Connection.t(),
  keyword()
) :: {:ok, OpenApiTypesense.SuccessStatus.t()} | :error

Same as create_snapshot/1 but passes another connection.

ExTypesense.create_snapshot(%{api_key: xyz, host: ...}, snapshot_path: "/tmp/typesense-data-snapshot")

ExTypesense.create_snapshot(OpenApiTypesense.Connection.new(), snapshot_path: "/tmp/typesense-data-snapshot")

health()

(since 0.3.0)
@spec health() :: {:ok, OpenApiTypesense.HealthStatus.t()} | :error

Get health information about a Typesense node.

health(opts)

(since 1.0.0)
@spec health(map() | OpenApiTypesense.Connection.t() | keyword()) ::
  {:ok, OpenApiTypesense.HealthStatus.t()} | :error

Same as health/0

ExTypesense.health([])

ExTypesense.health(%{api_key: xyz, host: ...})

ExTypesense.health(OpenApiTypesense.Connection.new())

health(conn, opts)

(since 1.0.0)
@spec health(
  map() | OpenApiTypesense.Connection.t(),
  keyword()
) :: {:ok, OpenApiTypesense.HealthStatus.t()} | :error

Same as health/1 but passes another connection.

ExTypesense.health(%{api_key: xyz, host: ...}, [])

ExTypesense.health(OpenApiTypesense.Connection.new(), [])

toggle_slow_request_log(config)

(since 1.0.0)
@spec toggle_slow_request_log(map()) ::
  {:ok, OpenApiTypesense.SuccessStatus.t()} | :error

Enable logging of requests that take over a defined threshold of time.

Slow requests are logged to the primary log file, with the prefix SLOW REQUEST. Default is -1 which disables slow request logging.

Example

iex> config = %{"log_slow_requests_time_ms" => 2_000}
iex> ExTypesense.toggle_slow_request_log(config)

toggle_slow_request_log(config, opts)

(since 1.0.0)
@spec toggle_slow_request_log(
  map() | OpenApiTypesense.Connection.t(),
  map() | keyword()
) ::
  {:ok, OpenApiTypesense.SuccessStatus.t()} | :error

Same as toggle_slow_request_log/1

ExTypesense.toggle_slow_request_log(config, [])

ExTypesense.toggle_slow_request_log(%{api_key: xyz, host: ...}, config)

ExTypesense.toggle_slow_request_log(OpenApiTypesense.Connection.new(), config)

toggle_slow_request_log(conn, config, opts)

(since 1.0.0)
@spec toggle_slow_request_log(
  map() | OpenApiTypesense.Connection.t(),
  map(),
  keyword()
) ::
  {:ok, OpenApiTypesense.SuccessStatus.t()} | :error

Same as toggle_slow_request_log/2 but passes another connection.

ExTypesense.toggle_slow_request_log(%{api_key: xyz, host: ...}, config, [])

ExTypesense.toggle_slow_request_log(OpenApiTypesense.Connection.new(), config, [])

vote()

(since 0.3.0)
@spec vote() :: {:ok, OpenApiTypesense.SuccessStatus.t()} | :error

Triggers a follower node to initiate the raft voting process, which triggers leader re-election.

The follower node that you run this operation against will become the new leader, once this command succeeds.

vote(opts)

(since 0.3.0)
@spec vote(map() | OpenApiTypesense.Connection.t() | keyword()) ::
  {:ok, OpenApiTypesense.SuccessStatus.t()} | :error

Same as vote/0 but passes another connection.

ExTypesense.vote([])

ExTypesense.vote(%{api_key: xyz, host: ...})

ExTypesense.vote(OpenApiTypesense.Connection.new())

vote(conn, opts)

(since 0.3.0)
@spec vote(
  map() | OpenApiTypesense.Connection.t(),
  keyword()
) :: {:ok, OpenApiTypesense.SuccessStatus.t()} | :error

Same as vote/1 but passes another connection.

ExTypesense.vote(%{api_key: xyz, host: ...}, [])

ExTypesense.vote(OpenApiTypesense.Connection.new(), [])