Skip to content

Barenboim is prepared to tackle with data streaming dependencies in concurrent flows

License

Notifications You must be signed in to change notification settings

mendrugory/barenboim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Barenboim

hex.pm hexdocs.pm Build Status

Barenboim is prepared to tackle with data streaming dependencies in concurrent flows.

If your application works with a data streaming and your incoming events could have dependencies between them, the app can have problems when:

  • The Application which is sending the data is not sending the data in the right order.
  • Your Application is treating the data concurrently therefore the order is not ensured.

Installation

Add barenboim to your list of dependencies in mix.exs:

def deps do
  [{:barenboim, "~> 0.3.1"}]
end

Configuration

Barenboim uses poolboy and you can configure it depending on your needs:

config :barenboim,
  pool_domain: :global,     # default :local
  pool_size: 20,            # default 10
  max_overflow: 3           # default 5

You can also configure a delay for a reminder notification. A reminder notification is sent in order to avoid corner cases (notification between the data access and the registration of a dependency). This time (milliseconds) should be defined depending on your data access function time (see next section).

config :barenboim,
  reminder_time: 50     # default 100

How to use it

Define the function that will retrieve the dependency data where dependency_ref is the reference of your data and call Barenboim.get_data. You can also specify a time out in milliseconds.

fun = fn(dependency_ref) -> MyDataModule.get(dependency_ref) end
{:ok, data} = Barenboim.get_data(dependency_ref, fun)

Meanwhile, the flow that is processing a new event has to notify when the data is available for others.

Barenboim.notify({:reference, dependency_ref})

Or you can even attach the data:

Barenboim.notify({:data, dependency_ref, dependency_data})

Test

Run the tests.

mix test 

In honor of

Daniel Barenboim

About

Barenboim is prepared to tackle with data streaming dependencies in concurrent flows

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages