services

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2019 License: MIT Imports: 24 Imported by: 0

README

services

GoDoc

Helpers to initialize services & applications.

Basic usage
import (
  "libs.altipla.consulting/services"
)

Documentation

Overview

Package services helps to initialize services & applications.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dial

func Dial(target Endpoint, opts ...grpc.DialOption) (*grpc.ClientConn, error)

Dial helps to open a connection to a remote GRPC server with tracing support and other goodies configured in this package.

func IsLocal

func IsLocal() bool

IsLocal returns true if we are running inside a local debug environment instead of a production Kubernetes container. It dependes on Version() working correctly.

func ProtoConfigFilename added in v1.8.0

func ProtoConfigFilename(app, filename string) string

ProtoConfigFilename returns the standard location for Altipla config files for the named app.

func Version

func Version() string

Version returns the environment variable VERSION. In development it should be empty. In production it should be set accordingly; it may be for example the container hash.

Types

type AtExitFn added in v1.7.0

type AtExitFn func() error

type Endpoint

type Endpoint string

Endpoint is a simple string with the host and port of the remote GRPC service. We use a custom type to avoid using grpc.Dial without noticing the bug.

This needs a "discovery" package with the full list of remote addresses that use this type instead of string and never using the direct address. That way if you use grpc.Dial it will report the compilation error inmediatly.

type Service

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

Service stores the configuration of the service we are configuring.

func Init

func Init(name string) *Service

Init the configuration of a new service for the current application with the provided name.

func (*Service) AtExit added in v1.7.0

func (service *Service) AtExit(fn AtExitFn)

func (*Service) ConfigureBetaRouting

func (service *Service) ConfigureBetaRouting(username, password string)

ConfigureBetaRouting enables a HTTP router with a simple password for to beta test the real application.

DEPRECATED: Use ConfigureRouting(routing.WithBetaAuth(username, password)) instead.

func (*Service) ConfigureGRPC

func (service *Service) ConfigureGRPC()

ConfigureGRPC enables a GRPC server.

func (*Service) ConfigureProfiler

func (service *Service) ConfigureProfiler()

ConfigureProfiler enables the Stackdriver Profiler agent.

func (*Service) ConfigureRouting

func (service *Service) ConfigureRouting(opts ...routing.ServerOption)

ConfigureRouting enables a HTTP router with the custom options we need. Logrus will be always enabled and Sentry will be configured if a DSN is provided in the ConfigureSentry call.

func (*Service) ConfigureSentry

func (service *Service) ConfigureSentry(dsn string)

ConfigureSentry enables Sentry support in all the features that support it.

func (*Service) ConfigureTracer

func (service *Service) ConfigureTracer(googleProject string)

ConfigureTracer enables the Stackdriver Trace agent.

func (*Service) GRPCServer

func (service *Service) GRPCServer() *grpc.Server

GRPCServer returns the server to register new GRPC services on it.

func (*Service) RoutingServer

func (service *Service) RoutingServer() *routing.Server

RoutingServer returns the server to register new HTTP routes on it.

func (*Service) Run

func (service *Service) Run()

Run starts listening in every configure port needed to provide the configured features.

Jump to

Keyboard shortcuts

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