-module(pharos@internal@hot_buffer). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/pharos/internal/hot_buffer.gleam"). -export([from_table/1, table_name/1, table/1, start_link/2, child_spec/2, push/2, drain/1, peek/1, size/1]). -export_type([hot_buffer/0]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. ?MODULEDOC(false). -opaque hot_buffer() :: {hot_buffer, gleam@erlang@atom:atom_()}. -file("src/pharos/internal/hot_buffer.gleam", 30). ?DOC(false). -spec from_table(gleam@erlang@atom:atom_()) -> hot_buffer(). from_table(Table) -> {hot_buffer, Table}. -file("src/pharos/internal/hot_buffer.gleam", 38). ?DOC(false). -spec table_name(gleam@erlang@process:name(any())) -> gleam@erlang@atom:atom_(). table_name(Name) -> pharos_ffi:name_to_atom(Name). -file("src/pharos/internal/hot_buffer.gleam", 41). ?DOC(false). -spec table(hot_buffer()) -> gleam@erlang@atom:atom_(). table(Buffer) -> erlang:element(2, Buffer). -file("src/pharos/internal/hot_buffer.gleam", 59). ?DOC(false). -spec start_link(gleam@erlang@atom:atom_(), integer()) -> {ok, gleam@otp@actor:started(hot_buffer())} | {error, gleam@otp@actor:start_error()}. start_link(Table, Capacity) -> _pipe@2 = gleam@otp@actor:new_with_initialiser( 1000, fun(_) -> pharos_ffi:hot_buffer_init(Table, Capacity), _pipe = gleam@otp@actor:initialised({hot_buffer, Table}), _pipe@1 = gleam@otp@actor:returning(_pipe, {hot_buffer, Table}), {ok, _pipe@1} end ), gleam@otp@actor:start(_pipe@2). -file("src/pharos/internal/hot_buffer.gleam", 52). ?DOC(false). -spec child_spec(gleam@erlang@atom:atom_(), integer()) -> gleam@otp@supervision:child_specification(hot_buffer()). child_spec(Table, Capacity) -> gleam@otp@supervision:worker(fun() -> start_link(Table, Capacity) end). -file("src/pharos/internal/hot_buffer.gleam", 74). ?DOC(false). -spec push(hot_buffer(), pharos@metric:metric()) -> boolean(). push(Buffer, Metric) -> pharos_ffi:hot_buffer_push(erlang:element(2, Buffer), Metric). -file("src/pharos/internal/hot_buffer.gleam", 80). ?DOC(false). -spec drain(hot_buffer()) -> list(pharos@metric:metric()). drain(Buffer) -> pharos_ffi:hot_buffer_drain(erlang:element(2, Buffer)). -file("src/pharos/internal/hot_buffer.gleam", 85). ?DOC(false). -spec peek(hot_buffer()) -> list(pharos@metric:metric()). peek(Buffer) -> pharos_ffi:hot_buffer_peek(erlang:element(2, Buffer)). -file("src/pharos/internal/hot_buffer.gleam", 90). ?DOC(false). -spec size(hot_buffer()) -> integer(). size(Buffer) -> pharos_ffi:hot_buffer_size(erlang:element(2, Buffer)).