# Acessor

## Description
`acessor` is a library to make it easy to orchestrate multiple services while using Elixir processes.

## Installation

the package can be installed by adding `acessor` to your list of dependencies in `mix.exs`:

def deps do
    {:acessor, "~> 0.1.1"}

## Run tests
  mix test

## Usage
  defmodule MyModule do
    use Acessor.Macros.Service

    def hello(name) do
      "Hello, " <> name

  services = %{:mymodule => MyModule}

  Acessor.config(services) # true
  {:response, response} = Acessor.invoke(:mymodule, :hello, ["Bob"])

  assert response == "Hello, Bob"


## Use Cases
`acessor` is useful when you have multiple services in your ecosystem, and you need to invoke them all the time. This could eliminate code duplication where all services could be centralized inside a library/repo for example:
  # this could be a new library/repo used across services

  defmodule MyService1 do
    def make_rest_request(_), do: :rest1

  defmodule MyService2 do
    def make_rest_request(_), do: :rest2

  services = %{:service_1 => MyService1, :service_2 => MyService2}

  Acessor.invoke(:service_1, :make_rest_request, []) # {:response, :rest1}
  Acessor.invoke(:service_2, :make_rest_request, []) # {:response, :rest2}


## Methods

`config/1 - services (inside %{})`

this method adds your services to the acessor, making it possible to invoke any methods after this initial setup.

`invoke/3 - service_name, method, args (inside [])`

this method uses `GenServer` to invoke your registered service, returning:
`{:response, response}` or `{:noresponse, nil}`