LogflareEx.Batcher (logflare_ex v0.2.0-dev.082a725d)
Batching cache is an Etso repo, LogflareEx.Repo
, and stores all events to be sent to the Logflare service.
There are 2 states that an event can be in:
- pending
- inflight
If an event is inflight, it will have an :inflight_at
timestamp stored on the struct.
Summary
Functions
Returns a specification to start this module under a supervisor.
Creates an event in the batching cache. This event will be considered as pending if it does not have an :inflight_at
value set.
Deletes all events in the cache, regardless of the status.
Deletes a single event in the cache.
Performs a flush for the given source.
Lists all events within the cache. All arguments provided are considered additive filters.
Updates the event within the batching cache.
Returns the via for each partitioned Batcher. Accepts a source_token
or source_name
filter or a %LogflareEx.Client{}
struct.
Functions
child_spec(init_arg)
Returns a specification to start this module under a supervisor.
See Supervisor
.
create_event(attrs)
@spec create_event(map()) :: {:ok, LogflareEx.BatchedEvent.t()}
Creates an event in the batching cache. This event will be considered as pending if it does not have an :inflight_at
value set.
An event should only be created after all payload manipulations has been performed. The payload will be stored on the :body
key.
All timestamp fields internally on the struct are NaiveDateTime.
Required fields:
- :body
- :source_token or :source_name
delete_all_events()
@spec delete_all_events() :: :ok
Deletes all events in the cache, regardless of the status.
delete_event(event)
@spec delete_event(LogflareEx.BatchedEvent.t()) :: {:ok, LogflareEx.BatchedEvent.t()}
Deletes a single event in the cache.
Example
iex> delete_event(event)
{:ok, %BatchedEvent{...}}
flush(kw)
@spec flush(kw_filter()) :: :ok
Performs a flush for the given source.
Accepts the following filters: :source_name
or :source_token
Flush is performed asyncronously.
list_events_by(type, opts \\ [])
@spec list_events_by(status_filter(), list_opts()) :: [LogflareEx.BatchedEvent.t()]
Lists all events within the cache. All arguments provided are considered additive filters.
Example
list_events_by(:pending)
list_events_by(:all)
list_events_by(:inflight)
list_events_by(:all, source_token: "...")
list_events_by(:all, source_name: "...")
list_events_by(:all, source_name: "...", limit: 5)
Limitations
Etso does not support the Ecto.Query :limit
option, hence filtering is done post result fetch.
start_link(opts)
update_event(event, attrs)
@spec update_event(LogflareEx.BatchedEvent.t(), map()) :: {:ok, LogflareEx.BatchedEvent.t()}
Updates the event within the batching cache.
via(arg1)
@spec via(LogflareEx.Client.t() | kw_filter()) :: identifier()
Returns the via for each partitioned Batcher. Accepts a source_token
or source_name
filter or a %LogflareEx.Client{}
struct.
Example
via(source_name: "my source")
via(source_token: "some-uuid")
via(%LogflareEx.Client{...})