Code Monkey home page Code Monkey logo

challenge's Introduction

Challenge

Setup

~/challenge $ mix deps.get
~/challenge $ mix compile
~/challenge $ mix dialyzer
~/challenge $ mix test
~/challenge $ mix docs

Concept

Many identically named entries from the original file with differing details will be ignored. This implementation assumes that a consumer simply wants to identify the name of a foodtruck that serves a particular dish. And that the consumer can track down the foodtruck via other means, such as social media. If this application were built for a municipal bureaucracy, perhaps all the various locations and relevant permits would be written to the cache, too.

Cache

An ETS table serves as the in-memory cache. Only the process named Cache can write data to the table. Every table row looks like the following:

{"foodTruckName", %{"mapKey": "value", "mapKey2": "value2"}}

Each key in the table is unique, because the table is configured as a set. And once written, a key can't be re-written, because of the following line:

:ets.insert_new(@table, d)

A simple Client API exists for other processes to read particular data from the cache, such as read_vendor() & read_food().

Router

A web server offers un-secured JSON responses, and properly terminates TCP connections after transactions complete. The web server offers a route for checking the health of the application. If this application relied on a database, an additional route for reporting the status of a connection to that dependency would be valuable.

Operate

Open two separate terminals, and use httpie to request data.

~/challenge $ MIX_ENV=prod mix release demo #terminal 1
~/challenge $ _build/prod/rel/demo/bin/demo start #terminal 1
~/challenge $ http get "localhost:8888/health" #terminal 2
~/challenge $ http get "localhost:8888/v0/vendor/Natan's Catering" #terminal 2
~/challenge $ http get "localhost:8888/v0/food/burger" #terminal 2

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.