Clutch

Elixir Component library for writing code as servers

Elixir Component library for writing code as servers
Average rating: 0
(0 votes)

If you are interested in Elixir, it will be interesting for you to get to read more about this programming language in our blog. Today we are going to show you how you can use Elixir Component library for writing code as servers.

The Component Library makes it easy to create simple servers. It is an attempt to make it so easy to write trivial standalone servers that people will just naturally split their applications up that way.

A component is a simple module, containing what looks like function definitions. This library generates from it an API module, a GenServer module, and an implementation module.

There is a number of component types:

  • global: a singleton process
  • dynamic: on-demand processes
  • pooled: a pool of processes that typically represent limited resources
  • hungry: a pool of processes that process a collection in parallel

A global component must be created before use. Once created, it may be accessed by simply calling the functions it contains. There is no need to identify a particular worker, as there is only one per component. A global component may be destroyed, in which case it must be recreated before being used again.

Dynamic and pooled components must be initialized. This process does not necessarily create any worker processes; it simply prepares the component for use.

With dynamic components you gain access to a worker by telling the component to create it. This returns an identifier for that worker process, which you must pass to subsequent calls to functions in the component. You should eventually destroy workers that you create.

Pooled components are automatically created when needed, so there’s no need to call their create function.

Here you can find more details on the subject.

By the way, do you know that Elixir v1.8 released?

Rate this article, if you like it

Thanks! You’ve rated this material!

Got a project? Let's discuss it!

*By submitting this form you agree with our Privacy Policy.

Mailing & Legal Address

Syndicode Inc. 340 S Lemon Ave #3299, Walnut CA, 91789, USA

Visiting & Headquarters address
Kyiv Sofiivska 1/2a, 01001, Kyiv, Ukraine
Dnipro Hlinky 2, of. 1003, 49000, Dnipro, Ukraine
Email info@syndicode.com
Phone (+1) 9035021111