foundation

package module
v0.0.0-...-e419a8d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

README

Foundation CircleCI

This starter kit is a starting point for building production grade scalable Go service applications. The goal of this Foundation is to provide a proven starting point for new projects that reduce the repetitive tasks in getting a new project launched to production.

This project should not be considered as a "framework". This project leaves you in control of your project’s architecture and development.

How to use

// create a GRPC server from github.com/anthonycorbacho/foundation/grpc import.
srv := grpc.NewServer()
defer srv.Stop()
pb.RegisterXXXXXXServer(srv, &myStruct{})

// Create foundation service with prometheus and jeager exporter.
svc := foundation.NewService(":8100", foundation.Name("service_name"))
svc.WithPrometheusExporter(":8101")
svc.WithJaegerExporter("http://127.0.0.1:14268/api/traces", trace.AlwaysSample())

// start the service.
if err := svc.Serve(srv); err != nil {
	logger.Fatal("failed to serve", log.Error(err))
}

Contributing

We are welcoming any contribution to the project. If you have a use case or pattern you want to include please feel free to open an issue or create a Pull Request.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnnotateError

func AnnotateError(span *trace.Span, err error)

AnnotateError annotates the error to the given span.

Types

type Option

type Option func(*Service)

func Name

func Name(name string) Option

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is a structure that wraps the lower level libraries. Its a convenience method for building and initialising services.

func NewService

func NewService(addr string, opts ...Option) *Service

NewService creates a foundation Service.

func (*Service) Serve

func (s *Service) Serve(grpcsrv *grpc.Server) error

Serve starts foundation Service.

func (*Service) WithJaegerExporter

func (s *Service) WithJaegerExporter(collectorAddr string, sampler trace.Sampler, tags ...jaeger.Tag)

WithJaegerExporter create a new export that will report trace to the given collector endpoint. if collector is empty, the default address will be use (http://127.0.0.1:14268/api/traces). will panic on error

func (*Service) WithPrometheusExporter

func (s *Service) WithPrometheusExporter(addr string)

WithPrometheusExporter creates a new HTTP server that will provide a HTTP endpoint /metrics that will report application metrics. if addr is nil, default binding port will be :9090. will panic if cannot bind http to the addr.

Directories

Path Synopsis
Package log provides a application log that formalize a log format.
Package log provides a application log that formalize a log format.
Package version provides a simple logic that will inject application version at build time.
Package version provides a simple logic that will inject application version at build time.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL