Git Product home page Git Product logo

fb_manager_otp's Introduction

FbManagerOtp

Code based on "Intro to OTP In Elixir" (https://www.youtube.com/watch?v=CJT8wPnmjTM)

A small application wrapper for https://www.fantasyfootballnerd.com/. Uses the the ffnerd-api-elixir elixir API(https://github.com/jessejanderson/ffnerd-api-elixir). This application uses OTP for its process management.

Getting Started

Clone the repo locally

git clone https://github.com/mazz/fb_manager_otp.git

Get dependencies and compile dependencies

mix deps.get && mix deps.compile

Add compiled app to iex runtime

iex -S mix

IEX> Start the supervisor

FbManagerOtp.Supervisor.start_link

IEX> Demonstrate that server is already running because of supervisor

FbManagerOtp.Server.start_link # gets created when Supervisor does

IEX> Add some team members

FbManagerOtp.Server.add("Russell Wilson")
FbManagerOtp.Server.add("Doug Baldwin")

IEX> Display fantasy team

FbManagerOtp.Server.team

IEX> Remove a team member

FbManagerOtp.Server.remove("Doug Baldwin")

IEX> Display fantasy team again

FbManagerOtp.Server.team

IEX> Find elixir process by Atom

Process.whereis(:fb_manager)

IEX> Kill server

Process.whereis(:fb_manager) |> Process.exit(:kill)

IEX> Demonstrate that server is re-created by supervisor

Process.whereis(:fb_manager)

Application initialization In mix.exs, add application initialization

mix.exs, add to applications do

| mod: {FbManagerOtp.Application, []}

Run IEX again

iex -S mix

IEX> Demonstrate that we didn't need to call start_link because application already did

FbManagerOtp.Server.add("Russell Wilson") # did not need to call start_link

IEX> Inspect the Erlang Runtime

:observer.start

IEX> Add a player again

FbManagerOtp.Server.add("Doug Baldwin")

IEX> Inspect the team

FbManagerOtp.Server.team

IEX> Kill the server

Process.whereis(:fb_manager) |> Process.exit(:kill)

IEX> See, the server got restarted, no state

FbManagerOtp.Server.team
mix run --no-halt # run forever

Installation

If available in Hex, the package can be installed by adding fb_manager_otp to your list of dependencies in mix.exs:

def deps do
  [
    {:fb_manager_otp, "~> 0.1.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/fb_manager_otp.

fb_manager_otp's People

Contributors

mazz avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.