simple

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: 8 Imported by: 0

Documentation

Index

Constants

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

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:"SERVER_HOST,defaut="`
	Port int    `env:"SERVER_PORT,default=8080"`
	Tags string `env:"SERVER_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 Initializer

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

func NewInitializer

func NewInitializer(s *Simple) *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(*Simple)

Option to pass as arg while creating new service

type Simple

type Simple struct {
	*Config
	// contains filtered or unexported fields
}

Grpc holds gRPC config

func NewSimple

func NewSimple(opts ...Option) *Simple

NewGrpc creates a new gRPC server

func (*Simple) AddRegistryTags

func (s *Simple) AddRegistryTags(tags ...string)

AddRegistryTags - sets the registry tags for the server

func (*Simple) Address

func (s *Simple) Address() string

Address returns the server address

func (*Simple) GetMetadata

func (s *Simple) GetMetadata(key string) interface{}

GetMetadata returns the metadata by key

func (*Simple) HasInitializer

func (s *Simple) HasInitializer() bool

func (*Simple) Host

func (s *Simple) Host() string

Host returns gRPC server hostname

func (*Simple) Initializer

func (s *Simple) Initializer() component.Initializer

func (*Simple) Port

func (s *Simple) Port() int

Port returns gRPC server port

func (*Simple) RegistryTags

func (s *Simple) RegistryTags() []string

RegistryTags returns gRPC server registry tags

func (*Simple) String

func (s *Simple) String() string

String - Returns the type of the server

Jump to

Keyboard shortcuts

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