sidecar

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2023 License: MIT Imports: 15 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfFolder added in v0.0.14

func ConfFolder() (confFolder string, err error)

Command line of sidecar : <exe name> --cf <path of config folder> ConfFolder() return the value of 'cf' flag

func ConfigFactory

func ConfigFactory(cfPath string) sputnik.ConfFactory

ConfigFactory returns implementation of sputnik.ConfFactory based on github.com/tkanos/gonfig - JSON format of config files - Automatic matching of environment variables - Env. variable for configuration "example" and key "kname" should be set in environment as "EXAMPLE_KNAME" - Value in environment automatically overrides value from the file - Temporary used github.com/g41797/gonfig (till merge of PR)

func LoadDockerComposeFile added in v0.0.20

func LoadDockerComposeFile(url string) error

Loads docker-compose.yml file to configuration folder with name "docker-compose.yml" for further using by StartServices

func LoadEnv added in v0.0.19

func LoadEnv() error

Loads all *.env file from configuration folder of the process. Overwrites non-existing environment variables. Supports "prefixed" environment variables (https://github.com/g41797/gonfig#using-prefixes-for-environment-variables-name)

func ReadAppBlocks

func ReadAppBlocks(confFolder string) ([]sputnik.BlockDescriptor, error)

func Start

func Start(cntr sputnik.ServerConnector)

func StartServices added in v0.0.17

func StartServices() (stopServices func(), err error)

Starts docker compose on 'docker-compose.yml' from configuration folder Does not wait finish.

func StartServicesWithCompose added in v0.0.17

func StartServicesWithCompose(composePath string) (stopServices func(), err error)

func UseEmbeddedConfiguration added in v0.0.18

func UseEmbeddedConfiguration(efs *embed.FS) (cleanUp func(), err error)

UseEmbeddedConfiguration creates temporary directory and copies configuration files embedded within package. For success returns cleanUp function for removing created directory Use this function in main function if you don't supply path to config directory in command line. Example:

import (

	"embed"
 .......

)

go:embed configdir var cnffiles embed.FS

func main() {
	cleanup, err := sidecar.UseEmbeddedConfiguration(&cnffiles)
	if err != nil {
		return err
	}
	defer cleanup()
	sidecar.Start(new(adapter.BrokerConnector))
}

func WalkDir added in v0.0.19

func WalkDir(root string, exts []string) ([]string, error)

Finds all the files matching a particular suffix in all the directories https://stackoverflow.com/questions/70537979/how-to-efficiently-find-all-the-files-matching-a-particular-suffix-in-all-the-di

Types

type Cleaner added in v0.0.21

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

Emulates stack of cleanup functions

func (*Cleaner) Clean added in v0.0.21

func (c *Cleaner) Clean()

Cleanup in LIFO order

func (*Cleaner) Push added in v0.0.21

func (c *Cleaner) Push(cf func())

Push cleanup function to stack

type Connector added in v0.0.13

type Connector interface {
	// Connect to the broker or attach to existing shared
	Connect(cf sputnik.ConfFactory, shared sputnik.ServerConnection) error

	// For shared connection - detach, for own - close
	Disconnect()
}

Connector provides possibility for negotiation between sputnik based software and external broker process

type MessageConsumer added in v0.0.13

type MessageConsumer interface {
	Connector

	// Receive event from broker, convert to sputnik.Msg
	// and send to another block
	Consume(sender sputnik.BlockCommunicator) error
}

type MessageProducer

type MessageProducer interface {
	Connector

	// Translate message to format of the broker and send it
	Produce(msg sputnik.Msg) error
}

type Runner

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

func StartRunner

func StartRunner(confFolder string, cntr sputnik.ServerConnector) (*Runner, error)

func (*Runner) Start

func (rnr *Runner) Start(ri *runnerInfo) error

func (*Runner) Stop

func (rnr *Runner) Stop()

func (*Runner) Wait

func (rnr *Runner) Wait()

Jump to

Keyboard shortcuts

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