Trogon.Commanded.TypeProvider (Trogon.Commanded v0.37.0)

Copy Markdown View Source

Implements Commanded.EventStore.TypeProvider behavior. Using macros to generate the behavior.

Summary

Functions

Imports all the types from another module defined by Trogon.Commanded.TypeProvider.

Registers a mapping from a Protobuf message module using its full_name/0 function as the type.

Registers a mapping from an name string to an Elixir Module that defines a struct.

Functions

import_type_provider(provider_mod)

(macro)
@spec import_type_provider(provider_mod :: module()) :: Macro.t()

Imports all the types from another module defined by Trogon.Commanded.TypeProvider.

Example

defmodule UserTypeProvider do
  use Trogon.Commanded.TypeProvider
  # ...
end

defmodule MyAppTypeProvider do
  use Trogon.Commanded.TypeProvider

  import_type_provider UserTypeProvider
end

register_protobuf_message(struct_mod)

(macro)
@spec register_protobuf_message(struct_mod :: module()) :: Macro.t()

Registers a mapping from a Protobuf message module using its full_name/0 function as the type.

Example

defmodule MyTypeProvider do
  use Trogon.Commanded.TypeProvider

  register_protobuf_message MyApp.Proto.AccountCreated
end

register_type(name, struct_mod)

(macro)
@spec register_type(name :: String.t(), struct_mod :: module()) :: Macro.t()

Registers a mapping from an name string to an Elixir Module that defines a struct.

Example

defmodule MyTypeProvider do
  use Trogon.Commanded.TypeProvider,
    prefix: "accounts." # optional, adds the prefix to the type name

  register_type "account_created", AccountCreated
end