A standard library for microservices.

PACE Bricks Golang CI Coverage Status

Opinionated microservice kit to help developers to build microservices with go.

Opinions

A pace/bricks microservice is:

  • built as a docker container
  • deployed into a kubernetes cluster
    • support for the termination log
  • configured using environment variables (TWELVE-FACTOR APP)
  • monitored using prometheus
  • reports errors to sentry
  • samples traces to jaeger
  • logs to stdout using json deployed kubernetes otherwise human readable
  • offers health endpoints
  • built-in redaction of JWTs and card schemes
  • connects to backend services
    • postgres (logging, metrics, tracing, health)
    • redis (logging, metrics, tracing, health)
    • queue via redis (logging, metrics, tracing, health)
    • http (logging, metrics, tracing, retries)
    • s3 via http (logging, metrics, tracing, health)
    • couchdb via http (logging, metrics, tracing, retries, health)
    • grpc (logging, metrics, tracing, retries)
  • provides two commands control and daemon
  • provides a RESTful API
    • code is generated from the OpenAPIv3 spec
    • authenticated via OAuth2
    • encoded using json:api
    • that supports logging, tracing and metrics
  • optionally provides a GRPC API
    • code is generated from the protoc spec
    • that supports logging, tracing and metrics

Install

go get github.com/pace/bricks/cmd/pb

Usage

pb -h

Contributing

Read our contributors guide.

Requirements

  • A working go installation
  • A working git installation

Testing

  • Use make test to test without dependencies
  • Use docker-compose run testserver make integration to test with dependencies
  • Use make testserver to start a testserver that will be started with dependencies. In order to update the server one need to docker-compose restart testserver

Environment variables for the pb command

Variable Description
PACE_BRICKS_EDITOR   The path to the editor that should be used for opening a project. Defaults to $EDITOR.
PACE_BRICKS_PATH The path where new project should be created. Defaults to $HOME/PACE.
Owner
Comments
  • Add log breadcrumbs to log.handleError()

    Add log breadcrumbs to log.handleError()

    Currently, breadcrumbs are only attached when an http request is aborted with an error or panic. Sometimes we want to use handleError to report a message to sentry without aborting the request.

    Breadcrumbs should be added there as well.

  • #109: Add the Authentication to the generated Api code

    #109: Add the Authentication to the generated Api code

    Adds the Authentication for ApiKey and OAuth2 to the generated ApiKey. This makes it necessary that each Api-Definition contains security schema configurations. But the generated code is still backwards compatible, because it can be used without the usage of the generated Authentication.

  • Panics are caught by the golang http server instead of the Pace error handler

    Panics are caught by the golang http server instead of the Pace error handler

    The pace Router object registers an error handler that normally intercepts panics:

    // HandleRequest should be called with defer to recover panics in request handlers
    func HandleRequest(handlerName string, w http.ResponseWriter, r *http.Request) {
    	if rp := recover(); rp != nil {
    		HandleError(&PanicWrap{rp}, handlerName, w, r)
    	}
    }
    

    But panics are caught instead by the golang http server: http/server.go

    // Serve a new connection.
    func (c *conn) serve(ctx context.Context) {
    	c.remoteAddr = c.rwc.RemoteAddr().String()
    	ctx = context.WithValue(ctx, LocalAddrContextKey, c.rwc.LocalAddr())
    	defer func() {
    		if err := recover(); err != nil && err != ErrAbortHandler {
    			const size = 64 << 10
    			buf := make([]byte, size)
    			buf = buf[:runtime.Stack(buf, false)]
    			c.server.logf("http: panic serving %v: %v\n%s", c.remoteAddr, err, buf)
    		}
    

    Because of this, the recover() function in HandleRequest is always nil.

  • new round tripper package

    new round tripper package

    The old roundtripper package did not preserve the request body on retries. This has been solve by exchanging to another package providing that handling.

  • Update dependencies and moved to github actions

    Update dependencies and moved to github actions

    • remove insecure jwt dependency
    • codahale/hdrhistogram fixes #274
    • update github.com/go-redis/redis/v7
    • update github.com/asaskevich/govalidator
    • travis -> github action
    • update github.com/mattn/goveralls
    • remove coverage from action
    • using github action actions-goveralls
  • grpc: delete utm metadata entry

    grpc: delete utm metadata entry

    Follow convention, but I am not sure why we do this for other entries. The grpc documentation does not indicate any need to do that: https://github.com/grpc/grpc-go/blob/master/Documentation/grpc-metadata.md

  • Fix queue backend metrics that were gathered only once

    Fix queue backend metrics that were gathered only once

    Metrics gathered by the queue backend were not working as expected due to the fact that they were gathered only once on package initialization. Added a ticker to the routine that is responsible with gathering the metrics.

  • add grpc client and server middleware setup code

    add grpc client and server middleware setup code

    Adds a new grpc client and server middleware setup that works together with the rest of pace bricks.

    • adds testserver for testing and demonstration
    • fixes golint to use vendored version (prevents crashes)
    • updates readme
  • Introduce dedicated and secondary client for couchdb backend health checks

    Introduce dedicated and secondary client for couchdb backend health checks

    Motivation

    Using long-polling/streaming features with couchdb somehow causes the healthcheck calls to be blocked.

    Idea

    Change https://github.com/pace/bricks/blob/master/backend/couchdb/health_check.go to use a second client dedicated to just performing health checks.

  • log proper failover state on error

    log proper failover state on error

    During active/passive failover, if setting the label of the pod fails, the logged message always contains the state undefined and not the actual state it tried to set.

  • `brickserrors.Handle` needs a check for context cancellation

    `brickserrors.Handle` needs a check for context cancellation

    brickserrors.Handle needs a check for context cancellation and if the context is canceled there needs to be a new context to continue.

    https://github.com/pace/bricks/blob/74a4ee5afd9a836fe22d734fc8b647acd20480cf/maintenance/errors/error.go#L118

HTTP load testing tool and library. It's over 9000!
HTTP load testing tool and library. It's over 9000!

Vegeta Vegeta is a versatile HTTP load testing tool built out of a need to drill HTTP services with a constant request rate. It can be used both as a

Dec 30, 2022
Go library to create resilient feedback loop/control controllers.

Gontroller A Go library to create feedback loop/control controllers, or in other words... a Go library to create controllers without Kubernetes resour

Jan 1, 2023
Orchestra is a library to manage long running go processes.

Orchestra Orchestra is a library to manage long running go processes. At the heart of the library is an interface called Player // Player is a long ru

Oct 21, 2022
Testcontainers is a Golang library that providing a friendly API to run Docker container. It is designed to create runtime environment to use during your automatic tests.

When I was working on a Zipkin PR I discovered a nice Java library called Testcontainers. It provides an easy and clean API over the go docker sdk to

Jan 7, 2023
Automated configuration documentation library for Go Projects.

Cato Cato is an automated documentation generation library for Go Projects. Through the use of custom tags for struct fields, Cato can extract informa

Aug 28, 2020
Gohalt 👮‍♀🛑: Fast; Simple; Powerful; Go Throttler library
Gohalt 👮‍♀🛑: Fast; Simple; Powerful; Go Throttler library

Gohalt ??‍♀ ?? : Fast; Simple; Powerful; Go Throttler library go get -u github.com/1pkg/gohalt Introduction Gohalt is simple and convenient yet powerf

Nov 27, 2022
A K8s ClusterIP HTTP monitoring library based on eBPF

Owlk8s Seamless RED monitoring of k8s ClusterIP HTTP services. This library provides RED (rate,error,duration) monitoring for all(by default but exclu

Jun 16, 2022
library to make building things with bitclout easy

cloutcli library to make building things with bitclout easy quick start demo cmd $ ./clout demo clout demo visualizegraph # make clout.gv graph fi

Jul 27, 2022
A Go library for the Linux Landlock sandboxing feature

Go landlock library The Go landlock library provides an interface to Linux 5.13's Landlock kernel sandboxing features. The library provides access to

Dec 27, 2022
A simple and flexible health check library for Go.

Health A simple and flexible health check library for Go. Documentation · Report Bug · Request Feature Table of Contents Getting started Synchronous v

Jan 4, 2023
The DGL Operator makes it easy to run Deep Graph Library (DGL) graph neural network training on Kubernetes

DGL Operator The DGL Operator makes it easy to run Deep Graph Library (DGL) graph neural network distributed or non-distributed training on Kubernetes

Dec 19, 2022
The k8s-generic-webhook is a library to simplify the implementation of webhooks for arbitrary customer resources (CR) in the operator-sdk or controller-runtime.

k8s-generic-webhook The k8s-generic-webhook is a library to simplify the implementation of webhooks for arbitrary customer resources (CR) in the opera

Nov 24, 2022
ghcr images - Fetched from docker-library

ghcri ghcri is the repo for Github Container Registry Images. Just like docker-library for Docker Registry. Usage Replace all docker library from dock

Aug 15, 2022
Go library providing algorithms optimized to leverage the characteristics of modern CPUs

asm Go library providing algorithms optimized to leverage the characteristics of modern CPUs. Motivation With the development of Cloud technologies, a

Dec 29, 2022
runtime - an abstraction library on top of the Open Policy Agent (OPA)

runtime - an abstraction library on top of the Open Policy Agent (OPA) Introduction The "runtime" project is a library that sits on top of OPA. The go

Nov 7, 2022
AwGo — A Go library for Alfred workflows
 AwGo — A Go library for Alfred workflows

AwGo — A Go library for Alfred workflows Full-featured library to build lightning-fast workflows in a jiffy. Features Installation & usage Documentati

Dec 30, 2022
Go client library for Atlassian Jira
Go client library for Atlassian Jira

Go client library for Atlassian Jira

Jan 3, 2023
Export Prometheus metrics from journald events using Prometheus Go client library

journald parser and Prometheus exporter Export Prometheus metrics from journald events using Prometheus Go client library. For demonstration purposes,

Jan 3, 2022
A Golang library for testing infrastructure in automated ways.

Infratest Infratest is a Golang library that we hope makes testing your infrastructure using tests that are written in Golang easier to do. The genera

Nov 2, 2022