A collection of packages for building a Go microservice on the LUSH platform.
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 and examples are provided in README files in each package.
These packages contain functionality for the core concepts of our services.
These packages contain convenient middlewares for transport protocols like HTTP REST and gRPC.
- core/middleware/i18nmw
- core/middleware/metricsmw
- core/middleware/paginationmw
- core/middleware/tracingmw
These packages contain convenient workers things like network servers, background workers and message brokers.
- core/workers/grpcsrv
- core/workers/httpsrv
- core/workers/keybroker
- core/workers/metricsrv
- core/workers/readysrv
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.
- LUSHDigital/core-redis: Packages for connecting to, and working with a Redis store.
- LUSHDigital/core-sql: Packages for connecting to, and working with an SQL database.
- LUSHDigital/core-lush: Packages specific to the LUSH platform.
There are a few tools that can be used with projects that use the core library.
- LUSHDigital/jwtl: A command line tool to help generating JWTs during development.
- LUSHDigital/core-mage: A library for the mage build tool including convenient build targets used in conjunction with a project using this core library.
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
- Zee Philip Vieira: Author
- Ben Cable: Author
- Zach Jones: Code
- Dan P: Code
- Oliver Pauffley: Code
- Cerys Evans: Design