core

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Keystore stores the keys
	Keystore = &keyStore{}
)

Functions

func EnsureOutFolder

func EnsureOutFolder(outFolder string) error

EnsureOutFolder creates a folder if it does not exist

func GetFreePort

func GetFreePort() (port int, err error)

GetFreePort asks the kernel for a free open port that is ready to use.

func GetOutboundIP

func GetOutboundIP() (net.IP, error)

GetOutboundIP returns the IP visible to others

func IsDockerContainer

func IsDockerContainer() bool

IsDockerContainer checks if running in a docker env

func IsFreePort

func IsFreePort(port int) bool

IsFreePort checks if the port can be used

Types

type Bus

type Bus struct {
	Szenario *eventHandler[msg.SzenarioEvtMsg]
	Alert    *eventHandler[msg.AlertMsg]
	Incident *eventHandler[msg.IncidentMsg]
	// contains filtered or unexported fields
}

Bus is the event bus

func (*Bus) Connect

func (e *Bus) Connect() *grav.Pod

Connect to grav and return a pod

func (Bus) EndpointURL

func (e Bus) EndpointURL() string

EndpointURL returns the URL the bus endpoint listens on

func (Bus) GetLogger

func (e Bus) GetLogger() *slog.Logger

GetLogger returns the eventbus logger

func (*Bus) WaitMsgProcessed

func (e *Bus) WaitMsgProcessed()

WaitMsgProcessed waits until the managed cannels have their messages sent

type Core

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

Core is the central structure

func Get

func Get() *Core

Get returns the core instance or panics if not Initialised with New

func New

func New(name string, opts ...Option) (*Core, func())

New creates a new Cores and its cleanup function

func (*Core) Bus

func (c *Core) Bus() *Bus

Bus returns the bus or panics if Core not Initialised with New

func (*Core) Log added in v0.13.0

func (c *Core) Log() *slog.Logger

Log returns the logger or panics if Core not Initialised with New

func (*Core) SzenaioConfig

func (c *Core) SzenaioConfig() *szenario.Config

SzenaioConfig returns the szenario config

func (*Core) WebServer

func (c *Core) WebServer() *WebServer

WebServer returns the webserver

type EventHandler

type EventHandler[M eventer] func(*M)

EventHandler handles events

type Middleware

type Middleware func(http.HandlerFunc) http.HandlerFunc

Middleware func

type Option

type Option func(*Core)

Option configures the core

func BasePath

func BasePath(s string) Option

BasePath sets the root of the webserver path

func BusLogger

func BusLogger(level slog.Level) Option

BusLogger enables and sets the loggin of the bus bus

func Szenario

func Szenario(szCfg *szenario.Config) Option

Szenario sets the szenario config

func WebPort

func WebPort(p int) Option

WebPort sets the port of the webserver

type WebServer

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

WebServer is a wrapper for a webserver

func (*WebServer) AddMiddleware

func (w *WebServer) AddMiddleware(m Middleware)

AddMiddleware adds middleware

func (*WebServer) BasePath

func (w *WebServer) BasePath() string

BasePath is the url path

func (*WebServer) Handle

func (w *WebServer) Handle(pattern string, handler http.Handler)

Handle registers the handler for the given pattern. If a handler already exists for pattern, Handle panics.

func (*WebServer) HandleFunc

func (w *WebServer) HandleFunc(pattern string, handler http.HandlerFunc)

HandleFunc registers the handler function for the given pattern.

func (*WebServer) Start

func (w *WebServer) Start()

Start the webserver

func (*WebServer) Stop

func (w *WebServer) Stop()

Stop the webserver

func (*WebServer) URL

func (w *WebServer) URL() string

URL returns the url the server is listening on

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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