View Source ExRocketmq.Remote.Waiter (lib_oss v0.1.0)

The future-wait store of the remote, opaque => request pid This module is a wrapper of ets and genserver, ets is responsible for storing the request, and GenServer is responsible for cleaning up the expired request

Summary

Functions

Returns a specification to start this module under a supervisor.

pop the value of the key from the waiter

put key-value pair to the waiter

start the waiter

Types

@type key() :: ExRocketmq.Typespecs.opaque()
@type opts_schema_t() :: [name: atom(), interval: integer(), opts: keyword()]
@type t() :: %ExRocketmq.Remote.Waiter{
  interval: non_neg_integer(),
  name: atom(),
  pid: pid()
}
@type value() :: {pid(), any()} | nil

Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

@spec pop(t(), ExRocketmq.Typespecs.opaque()) :: value()

pop the value of the key from the waiter

Examples

iex> ExRocketmq.Remote.Waiter.pop(waiter, 1)
nil
Link to this function

put(waiter, key, value, list)

View Source
@spec put(t(), key(), value(), [{:ttl, non_neg_integer() | :infinity}]) :: any()

put key-value pair to the waiter

Params

  • waiter - the waiter instance
  • key - the key of the value, must be an integer
  • value - the value of the key
  • ttl - the time to live(milliseconds) of the key-value pair

Examples

iex> ExRocketmq.Remote.Waiter.put(waiter, 1, return_value, ttl: 5000)
@spec start(opts_schema_t()) :: t()

start the waiter

Options

  • :name (atom/0) - Required. The name of the waiter

  • :interval (integer/0) - The cleanup interval time in millisecond of the waiter The default value is 5000.

  • :opts (keyword/0) - The other options of the waiter The default value is [].

Examples

iex> ExRocketmq.Remote.Waiter.start(name: :waiter_name)
%ExRocketmq.Remote.Waiter{
  name: :waiter_name,
  pid: #PID<0.262.0>,
  interval: 5000
}
@spec stop(t()) :: :ok