Documentation
¶
Overview ¶
Package core consists of a set of packages which are used in writing micro-service applications.
Each package defines conventional ways of handling common tasks, as well as a suite of tests to verify their behaviour.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Service ¶
type Service struct {
// Name represents the name of the service, typically the same as the github repository.
Name string `json:"service_name"`
// Type represents the type of the service, eg. service or aggregator.
Type string `json:"service_type"`
// Version represents the SVC tagged version of the service.
Version string `json:"service_version"`
}
Service represents the minimal information required to define a working service.
func NewService ¶
func NewService() *Service
NewService reads a service definition from the environment.
func (*Service) StartWorkers ¶
func (s *Service) StartWorkers(ctx context.Context, workers ...ServiceWorker)
StartWorkers will start the given service workers and block block indefinitely.
Example ¶
package main
import (
"context"
"net/http"
"github.com/LUSHDigital/core"
"github.com/LUSHDigital/core/workers/grpcsrv"
"github.com/LUSHDigital/core/workers/httpsrv"
"github.com/LUSHDigital/core/workers/keybroker"
"github.com/LUSHDigital/core/workers/metricsrv"
)
var (
ctx context.Context
handler http.Handler
)
func main() {
svc := core.NewService()
svc.StartWorkers(ctx,
grpcsrv.New(nil),
httpsrv.NewDefault(handler),
metricsrv.New(),
keybroker.NewRSA(nil),
)
}
Directories
¶
| Path | Synopsis |
|---|---|
|
Package auth provides functions for services to issue and sign api consumer tokens.
|
Package auth provides functions for services to issue and sign api consumer tokens. |
|
Package env provides functionality for ensuring we retrieve an environment variable
|
Package env provides functionality for ensuring we retrieve an environment variable |
|
examples
|
|
|
service
command
|
|
|
middleware
|
|
|
metricsmw
Package metricsmw is used to record and expose metrics for an application.
|
Package metricsmw is used to record and expose metrics for an application. |
|
paginationmw
Package paginationmw provides transport middlewares for dealing with pagination.
|
Package paginationmw provides transport middlewares for dealing with pagination. |
|
tracingmw
Package tracingmw allows setting and tracing a request by injecting an id as part of it's headers, when dealing with HTTP, or it's context, when dealing with GRPC.
|
Package tracingmw allows setting and tracing a request by injecting an id as part of it's headers, when dealing with HTTP, or it's context, when dealing with GRPC. |
|
Package pagination defines a paginator able to return formatted responses enabling the API consumer to retrieve data in defined chunks
|
Package pagination defines a paginator able to return formatted responses enabling the API consumer to retrieve data in defined chunks |
|
Package response defines the how the default microservice response must look and behave like.
|
Package response defines the how the default microservice response must look and behave like. |
|
Package test contains helpers for aiding testing.
|
Package test contains helpers for aiding testing. |
|
workers
|
|
|
grpcsrv
Package grpcsrv provides a default set of configuration for hosting a grpc server in a service.
|
Package grpcsrv provides a default set of configuration for hosting a grpc server in a service. |
|
httpsrv
Package httpsrv provides a default set of configuration for hosting a http server in a service.
|
Package httpsrv provides a default set of configuration for hosting a http server in a service. |
|
keybroker
Package keybroker implements a background broker conmtinous retrieval of public keys from multiple different type of sources.
|
Package keybroker implements a background broker conmtinous retrieval of public keys from multiple different type of sources. |
|
keybroker/keybrokermock
Package keybrokermock implements no-op mocks for the keys package
|
Package keybrokermock implements no-op mocks for the keys package |
|
metricsrv
Package metricsrv provides a default set of configuration for hosting http prometheus metrics in a service.
|
Package metricsrv provides a default set of configuration for hosting http prometheus metrics in a service. |
|
readysrv
Package readysrv is used to provide readiness checks for a service.
|
Package readysrv is used to provide readiness checks for a service. |
Click to show internal directories.
Click to hide internal directories.