Giter VIP home page Giter VIP logo

go-microservice's Introduction

go-microservice

REST Microservice developed in Go. Works with following struct:

type Product struct {
	ID          int     `json:"id" storm:"id,increment=3"`
	Name        string  `json:"name" validate:"required"`
	Description string  `json:"description"`
	Price       float32 `json:"price" validate:"required,gt=0"`
	SKU         string  `json:"sku" validate:"required,sku"`
	CreatedOn   string  `json:"-"`
	UpdatedOn   string  `json:"-"`
	DeletedOn   string  `json:"-"`
}

Packages used

Other resources

Usage

Fetch all products

curl localhost:9090

Fetch a specific product

curl localhost:9090/{id}

Add product

curl localhost:9090 -X POST -d `{"name":"New product", "price":3.22, "sku":"abc-abcd-abcde"...}`

Update product

curl localhost:9090/{id} -X PUT -d `{"name":"Updated", "price":1.99, "sku":"abc-abcd-abcde"...}`

Remove product

curl localhost:9090/{id} -X DELETE

RabbitMQ

You can run the service with the following command

go run main.go -rabbitmq

This will enable RabbitMQ service and will run both the consumer and producer.

  • Service uses the following data model:
type User struct {
	ID        int       `json:"id" storm:"id,increment=1"`
	FirstName string    `json:"first_name"`
	LastName  string    `json:"last_name"`
	Email     string    `json:"email"`
	Gender    string    `json:"gender"`
	IPAddress string    `json:"ip_address"`
	CreatedAt time.Time `json:"created_at"`
}
  • Producer will publish the message to queue every 10 seconds.
  • The message is fetched from mock API.
  • Consumer will consume the message and insert the user into BoltDB database.

Fetch all users

curl localhost:9090/users

go-microservice's People

Contributors

dzonint avatar

Watchers

 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.