Raxol.Audit.Storage (Raxol v2.0.1)

View Source

Functional version of the specialized storage backend for audit logs with indexing and search capabilities.

This module provides efficient storage and retrieval of audit events with support for complex queries, full-text search, and compliance reporting, using pure functional error handling patterns instead of try/catch blocks.

Summary

Functions

Returns a specification to start this module under a supervisor.

Creates an index on a specific field for faster queries.

Deletes events older than the specified timestamp.

Gets storage statistics.

Queries audit events with filters and options.

Queries audit events with filters and options from a specific storage.

Stores a batch of audit events.

Types

query_filter()

@type query_filter() :: %{
  optional(:user_id) => String.t(),
  optional(:event_type) => atom(),
  optional(:severity) => atom(),
  optional(:start_time) => integer(),
  optional(:end_time) => integer(),
  optional(:resource_type) => String.t(),
  optional(:resource_id) => String.t(),
  optional(:ip_address) => String.t(),
  optional(:session_id) => String.t(),
  optional(:text_search) => String.t()
}

query_options()

@type query_options() :: %{
  optional(:limit) => pos_integer(),
  optional(:offset) => non_neg_integer(),
  optional(:sort_by) => atom(),
  optional(:sort_order) => :asc | :desc,
  optional(:include_metadata) => boolean()
}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

create_index(storage \\ __MODULE__, field)

Creates an index on a specific field for faster queries.

delete_before(storage \\ __MODULE__, timestamp)

Deletes events older than the specified timestamp.

get_events_in_range(storage \\ __MODULE__, start_time, end_time)

Gets events within a time range.

get_statistics(storage \\ __MODULE__)

Gets storage statistics.

handle_manager_cast(msg, state)

Callback implementation for Raxol.Core.Behaviours.BaseManager.handle_manager_cast/2.

query(filters, opts \\ [])

Queries audit events with filters and options.

query(storage, filters, opts)

Queries audit events with filters and options from a specific storage.

start_link(init_opts \\ [])

store_batch(storage \\ __MODULE__, events)

Stores a batch of audit events.