nickon

nickon

How to supervise OTP server turned into a component

Hi all,

New to Elixir and loving it so far :smiley: I’ve been making my way through Programming Elixir >= 1.6 by Dave Thomas and really liking the parts where he goes beyond just teaching you the language.

One of these parts is in Chapter 17 where he states that he likes to seperate the API, GenServer and Implementation specifics into seperate modules and files. I really like that too.

Hence, I implemented the exercise (the Stack GenServer built throughout Chapter 17) in that way as well. However, when you get to the next chapter (OTP: Supervisors) and want to supervise that GenServer by adding it to the children of a standard OTP application, there is a little bit of a hickup. This seems to be due to the split of the API and the GenServer.

My API (module Stack defined in stack.ex) contains:

  • start_link
  • push
  • pop

My GenServer (module Stack.Server defined in stack/server.ex) contains:

  • init
  • handle_call
  • handle_cast
  • terminate

Forgive me to cut to the chase, I can give more details later if needed, but the big question with “splitting this server up into a component” is: which of these do I pass as a child to my supervisor? (both give errors)"

Best regards,
Nick

First Post!

alakra

alakra

Hi Nick!

Glad to hear you’re enjoying the language!

Your supervisor needs to know which module contains the exported function for starting the module. By the looks of your API, it appears to be Stack.start_link.

You might consider reading this post before going further.

– angelo

Where Next?

Popular in Chat/Questions Top

ariandanim
Hello all, I am still learning Elixir, then go into Phoenix, i am try search in google but find the programming phoenix 1.4, another for...
New
peerreynders
Manning 2016 Halloween weekend sale via Deal of the Day Friday, October 28 - Half off all MEAPs - code WM102816LT Saturday, October 29 ...
326 29600 154
New
roshan
Hi everyone, I’m looking for a book on Phoenix server hosting / deployment like the following books for Rails, Docker for Rails Develop...
New
gouvermxt
I just finished the “Learn Functional Programming with Elixir (Pragprog)” book. I have 5+ years of experience with Ruby/Rails, my goal is...
New
jslearner
Will learning Erlang really help in being a better Phoenix or Elixir developer or is it a waste of time?
New
jace
I wanted to write a library for interacting with a Web API as a practical way of learning Elixir. However, there seem to be a lot of diff...
New
New
lgmfred
Hello, I want to get started with elixir today. Having learnt the basics of Erlang (my first ever language) and seen what it’s can do, I’...
New
pdgonzalez872
Do we have a list of academic/research papers: about Elixir/Erlang? that use Elixir/Erlang? about the Beam? If so, could you please po...
New
Fl4m3Ph03n1x
Background Hey guys, recently I bought a book on TDD that I am reading. The books is really nice and has some really juicy things on arch...
New

Other popular topics Top

Tee
can someone please explain to me how Enum.reduce works with maps
New
William
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New

We're in Beta

About us Mission Statement