grpc

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SERVER_TYPE is the type of the server.
	SERVER_TYPE = "grpc"
)

Variables

View Source
var (
	// ErrRequiredGRPCRegistrar returned when gRPC registration callback is not provided
	ErrRequiredGRPCRegistrar = errors.New("gRPC registration callback is required")
	// ErrGRPCConfigLoad returned when env config for GRPC results in an error
	ErrGRPCConfigLoad = errors.New("error loading grpc config")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Host string `env:"GRPC_HOST,defaut="`
	Port int    `env:"GRPC_PORT,default=9090"`
	Tags string `env:"GRPC_CONSUL_TAGS,default="`
}

Config manages the HTTP server config

func NewConfig

func NewConfig() *Config

NewConfig returns the parsed config for jetstream from env

func (*Config) Address

func (c *Config) Address() string

Address returns the full formatted http address

func (*Config) GetTags

func (c *Config) GetTags() []string

GetTags return the service registry tags slice

type Grpc

type Grpc struct {
	ServerOptions []grpc.ServerOption
	DialOptions   []grpc.DialOption
	Server        *grpc.Server

	*Config
	// contains filtered or unexported fields
}

Grpc holds gRPC config

func NewGrpc

func NewGrpc(opts ...Option) *Grpc

NewGrpc creates a new gRPC server

func (*Grpc) AddRegistryTags

func (g *Grpc) AddRegistryTags(tags ...string)

AddRegistryTags - sets the registry tags for the server

func (*Grpc) Address

func (g *Grpc) Address() string

Address returns the server address

func (*Grpc) GetMetadata

func (g *Grpc) GetMetadata(key string) interface{}

GetMetadata returns the metadata by key

func (*Grpc) HasInitializer

func (g *Grpc) HasInitializer() bool

func (*Grpc) Host

func (g *Grpc) Host() string

Host returns gRPC server hostname

func (*Grpc) Initializer

func (g *Grpc) Initializer() component.Initializer

func (*Grpc) Port

func (g *Grpc) Port() int

Port returns gRPC server port

func (*Grpc) RegistryTags

func (g *Grpc) RegistryTags() []string

RegistryTags returns gRPC server registry tags

func (*Grpc) String

func (g *Grpc) String() string

String - Returns the type of the server

type Initializer

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

func NewInitializer

func NewInitializer(g *Grpc) *Initializer

NewInitializer returns a new JetStream Initialiazer

func (*Initializer) AddDependency

func (i *Initializer) AddDependency(dep interface{}) error

AddDependency adds necessary service components as dependencies

func (*Initializer) CanRun

func (i *Initializer) CanRun() bool

CanRun returns true if the component has anything to Run

func (*Initializer) CanStop

func (i *Initializer) CanStop() bool

CanRun returns true if the component has anything to Run

func (*Initializer) Dependencies

func (i *Initializer) Dependencies() []string

Dependencies returns the string names of service components that are required as dependencies for this component

func (*Initializer) Run

func (i *Initializer) Run(ctx context.Context) error

Run start the service component

func (*Initializer) Stop

func (i *Initializer) Stop(ctx context.Context) error

Run start the service component

type Option

type Option func(*Grpc)

Option to pass as arg while creating new service

func WithGRPCDialOptions

func WithGRPCDialOptions(opts ...grpc.DialOption) Option

WithGRPCDialOptions overrides custom dial options

func WithGrpcServerOptions

func WithGrpcServerOptions(opts ...grpc.ServerOption) Option

WithGrpcServerOptions adds gRPC options

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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