Giter VIP home page Giter VIP logo

task's Introduction

The Task

Create a production ready web service which combines two existing web services. Fetch a random name from https://names.mcquay.me/api/v0 Fetch a random Chuck Norris joke from http://api.icndb.com/jokes/random?firstName=John&lastName=Doe&limitTo=nerdy Combine the results and return them to the user.

The Solution

Go Report Card

Project structure

The project structure is taken from the set of common historical and emerging project layout patterns in the Go ecosystem. It may look ambiguous for such a small project butt it really worth it for bigger projects.

Elapsed time

It took me approx. one hour to build the first working version and three more hours to refactor the code.

Known issues

There are some unhandled errors in deferred calls.

Tests

To prevent over-engineering only one important function is tested. This is common for real-world programming. Also, note that tests run every time Docker image is being built.

Clone the repository:

$ git clone https://github.com/wildsurfer/task

Build Docker image:

Docker image is built from the scratch image and is extremely small (~9mb) which is good for CI/CD pipelines.

$ cd task
$ docker build -f ./build/package/Dockerfile -t task .

Run:

$ docker run -it --rm -p 5000:5000 task .

Try:

$ docker run -it --rm -p 5000:5000 kek .
$ curl "http://localhost:5000"

Try concurrent requests:

$ ab -n 1000 -c 100  "http://localhost:5001/"

task's People

Contributors

wildsurfer avatar dmarkham avatar

Watchers

James Cloos 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.