Coder Social home page Coder Social logo

go-events-service's Introduction

go-events-service

A simple Go web service allowing storage of time-based events.

Recording an event

POST /events
{
	"name": "test",
	"timestamp": "2015-02-11T15:01:00+00:00"
}

Aggregating events

GET /events/count?from=2015-02-11T15:01:00+00:00&to=2015-02-11T15:01:59+00:00
{
	"test": 1
}

Playing around

Docker

The service has been containerised using Docker. If you'd like to play around, you need to install docker first (it's worth it!).

Running

A makefile is provided to help with common tasks. To spin up a working instance of the service, simply type make run at the repository root. Once the service has started, docker ps will show it's running containers:

$ docker ps
CONTAINER ID        IMAGE                             STATUS              PORTS                     NAMES
5ee27d857668        go-events-service:latest          Up 5 seconds        0.0.0.0:49161->5000/tcp   go-events-service-app
6ede52667e85        redis:latest                      Up 24 hours         6379/tcp                  go-events-service-redis

As you can see, the service comprises two Docker containers by default, one for the Go web application and one for the backing redis datastore. The app container exposes its functionality on port 5000 and this is bound to a high port on the host machine (49161 in this example). In this example, to store an event via the service, we would make a POST request to http://localhost:49161/events. If you are running on MacOSX using boot2docker, you will access the service via the boot2docker host IP rather than localhost. This can be obtained as follows:

$ boot2docker ip
192.168.59.103

Testing

Similarly, a make target is provided to run the application's test suite. make test spins up a Docker container with all the system-level and Go dependencies required to run the tests, printing test results and coverage before exiting.

go-events-service's People

Forkers

shimaomao

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.