Skip to content

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

License

Notifications You must be signed in to change notification settings

LUSHDigital/core

Folders and files

NameName
Last commit message
Last commit date

Latest commit

bdca51b · Nov 20, 2020
Feb 12, 2020
Aug 28, 2019
Mar 19, 2020
Jul 4, 2019
Apr 17, 2020
Feb 12, 2020
Sep 16, 2020
Mar 19, 2020
Jun 8, 2020
Sep 30, 2019
Oct 3, 2019
Apr 3, 2019
Apr 3, 2019
Nov 20, 2020
May 14, 2020
May 14, 2020
Oct 2, 2019
Feb 12, 2020
Sep 30, 2019

Repository files navigation

License Go Report Card Build Status Documentation

Donguri by Cerys Evans 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/middleware/metricsmw"
	"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() {
	metrics := metricsrv.New(nil)
	broker := keybroker.NewPublicRSA(nil)
	readiness := readysrv.New(nil, readysrv.Checks{
		"public_rsa_key": broker,
	})

	handler := metricsmw.MeasureRequests(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
		w.WriteHeader(200)
		w.Write([]byte("hello world"))
	}))

	server := httpsrv.New(&http.Server{
		ReadTimeout: 10 * time.Second,
		Handler:     handler,
	})

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

Documentation

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

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.

Workers

These packages contain convenient 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.

Tools

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

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 a struct, slice, or primitive any type. Originally forked from github.com/blockloop/scan
  • LUSHDigital/uuid: A UUID package originally forked from github.com/gofrs/uuid & github.com/satori/go.uuid
  • LUSHDigital/spew: A pretty-printer package originally forked from github.com/davecgh/go-spew/spew

Contributors