{"id":13776683,"url":"https://github.com/exponentially/helios_aggregate","last_synced_at":"2025-04-23T18:09:44.699Z","repository":{"id":57504776,"uuid":"135908303","full_name":"exponentially/helios_aggregate","owner":"exponentially","description":null,"archived":false,"fork":false,"pushed_at":"2018-08-31T07:45:58.000Z","size":17,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-12T15:46:44.125Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/exponentially.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-03T13:51:12.000Z","updated_at":"2023-07-14T17:34:16.000Z","dependencies_parsed_at":"2022-09-19T05:30:10.285Z","dependency_job_id":null,"html_url":"https://github.com/exponentially/helios_aggregate","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exponentially%2Fhelios_aggregate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exponentially%2Fhelios_aggregate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exponentially%2Fhelios_aggregate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exponentially%2Fhelios_aggregate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/exponentially","download_url":"https://codeload.github.com/exponentially/helios_aggregate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250304757,"owners_count":21408874,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T18:00:31.564Z","updated_at":"2025-04-23T18:09:44.676Z","avatar_url":"https://github.com/exponentially.png","language":"Elixir","funding_links":[],"categories":["Libraries"],"sub_categories":[],"readme":"# Helios.Aggregate\n\nElixir library defining Aggregate behaviour and providing extendable facility for aggregate command pipeline.\n\nPlease note this package is not full CQRS framework. We strongly disagree that CQRS can be boxed into framewrok, it is rather set of\ntechniques you CAN apply to your service architecture.\n\n## Installation\n\n[Available in Hex](https://hex.pm/packages/helios_aggregate), the package can be installed\nby adding `helios_aggregate` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:helios_aggregate, \"~\u003e 0.1\"}\n  ]\nend\n```\n\n## Aggregate example\n\n```elixir\ndefmodule Customer do\n  use Helios.Aggregate\n\n  # Aggregate state\n  defstruct [:first_name, :last_name, :email]\n\n  # Events emitted by aggregate\n  defmodule CustomerCreated, do: defstruct [:id, :first_name, :last_name]\n  defmodule CustomerContactCreated, do: defstruct [:email]\n\n  def create(ctx, %{first_name: first_name, last_name: last_name, email: email}) do\n    \n    ctx\n    |\u003e emit_event(%CustomerCreated{first_name: first_name, last_name: last_name})\n    |\u003e emit_event(%CustomerContactCreated{email: email})\n  end\n\n  def apply_event(customer, %CustomerCreated{}=event) do\n    %{customer|\n      first_name: event.first_name,\n      last_name: event.last_name\n    }\n  end\n\n  def apply_event(customer, %CustomerContactCreated{email: email}) do\n    %{customer| email: email}\n  end\nend\n```\n\n```elixir\n  ctx = %Helios.Aggregate.Pipeline.Context{\n    aggregate: %Helix.Aggregate{state: },\n    aggregate_module: CustomerAggregate,\n    correlation_id: \"1234567890\",\n    command: :create_user,\n    peer: self(),\n    params: %{first_name: \"Jhon\", last_name: \"Doe\", email: \"jhon.doe@gmail.com\"}\n  }\n\n  Cusomer.call(ctx, :create)\n    \n```\n\n## Logger configuration\n\nWe build logger which should log each command sent to aggregate. Since commands can cary some confidential information, or you have to be PCI DSS compliant, \nwe expsed configuration like below where you could configure which filed values in command should be retracted.\n\nBelow is example where list of field names are given. Please note, the logger plug will not try to conver string to atom or other way round, if you have both case\nplease state them in list as both, string and atom.\n```elixir\nuse Mix.Config\n\n# filter only specified\nconfig :helios_aggregate, \n  :filter_parameters, [:password, \"password\", :credit_card_number]\n\n# filter all but keep original values\nconfig :helios_aggregate, \n  :filter_parameters, {:keep, [:email, \"email\", :full_name]}\n\n# retract only specified field values\nconfig :helios_aggregate, \n  :filter_parameters, [:password, \"password\", :credit_card_number]\n\n\n```\n\nDocumentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)\nand published on [HexDocs](https://hexdocs.pm). Once published, the docs can\nbe found at [https://hexdocs.pm/helios_aggregate](https://hexdocs.pm/helios_aggregate).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexponentially%2Fhelios_aggregate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexponentially%2Fhelios_aggregate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexponentially%2Fhelios_aggregate/lists"}