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

sadcad
I love the Phoenix and Elixir docs, but I always tend to learn faster when I watch a video of someone explaining things and then I implem...
New
woohaaha
I’m coming from Ruby and Rails. I have read some Elixir and Phoenix books. They shed a lot of light about building applications in Elixir...
New
LegitStack
I’m not a hugely experienced programmer, just a few years. So I’m looking for resources to learn about a topic but I can’t seem to find m...
New
asfand
I already created an Elixir Phoenix app for learning purpose. In this app students of our collage will create profiles, and will chat wit...
New
aswinmohanme
I recently finished the Udemy course on Elixir and Phoenix and I am thinking about using it for the next project. But I am stuck as how t...
New
markdev
What are the best beginner resources for learning Elixir and OTP (not Phoenix) in 2018?
New
miguelsrrobo
hi i was wondering if it is necessary to learn erlang to learn elixir
New
ca1989
Hi all, is there any up to date resource out there (blog, talk, video, book…) about deploying elixir applications using releases? In pa...
New
g5becks
Hello everyone. So I just got done reading all of the introduction to Elixir and working through the basics of the language. I am not new...
New
QueenSvetlana
My bookstore has Introducing Elixir: Getting Started In Functional Programming and the front cover says the book uses Elixir 1.4. The cur...
New

Other popular topics Top

malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement