Arc.Application (cratis_arc v0.1.0)

Copy Markdown View Source

The runtime of one Arc application: discovery, configuration and the processes that serve observable queries.

defmodule MyApp.Arc do
  use Arc.Application, otp_app: :my_app
end

Start it in your supervision tree, after the Chronicle client:

children = [
  {Chronicle.Client, ...},
  MyApp.Arc
]

There is no global configuration. Everything is scoped to the application module, so tests and several Arc applications in one VM stay isolated.

Options

Options are given to use and merged over config :my_app, MyApp.Arc, [...].

  • :otp_app - (required) the OTP application whose modules are scanned for commands and read models (anything defining __arc__/0)
  • :artifacts - an explicit list of modules instead of scanning :otp_app
  • :route_prefix - default "api"
  • :segments_to_skip - leading module-name segments dropped from routes, slice locations and proxy folders; default 1 (the application name)
  • :chronicle - options given to every Chronicle call, for example [client: MyApp.Chronicle]
  • :authentication - a list of Arc.Authentication handler modules, run in order
  • :policies - [name: PolicyModule] for Arc.Policy
  • :filters - Arc.Filter modules: cross-cutting rules that run for every command and query
  • :tenant_header - default "x-cratis-tenant-id"; the header the :header tenancy resolver reads, and the fallback of the :subdomain one
  • :tenancy - how the tenant is resolved, see Arc.Tenancy: resolver (:header, :query, :claim, :subdomain, :fixed, :development or a module), header, query_parameter, claim_type, base_domain and tenant_id. A named tenant also selects the Chronicle namespace of every call made through the context
  • :correlation_header - default "x-correlation-id"
  • :max_body_bytes - request body limit; default 1_000_000
  • :introspection - who may read the discovery routes (/.cratis/commands, /.cratis/queries, /.cratis/identity-details/schema, /.cratis/users, /.cratis/tenants): :authenticated (default), :anonymous or false to remove them. /.cratis/me is not affected
  • :expose_exceptions - include exception messages and stack traces in results; default false, which replaces them with a generic message (the detail is always logged)
  • :identity_details - the Arc.Identity.Provider module to use; by default the single provider found in :otp_app. Without a provider /.cratis/me is not served
  • :trust_forwarded_identity_headers - let Arc.Authentication.MicrosoftIdentityPlatform accept the x-ms-client-principal* headers; default false. Enable only behind an ingress that authenticates callers and strips client-supplied identity headers
  • :forwarded_identity - signed forwarded identity, see Arc.Identity.SignedForwarding: enabled, audience, keys: [[key_id:, secret_base64:]]
  • :on_behalf_of - acting on behalf of a user, see Arc.Identity.OnBehalfOf: enabled, issuer, audience, service, clock_skew (seconds), signing_keys: [[key_id:, public_key_pem:]]

Summary

Functions

The artifact descriptors of an application: %{commands: [...], read_models: [...]}.

Functions

artifacts(app)

@spec artifacts(module()) :: %{
  commands: [Arc.Descriptor.t()],
  read_models: [Arc.Descriptor.t()]
}

The artifact descriptors of an application: %{commands: [...], read_models: [...]}.