serverv2

package module
v2.0.0-...-61da5d1 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Logging flags
	FlagLogLevel   = "log_level"
	FlagLogFormat  = "log_format"
	FlagLogNoColor = "log_no_color"
	FlagTrace      = "trace"

	OutputFormatJSON = "json"
)

Variables

View Source
var ServerContextKey = struct{}{}

Functions

func AddCommands

func AddCommands(rootCmd *cobra.Command, logger log.Logger, homePath string, modules ...ServerModule) error

func NewLogger

func NewLogger(v *viper.Viper, out io.Writer) (log.Logger, error)

NewLogger creates a the default SDK logger. It reads the log level and format from the server context.

func ReadConfig

func ReadConfig(configPath string) (*viper.Viper, error)

Configs returns a viper instance of the config file

Types

type CLIConfig

type CLIConfig struct {
	// Commands defines the main command of a module server.
	Commands []*cobra.Command
	// Queries defines the query commands of a module server.
	// Those commands are meant to be added in the root query command.
	Queries []*cobra.Command
	// Txs defines the tx commands of a module server.
	// Those commands are meant to be added in the root tx command.
	Txs []*cobra.Command
}

CLIConfig defines the CLI configuration for a module server.

func Commands

func Commands(logger log.Logger, homePath string, modules ...ServerModule) (CLIConfig, error)

type Config

type Config struct {
	// StartBlock indicates if the server should block or not.
	// If true, the server will block until the context is canceled.
	StartBlock bool
}

Config is the config of the main server.

type HasCLICommands

type HasCLICommands interface {
	CLICommands() CLIConfig
}

HasCLICommands is a server module that has CLI commands.

type HasConfig

type HasConfig interface {
	Config() any
}

HasConfig is a server module that has a config.

type Server

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

func NewServer

func NewServer(logger log.Logger, modules ...ServerModule) *Server

func (*Server) CLICommands

func (s *Server) CLICommands() CLIConfig

CLICommands returns all CLI commands of all modules.

func (*Server) Configs

func (s *Server) Configs() map[string]any

Configs returns all configs of all server modules.

func (*Server) Name

func (s *Server) Name() string

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start starts all modules concurrently.

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

Stop stops all modules concurrently.

func (*Server) WriteConfig

func (s *Server) WriteConfig(configPath string) error

WriteConfig writes the config to the given path. Note: it does not use viper.WriteConfigAs because we do not want to store flag values in the config.

type ServerModule

type ServerModule interface {
	Name() string

	Start(context.Context) error
	Stop(context.Context) error
}

ServerModule is a server module that can be started and stopped.

Directories

Path Synopsis
api
grpc/gogoreflection
Package gogoreflection implements gRPC reflection for gogoproto consumers the normal reflection library does not work as it points to a different singleton registry.
Package gogoreflection implements gRPC reflection for gogoproto consumers the normal reflection library does not work as it points to a different singleton registry.
appmanager module
stf module
Package abci contains shared data between the host and plugins.
Package abci contains shared data between the host and plugins.

Jump to

Keyboard shortcuts

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