Skip to content
A collection of packages for building a Go microservice on the LUSH platform
Go
Branch: master
Clone or download
Latest commit 2c20f46 Aug 15, 2019

README.md

License Go Report Card Build Status GoDoc

Core (Go)

A collection of packages for building a Go microservice on the LUSH platform.

Quick start

Below there's an example for how to get running quickly with a service using the LUSHDigital core package.

package main

import (
	"context"
	"net/http"
	"time"

	"github.com/LUSHDigital/core"
	"github.com/LUSHDigital/core/workers/httpsrv"
	"github.com/LUSHDigital/core/workers/keybroker"
	"github.com/LUSHDigital/core/workers/metricsrv"
	"github.com/LUSHDigital/core/workers/readysrv"
)

var service = &core.Service{
	Name:    "example",
	Type:    "service",
	Version: "1.0.0",
}

func main() {
	core.SetupLogs()

	metrics := metricsrv.New(nil)
	broker := keybroker.NewPublicRSA(nil)
	readiness := readysrv.New(readysrv.Checks{
		"rsa_key": broker,
	})

	server := httpsrv.New(&http.Server{
		ReadTimeout: 10 * time.Second,
		Handler: http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
			w.WriteHeader(200)
			w.Write([]byte("hello world"))
		}),
	})

	service.StartWorkers(context.Background(),
		server,
		metrics,
		broker,
		readiness,
	)
}

Documentation

Documentation and examples are provided in README files in each pacakge.

Core Concepts

These packages contain functionality for the core concepts of our services.

Middlewares

These packages contain convenient middlewares for transport protocols like HTTP REST and gRPC.

Service Workers

These packages contain convenient service workers things like network servers, background workers and message brokers.

Plugins

There are a few libraries that can be used in conjunction with the core library containing their own service workers, ready checks and/or middlewares.

  • core-redis: Libraries for connecting to, and working with a Redis store.
  • core-sql: Libraries for connecting to, and working with an SQL database.

Tools

There are a few tools that can be used with projects that use the core libary.

  • jwtl: A command line tool to help generating JWTs during development.

Recommended Libraries

Some libraries have been designed to work together with the core library and some are even dependencies. Consider using these if you need extended functionality for certain things.

  • LUSHDigital/scan: Scan database/sql rows directly to structs, slices, and primitive types, originally forked from github.com/blockloop/scan
  • LUSHDigital/uuid: A UUID package originally forked from github.com/gofrs/uuid & github.com/satori/go.uuid
You can’t perform that action at this time.