serviceutil

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package serviceutil provides service helper functions

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidArgument = errors.New("One ore more request arguments are invalid")

ErrInvalidArgument indicates, that one or more provided arguments are invalid, e.g. required data is missing

Functions

func AsGrpcError

func AsGrpcError(err error, message string, messageArgs ...interface{}) error

AsGrpcError returns a GRPC error, mapping internal errors and returning codes.Internal as default error. The error is logged If the given err is nil AsGrpcError returns nil

func CloseContexts

func CloseContexts()

CloseContexts is deprecated

func GetServiceConnection

func GetServiceConnection(serviceAddress string) (service *grpc.ClientConn, err error)

GetServiceConnection establishes connection to GRPC service at given URL. We are not waiting, til the service is up (no grpc.WithBlock())

func GetServiceConnectionWithDialOptions added in v0.0.4

func GetServiceConnectionWithDialOptions(serviceAddress string, dialOptions ...grpc.DialOption) (service *grpc.ClientConn, err error)

GetServiceConnectionWithDialOptions establishes connection to GRPC service at given URL with given dial options.

Types

type Service

type Service struct {
	Name               string
	GrpcPublishPort    string
	GrpcOptions        []grpc.ServerOption
	RestPort           string
	MetricsPort        string
	WaitGroup          sync.WaitGroup
	Client             interface{}
	NewClientFunc      func(*grpc.ClientConn) interface{}
	RegisterServerFunc func(s *grpc.Server, srv interface{})
	RegisterClientFunc func(ctx context.Context, mux *runtime.ServeMux, client interface{}) error
	Service            interface{}
	ServeHTTP          bool // enables REST endpoints
	SwaggerJsonPath    string
}

Service defines values to start a GRPC (and a REST) service

func (*Service) Start

func (service *Service) Start()

Start runs service with GRPC and REST service endpoints. REST is served if Service.ServeHttp is true (currently fixed on port 8080)

Jump to

Keyboard shortcuts

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