Documentation
¶
Index ¶
- Variables
- type Client
- func (c *Client) BufferWrite(record map[string]interface{}) error
- func (c *Client) Close() error
- func (c *Client) Flush(ctx context.Context) error
- func (c *Client) IsConnected() bool
- func (c *Client) MarkConnected()
- func (c *Client) Ping(ctx context.Context) error
- func (c *Client) Query(ctx context.Context, sql string) ([]map[string]interface{}, error)
- type Defaults
- type Registry
Constants ¶
This section is empty.
Variables ¶
var ErrNoArcInstance = errors.New("no arc instance configured for org")
ErrNoArcInstance is returned by Registry.Get when the requested org has no configured Arc instance. Surface as HTTP 503 at the request edge.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the Arc HTTP API for writing and querying memories
func NewClient ¶
func NewClient(baseURL, apiKey, database, measurement string, batchSize int, flushIntervalMS int, connectTimeout int, queryTimeout int, logger zerolog.Logger) *Client
NewClient creates a new Arc HTTP client
func (*Client) BufferWrite ¶
BufferWrite adds a record to the write buffer. Flushes when batch size is reached. If the buffer exceeds maxBufferSize, the oldest records are dropped.
func (*Client) Close ¶
Close stops the background flush and health check, then flushes remaining records. Safe to call multiple times.
func (*Client) Flush ¶
Flush writes all buffered records to Arc using columnar msgpack format. On failure, records are re-buffered so they can be retried on the next cycle. Serialized via flushMu to prevent concurrent flush races.
func (*Client) IsConnected ¶
IsConnected returns the last known connection state from the background health check.
func (*Client) MarkConnected ¶
func (c *Client) MarkConnected()
MarkConnected sets the connection state to true. Called after a successful startup Ping.
type Defaults ¶
type Defaults struct {
ConnectTimeout int
QueryTimeout int
WriteBatchSize int
WriteFlushIntervalMS int
}
Defaults are the timing/batch knobs shared by every Arc client. Per-org values (URL, API key, database, measurement) live in the metadata DB.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry resolves *Client instances by org_id. Built once at startup; per-org adds/removes go through Reload to keep the cache coherent.
func NewRegistry ¶
func NewRegistry(ctx context.Context, store *metadata.ArcInstanceStore, defaults Defaults, logger zerolog.Logger) (*Registry, error)
NewRegistry eagerly builds clients for every row in arc_instances. Returns a non-nil registry even when the table is empty (Get will then return ErrNoArcInstance for every org until Reload is called).
func (*Registry) Get ¶
Get returns the *Client for an org, or ErrNoArcInstance if none is configured.
func (*Registry) Health ¶
Health returns the per-org health snapshot from each client's background health check.