core

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: BSD-3-Clause Imports: 44 Imported by: 0

Documentation

Overview

Author: Paul Côté Last Change Author: Paul Côté Last Date Changed: 2022/09/20

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Author: Paul Côté Last Change Author: Paul Côté Last Date Changed: 2022/09/20

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Author: Paul Côté Last Change Author: Paul Côté Last Date Changed: 2022/09/20

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

View Source
const (
	ErrGRPCMiddlewareNil    = bg.Error("gRPC middleware uninitialized")
	ErrEmptyPermissionsList = bg.Error("empty permissions list")
	ErrInvalidMacEntity     = bg.Error("invalid macaroon permission entity")
	ErrInvalidMacAction     = bg.Error("invalid macaroon permission action")
	ErrDeprecatedAction     = bg.Error("deprecated rpc command")
)
View Source
const (
	ErrLogLvlNotFound = bg.Error("log level not found")
)
View Source
const (
	ErrShutdown = bg.Error("shutting down")
)

Variables

This section is empty.

Functions

func InitLogger

func InitLogger(config *Config) (zerolog.Logger, error)

InitLogger creates a new instance of the `zerolog.Logger` type. If `console_out` is true, it will output the logs to the console as well as the logfile

func Main

func Main(interceptor *intercept.Interceptor, server *Server) error

Main is the true entry point for Laniakea. It's called in a nested manner for proper defer execution

func MainGrpcServerPermissions

func MainGrpcServerPermissions() map[string][]bakery.Op

MainGrpcServerPermissions returns a map of the command URI and it's associated permissions

func NewSubLogger

func NewSubLogger(l *zerolog.Logger, subsystem string) *subLogger

NewSubLogger takes a `zerolog.Logger` and string for the name of the subsystem and creates a `subLogger` for this subsystem

func StreamingPluginAPIPermission

func StreamingPluginAPIPermission() map[string][]bakery.Op

StreamingPluginAPIPermissions returns a map of the command URI and it's assocaited permissions for the streaming Plugin API methods

Types

type Config

type Config struct {
	DefaultLogDir       bool                    `yaml:"DefaultLogDir"`
	LogFileDir          string                  `yaml:"LogFileDir" long:"logfiledir" description:"Choose the directory where the log file is stored"`
	MaxLogFiles         int64                   `yaml:"MaxLogFiles" long:"maxlogfiles" description:"Maximum number of logfiles in the log rotation (0 for no rotation)"`
	MaxLogFileSize      int64                   `yaml:"MaxLogFileSize" long:"maxlogfilesize" description:"Maximum size of a logfile in MB"`
	ConsoleOutput       bool                    `yaml:"ConsoleOutput" long:"consoleoutput" description:"Whether log information is printed to the console"`
	GrpcPort            int64                   `yaml:"GrpcPort" long:"grpc_port" description:"The port where Laniakea listens for gRPC API requests"`
	RestPort            int64                   `yaml:"RestPort" long:"rest_port" description:"The port where Laniakea listens for REST API requests"`
	ExtraIPAddr         []string                `yaml:"ExtraIPAddr" long:"tlsextraip" description:"Adds an extra ip to the generated certificate"` // optional parameter
	PluginDir           string                  ``                                                                                                 /* 135-byte string literal not displayed */
	Plugins             []*lanirpc.PluginConfig `yaml:"Plugins"`
	RegenerateMacaroons bool                    `long:"regenmacaroons" description:"Boolean to determine whether macaroons are regenerated"`
	MacaroonDBPath      string
	TLSCertPath         string
	TLSKeyPath          string
	AdminMacPath        string
	TestMacPath         string
	WSPingInterval      time.Duration
	WSPongWait          time.Duration
}

Config is the object which will hold all of the config parameters

func InitConfig

func InitConfig(isTesting bool) (Config, error)

InitConfig returns the `Config` struct with either default values or values specified in `config.yaml`

type RpcServer

type RpcServer struct {
	Active int32
	lanirpc.UnimplementedLaniServer

	SubLogger *zerolog.Logger

	Listener net.Listener
	// contains filtered or unexported fields
}

RpcServer is a child of the lanirpc.UnimplementedLaniServer struct. Meant to host all related attributes to the rpcserver

func NewRpcServer

func NewRpcServer(interceptor *intercept.Interceptor, config *Config, log *zerolog.Logger) (*RpcServer, error)

NewRpcServer creates an instance of the GrpcServer struct

func (*RpcServer) AddGrpcInterceptor

func (s *RpcServer) AddGrpcInterceptor(i *intercept.GrpcInterceptor)

AddGrpcInterceptor adds the grpc middleware to the RpcServer

func (*RpcServer) AddMacaroonService

func (s *RpcServer) AddMacaroonService(svc *macaroons.Service)

AddMacaroonService adds the macaroon service to the attributes of the RpcServer

func (*RpcServer) AdminTest

AdminTest will return a string only if the client has the admin macaroon

func (*RpcServer) BakeMacaroon

BakeMacaroon bakes a new macaroon based on input permissions and constraints

func (*RpcServer) InsertROIMarker

func (s *RpcServer) InsertROIMarker(ctx context.Context, _ *proto.Empty) (*proto.Empty, error)

InsertROIMarker is a deprecated Executor API rpc command

func (*RpcServer) LoadTestPlan

func (s *RpcServer) LoadTestPlan(ctx context.Context, _ *proto.Empty) (*proto.Empty, error)

LoadTestPlan is a deprecated Executor API rpc command

func (*RpcServer) Ping

func (s *RpcServer) Ping(ctx context.Context) error

Ping implements the health package RegisteredHealthService interface TODO:SSSOCPaulCote - This should do more, it should actually probe the service to make sure everything is operating nominally

func (*RpcServer) RegisterWithGrpcServer

func (s *RpcServer) RegisterWithGrpcServer(grpcServer *grpc.Server) error

RegisterWithGrpcServer registers the rpcServer with the root gRPC server.

func (*RpcServer) RegisterWithRestProxy

func (s *RpcServer) RegisterWithRestProxy(ctx context.Context, mux *proxy.ServeMux, restDialOpts []grpc.DialOption, restProxyDest string) error

RegisterWithRestProxy registers the RPC Server with the REST proxy

func (*RpcServer) SetPressure

func (s *RpcServer) SetPressure(ctx context.Context, _ *proto.Empty) (*proto.Empty, error)

SetPressure is a deprecated Controller API rpc command

func (*RpcServer) SetTemperature

func (s *RpcServer) SetTemperature(ctx context.Context, _ *proto.Empty) (*proto.Empty, error)

SetTemperature is a deprecated Controller API rpc command

func (*RpcServer) Start

func (s *RpcServer) Start() error

Start starts the RpcServer subserver

func (*RpcServer) StartRecording

func (s *RpcServer) StartRecording(ctx context.Context, _ *proto.Empty) (*proto.Empty, error)

StartRecording is a deprecated DataCollector API rpc command

func (*RpcServer) StartTestPlan

func (s *RpcServer) StartTestPlan(ctx context.Context, _ *proto.Empty) (*proto.Empty, error)

StartTestPlan is a deprecated Executor API rpc command

func (*RpcServer) Stop

func (s *RpcServer) Stop() error

Stop stops the rpc sub-server

func (*RpcServer) StopDaemon

StopDaemon will send a shutdown request to the interrupt handler, triggering a graceful shutdown

func (*RpcServer) StopRecording

func (s *RpcServer) StopRecording(ctx context.Context, _ *proto.Empty) (*proto.Empty, error)

StopRecording is a deprecated DataCollector API rpc command

func (*RpcServer) StopTestPlan

func (s *RpcServer) StopTestPlan(ctx context.Context, _ *proto.Empty) (*proto.Empty, error)

StopTestPlan is a deprecated Executor API rpc command

func (*RpcServer) SubscribeDataStream

func (s *RpcServer) SubscribeDataStream(ctx context.Context, _ *proto.Empty) (*proto.Empty, error)

SubscribeDataStream is a deprecated DataCollector API rpc command

func (*RpcServer) TestCommand

TestCommand will return a string for any macaroon

type Server

type Server struct {
	Active int32 // atomic
	// contains filtered or unexported fields
}

Server is the object representing the state of the server

func InitServer

func InitServer(config *Config, logger *zerolog.Logger) (*Server, error)

InitServer creates a new instance of the server and returns a pointer to it

func (*Server) Start

func (s *Server) Start() error

Start starts the server. Returns an error if any issues occur

func (*Server) Stop

func (s *Server) Stop() error

Stop stops the server. Returns an error if any issues occur

Jump to

Keyboard shortcuts

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