library

package module
v3.6.2 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: LGPL-3.0 Imports: 7 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTimeout = errors.New("timeout")
)

Functions

This section is empty.

Types

type DBType

type DBType int
const (
	Sqlite DBType = iota
	Postgres
)

type Database

type Database struct {
	DB     *sql.DB
	DBType DBType
}

type DefaultListener added in v3.1.0

type DefaultListener <-chan InterServiceMessage

func (DefaultListener) AcceptMessage added in v3.1.0

func (l DefaultListener) AcceptMessage() InterServiceMessage

type InterServiceMessage

type InterServiceMessage struct {
	MessageID    uuid.UUID   `validate:"required"`
	ServiceID    uuid.UUID   `validate:"required"`
	ForServiceID uuid.UUID   `validate:"required"`
	MessageType  MessageCode `validate:"required"`
	SentAt       time.Time   `validate:"required"`
	Message      any         `validate:"required"`
}

func (*InterServiceMessage) Respond added in v3.5.0

func (s *InterServiceMessage) Respond(messageType MessageCode, message any, information *ServiceInitializationInformation)

type Listener added in v3.1.0

type Listener interface {
	AcceptMessage() InterServiceMessage
}

func NewListener added in v3.1.0

func NewListener(c <-chan InterServiceMessage) Listener

type MessageCode added in v3.1.0

type MessageCode int
const (
	Success MessageCode = iota
	BadRequest
	InternalError
	Unauthorized
)

type Permissions

type Permissions struct {
	// Authenticate allows the service to register with the nucleus authentication service and use OAuth2
	Authenticate bool `validate:"required"`
	// Router allows the service to serve web pages
	Router bool `validate:"required"`
	// Database allows the service to ask for a centralised database connection
	Database bool `validate:"required"`
	// BlobStorage allows the service to use the blob storage service
	BlobStorage bool `validate:"required"`
	// InterServiceCommunication allows the service to send and receive messages from other services
	InterServiceCommunication bool `validate:"required"`
	// Resources allows the service to access their resource directory
	Resources bool `validate:"required"`
}

type Service

type Service struct {
	Name        string      `validate:"required"`
	Permissions Permissions `validate:"required"`
	ServiceID   uuid.UUID   `validate:"required"`
}

type ServiceInitializationInformation

type ServiceInitializationInformation struct {
	Service *Service `validate:"required"`
	Domain  *string
	Outbox  chan<- InterServiceMessage `validate:"required"`

	Router        *chi.Mux
	Configuration map[string]interface{}
	ResourceDir   fs.FS
	// contains filtered or unexported fields
}

func NewServiceInitializationInformation added in v3.1.0

func NewServiceInitializationInformation(domain *string, outbox chan<- InterServiceMessage, inbox <-chan InterServiceMessage, router *chi.Mux, configuration map[string]interface{}, resourceDir fs.FS) *ServiceInitializationInformation

NewServiceInitializationInformation creates a new ServiceInitializationInformation and is only ever meant to be called by fulgens or a compliant implementation of fulgens.

func (*ServiceInitializationInformation) AcceptMessage added in v3.4.0

func (*ServiceInitializationInformation) AwaitISMessage added in v3.6.0

func (*ServiceInitializationInformation) GetDatabase added in v3.1.0

func (s *ServiceInitializationInformation) GetDatabase() (Database, error)

func (*ServiceInitializationInformation) SendAndAwaitISMessage

func (s *ServiceInitializationInformation) SendAndAwaitISMessage(forService uuid.UUID, messageType MessageCode, message any, timeout time.Duration) (InterServiceMessage, error)

func (*ServiceInitializationInformation) SendISMessage

func (s *ServiceInitializationInformation) SendISMessage(forService uuid.UUID, messageType MessageCode, message any) uuid.UUID

func (*ServiceInitializationInformation) StartISProcessor added in v3.1.0

func (s *ServiceInitializationInformation) StartISProcessor()

func (*ServiceInitializationInformation) YesIAbsolutelyKnowWhatIAmDoingAndIWantToAccessTheRawInbox added in v3.1.0

func (s *ServiceInitializationInformation) YesIAbsolutelyKnowWhatIAmDoingAndIWantToAccessTheRawInbox() <-chan InterServiceMessage

YesIAbsolutelyKnowWhatIAmDoingAndIWantToAccessTheRawInbox returns a channel that can be used to read messages from the inbox. This is a dangerous operation, can and will break the buffer, and you should most absolutely not use this unless you would like to handle the messages yourself with no outside help or synchronization.

If you think you know what you're doing, **you probably don't**.

Jump to

Keyboard shortcuts

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