ms

package module
v0.0.0-...-40701c6 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2019 License: MIT Imports: 21 Imported by: 0

README

ms-lib

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ServerOptionDefault = &ServerOptions{
	CloseTimeoutSeconds: 10,
}

ServerOptionDefault

Functions

func GRPCDial

func GRPCDial(url string, entry *logrus.Entry) (*grpc.ClientConn, error)

GRPCDial is a helper function that creates a grpc.ClientConn with logging and prometheus interecepters

func GetEnv

func GetEnv(envName string, defaultValue string) string

GetEnv return an env value or defaultValue if env value does not exist

Types

type GRPCTransport

type GRPCTransport struct {
	Logger  *log.Entry
	Addr    string
	Server  *grpc.Server
	Closers []io.Closer
}

GRPCTransport properties

func NewGRPCTransport

func NewGRPCTransport(opts *GRPCTransportOptions) (*GRPCTransport, error)

NewGRPCTransport

func (*GRPCTransport) AddCloser

func (t *GRPCTransport) AddCloser(c io.Closer)

AddCloser

func (*GRPCTransport) Close

func (t *GRPCTransport) Close() error

Close

func (*GRPCTransport) GRPCServer

func (t *GRPCTransport) GRPCServer() *grpc.Server

GRPCServer

func (*GRPCTransport) Run

func (t *GRPCTransport) Run() error

Run

type GRPCTransportOptions

type GRPCTransportOptions struct {
	Addr string
}

GRPCTransportOptions hold options for server

type HTTPTransport

type HTTPTransport struct {
	Logger  *log.Entry
	Addr    string
	Handler http.Handler
	Closers []io.Closer
}

HTTPTransport

func NewHTTPTransport

func NewHTTPTransport(opts *HTTPTransportOptions) (*HTTPTransport, error)

NewServer creates a new http transport

func (*HTTPTransport) Add

func (t *HTTPTransport) Add(c io.Closer)

Add

func (*HTTPTransport) Close

func (t *HTTPTransport) Close() error

Close

func (*HTTPTransport) Run

func (t *HTTPTransport) Run() error

Run

type HTTPTransportOptions

type HTTPTransportOptions struct {
	Addr    string
	Handler http.Handler
}

GRPCTransportOptions hold options for server

type Runner

type Runner interface {
	Run() error
}

Runner interface

type Server

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

Server property

func NewServer

func NewServer(opts *ServerOptions) (*Server, error)

NewServer creates a new Server

func (*Server) Add

func (s *Server) Add(runner Runner)

Add a runner

func (*Server) Close

func (s *Server) Close() error

Close manages server and runners shutdown by calling any runners with Close() interface and wait return or timeout.

func (*Server) Run

func (s *Server) Run() error

Run start the server

type ServerOptions

type ServerOptions struct {
	CloseTimeoutSeconds int64
}

ServerOptions hold options for server

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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