ExTypesense.Cluster (ExTypesense v2.0.1)

View Source

Cluster specific operations.

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

Summary

Functions

Get stats about API endpoints.

Clears the cache

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

Compaction of the underlying RocksDB database.

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

Get the status of in-progress schema change operations

Same as get_schema_changes/0 but passes another connection.

Get health information about a Typesense node.

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.

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.

Examples

iex> ExTypesense.api_stats()

api_stats(opts)

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

Same as api_stats/0

Options

  • conn: The custom connection map or struct you passed

Examples

iex> conn = %{api_key: xyz, host: ...}
iex> ExTypesense.api_stats(conn: conn)

iex> conn = OpenApiTypesense.Connection.new()
iex> ExTypesense.api_stats(conn: conn)

iex> opts = [conn: conn]
iex> ExTypesense.api_stats(opts)

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.

Examples

iex> ExTypesense.clear_cache()

clear_cache(opts)

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

Same as clear_cache/0

Options

  • conn: The custom connection map or struct you passed

Examples

iex> conn = %{api_key: xyz, host: ...}
iex> ExTypesense.clear_cache(conn: conn)

iex> conn = OpenApiTypesense.Connection.new()
iex> ExTypesense.clear_cache(conn: conn)

iex> opts = [conn: conn]
iex> ExTypesense.clear_cache(opts)

cluster_metrics()

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

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

Examples

iex> ExTypesense.cluster_metrics()

cluster_metrics(opts)

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

Same as cluster_metrics/0

Options

  • conn: The custom connection map or struct you passed

Examples

iex> conn = %{api_key: xyz, host: ...}
iex> ExTypesense.cluster_metrics(conn: conn)

iex> conn = OpenApiTypesense.Connection.new()
iex> ExTypesense.cluster_metrics(conn: conn)

iex> opts = [conn: conn]
iex> ExTypesense.cluster_metrics(opts)

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.

Examples

iex> ExTypesense.compact_db()

compact_db(opts)

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

Same as compact_db/0

Options

  • conn: The custom connection map or struct you passed

Examples

iex> conn = %{api_key: xyz, host: ...}
iex> ExTypesense.compact_db(conn: conn)

iex> conn = OpenApiTypesense.Connection.new()
iex> ExTypesense.compact_db(conn: conn)

iex> opts = [conn: conn]
iex> ExTypesense.compact_db(opts)

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

  • conn: The custom connection map or struct you passed
  • snapshot_path: The directory on the server where the snapshot should be saved.

Examples

iex> path = "/path/to/snapshot_dir"
iex> ExTypesense.create_snapshot(snapshot_path: path)

iex> conn = %{api_key: xyz, host: ...}
iex> ExTypesense.create_snapshot(snapshot_path: path, conn: conn)

iex> conn = OpenApiTypesense.Connection.new()
iex> ExTypesense.create_snapshot(snapshot_path: path, conn: conn)

iex> opts = [snapshot_path: path, conn: conn]
iex> ExTypesense.create_snapshot(opts)

get_schema_changes()

(since 1.2.0)
@spec get_schema_changes() ::
  {:ok, [OpenApiTypesense.SchemaChangeStatus.t()]} | :error

Get the status of in-progress schema change operations

Returns the status of any ongoing schema change operations. If no schema changes are in progress, returns an empty response.

Examples

iex> ExTypesense.get_schema_changes()

get_schema_changes(opts)

(since 1.2.0)
@spec get_schema_changes(keyword()) ::
  {:ok, [OpenApiTypesense.SchemaChangeStatus.t()]} | :error

Same as get_schema_changes/0 but passes another connection.

Options

  • conn: The custom connection map or struct you passed

Examples

iex> conn = %{api_key: xyz, host: ...}
iex> ExTypesense.get_schema_changes(conn: conn)

iex> conn = OpenApiTypesense.Connection.new()
iex> ExTypesense.get_schema_changes(conn: conn)

iex> opts = [conn: conn]
iex> ExTypesense.get_schema_changes(opts)

health()

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

Get health information about a Typesense node.

Examples

iex> ExTypesense.health()

health(opts)

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

Same as health/0

Options

  • conn: The custom connection map or struct you passed

Examples

iex> conn = %{api_key: xyz, host: ...}
iex> ExTypesense.health(conn: conn)

iex> conn = OpenApiTypesense.Connection.new()
iex> ExTypesense.health(conn: conn)

iex> opts = [conn: conn]
iex> ExTypesense.health(opts)

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(),
  keyword()
) :: {:ok, OpenApiTypesense.SuccessStatus.t()} | :error

Same as toggle_slow_request_log/1

Options

  • conn: The custom connection map or struct you passed

Examples

iex> conn = %{api_key: xyz, host: ...}
iex> ExTypesense.toggle_slow_request_log(config, conn: conn)

iex> conn = OpenApiTypesense.Connection.new()
iex> ExTypesense.toggle_slow_request_log(config, conn: conn)

iex> opts = [conn: conn]
iex> ExTypesense.toggle_slow_request_log(config, opts)

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.

Examples

iex> ExTypesense.vote()

vote(opts)

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

Same as vote/0 but passes another connection.

Options

  • conn: The custom connection map or struct you passed

Examples

iex> conn = %{api_key: xyz, host: ...}
iex> ExTypesense.vote(conn: conn)

iex> conn = OpenApiTypesense.Connection.new()
iex> ExTypesense.vote(conn: conn)

iex> opts = [conn: conn]
iex> ExTypesense.vote(opts)