Rulestead.Tenancy behaviour (rulestead v0.1.1)

Copy Markdown View Source

Explicit seam for resolving and bounding tenant scope across runtime helpers.

Summary

Types

tenant_scope()

@type tenant_scope() :: String.t() | atom() | nil

Callbacks

compose_bucket_identity(context, bucket_by, default_identity)

@callback compose_bucket_identity(
  context :: Rulestead.Context.t(),
  bucket_by :: atom() | String.t(),
  default_identity :: String.t() | nil
) :: String.t() | nil

resolve_tenant(conn_or_socket_or_params)

@callback resolve_tenant(conn_or_socket_or_params :: term()) :: tenant_scope()

same_tenant?(a, b)

@callback same_tenant?(a :: tenant_scope(), b :: tenant_scope()) :: boolean()

tenant_topic(base_topic, tenant)

@callback tenant_topic(base_topic :: String.t(), tenant :: tenant_scope()) :: String.t()

Functions

compose_bucket_identity(context, bucket_by, default_identity)

@spec compose_bucket_identity(
  Rulestead.Context.t(),
  atom() | String.t(),
  String.t() | nil
) ::
  String.t() | nil

module()

@spec module() :: module()

normalize_tenant(value)

@spec normalize_tenant(term()) :: tenant_scope()

resolve_tenant(input)

@spec resolve_tenant(term()) :: tenant_scope()

same_tenant?(a, b)

@spec same_tenant?(tenant_scope(), tenant_scope()) :: boolean()

tenant_topic(base_topic, tenant)

@spec tenant_topic(String.t(), tenant_scope()) :: String.t()