slcontainer

package
v0.1.17 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package slcontainer provides the container for the slave node

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidLoaderID is returned when the loader id is invalid
	ErrInvalidLoaderID = fmt.Errorf("invalid loader id")
	// ErrInvalidAuthID is returned when the auth id is invalid
	ErrInvalidAuthID = fmt.Errorf("invalid auth id")
	// ErrRequestNotFound is returned when the request is not found
	ErrRequestNotFound = fmt.Errorf("request not found")
	// ErrInvalidAuthType is returned when the auth type is invalid
	ErrInvalidAuthType = fmt.Errorf("invalid auth type")
)

Functions

This section is empty.

Types

type Auth

type Auth struct {
	DefaultAuthenticator string
	Container            map[string]*auth.SetAuthor
	// contains filtered or unexported fields
}

Auth is the struct to store auth information

func NewAuth

func NewAuth() *Auth

NewAuth creates a new auth container

func (*Auth) Add

func (a *Auth) Add(id string, auth auth.SetAuthor)

Add adds a new auth to the container

func (Auth) AddFromProto

func (a Auth) AddFromProto(id string, pbAuth *pb.Auth) error

AddFromProto adds a new auth from the proto to the container

func (Auth) Exists

func (a Auth) Exists(id string) bool

Exists checks if the auth exists

func (Auth) Find

func (a Auth) Find(id string) (auth.SetAuthor, bool)

Find finds an auth from the container

func (Auth) GetDefault

func (a Auth) GetDefault() auth.SetAuthor

GetDefault gets the default auth

func (*Auth) Remove

func (a *Auth) Remove(id string)

Remove removes an auth from the container

func (*Auth) SetDefault

func (a *Auth) SetDefault(id string)

SetDefault sets the default auth

type AuthResourceRequest

type AuthResourceRequest struct {
	IsDefault bool
	AuthID    string
}

AuthResourceRequest is the struct to store auth resource request

type CommandMapData

type CommandMapData struct {
	LoaderID         string
	OutputRoot       string
	StrMap           *sync.Map
	ThreadOnlyStrMap *sync.Map
	SlaveValues      map[string]any
}

CommandMapData represents the data for the command map

type Encryption

type Encryption struct {
	// Enabled is the flag to enable encryption
	Enabled bool
	// EncryptID is the encryption id
	EncryptID string
}

Encryption is the struct to store encryption information

type Loader

type Loader struct {
	LoaderBuilderMap map[string]*strings.Builder
	LoaderMap        map[string]string
	// contains filtered or unexported fields
}

Loader represents the loader container for the slave node

func NewLoader

func NewLoader() *Loader

NewLoader creates a new loader container for the slave node

func (*Loader) Build

func (l *Loader) Build(loaderID string)

Build builds the loader container

func (*Loader) GetLoader

func (l *Loader) GetLoader(loaderID string) (string, bool)

GetLoader returns the loader from the container

func (*Loader) WriteString

func (l *Loader) WriteString(loaderID, data string) error

WriteString writes a string to the loader container

type LoaderResourceRequest

type LoaderResourceRequest struct {
	LoaderID string
}

LoaderResourceRequest is a struct that represents a request to the loader resource.

type ReceiveChanelRequestContainer

type ReceiveChanelRequestContainer struct {
	ReqChan chan *pb.ReceiveChanelConnectResponse
	// contains filtered or unexported fields
}

ReceiveChanelRequestContainer is a struct that represents a container for the receive chanel requests

func NewReceiveChanelRequestContainer

func NewReceiveChanelRequestContainer() *ReceiveChanelRequestContainer

NewReceiveChanelRequestContainer creates a new request container

func (*ReceiveChanelRequestContainer) Cast

func (r *ReceiveChanelRequestContainer) Cast(reqID string)

Cast casts a term to the request

func (*ReceiveChanelRequestContainer) SendAuthResourceRequests

func (r *ReceiveChanelRequestContainer) SendAuthResourceRequests(
	ctx context.Context,
	connectionID string,
	mapper *RequestConnectionMapper,
	req AuthResourceRequest,
) <-chan struct{}

SendAuthResourceRequests sets the auth requests channel

func (*ReceiveChanelRequestContainer) SendLoaderResourceRequests

func (r *ReceiveChanelRequestContainer) SendLoaderResourceRequests(
	ctx context.Context,
	connectionID string,
	mapper *RequestConnectionMapper,
	req LoaderResourceRequest,
) <-chan struct{}

SendLoaderResourceRequests sets the loader requests channel

func (*ReceiveChanelRequestContainer) SendStore

func (r *ReceiveChanelRequestContainer) SendStore(
	ctx context.Context,
	connectionID string,
	mapper *RequestConnectionMapper,
	req StoreDataRequest,
) (<-chan struct{}, error)

SendStore send store requests

func (*ReceiveChanelRequestContainer) SendStoreResourceRequests

func (r *ReceiveChanelRequestContainer) SendStoreResourceRequests(
	ctx context.Context,
	connectionID string,
	mapper *RequestConnectionMapper,
	req StoreResourceRequest,
) (<-chan struct{}, error)

SendStoreResourceRequests sets the store requests channel

func (*ReceiveChanelRequestContainer) SendTargetResourceRequests

func (r *ReceiveChanelRequestContainer) SendTargetResourceRequests(
	ctx context.Context,
	connectionID string,
	mapper *RequestConnectionMapper,
	req TargetResourceRequest,
) <-chan struct{}

SendTargetResourceRequests sets the target requests channel

type RequestConnectionMapper

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

RequestConnectionMapper is a struct that represents a request connection mapper

func NewRequestConnectionMapper

func NewRequestConnectionMapper() *RequestConnectionMapper

NewRequestConnectionMapper creates a new request connection mapper

func (*RequestConnectionMapper) DeleteRequest

func (r *RequestConnectionMapper) DeleteRequest(reqID string)

DeleteRequest deletes the request from the mapper

func (*RequestConnectionMapper) DeleteRequestConnection

func (r *RequestConnectionMapper) DeleteRequestConnection(connectionID string)

DeleteRequestConnection deletes the request connection from the mapper

func (*RequestConnectionMapper) GetConnectionID

func (r *RequestConnectionMapper) GetConnectionID(reqID string) (string, bool)

GetConnectionID returns the connection ID for the request

func (*RequestConnectionMapper) GetRequestID

func (r *RequestConnectionMapper) GetRequestID(connectionID string) ([]string, bool)

GetRequestID returns the request ID for the connection

func (*RequestConnectionMapper) RegisterRequestConnection

func (r *RequestConnectionMapper) RegisterRequestConnection(reqID, connectionID string)

RegisterRequestConnection registers a new request connection to the mapper

type RequestTermCaster

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

RequestTermCaster is an interface that represents a request term caster

func NewRequestTermCaster

func NewRequestTermCaster() *RequestTermCaster

NewRequestTermCaster creates a new request term caster

func (*RequestTermCaster) Cast

func (r *RequestTermCaster) Cast(reqID string)

Cast casts a term to the request

func (*RequestTermCaster) RegisterRequest

func (r *RequestTermCaster) RegisterRequest(reqID string) <-chan struct{}

RegisterRequest registers a new request to the caster

type SlaveContainer

type SlaveContainer struct {
	Auth                          *Auth
	Store                         *Store
	Target                        *Target
	Loader                        *Loader
	CommandMap                    *sync.Map
	ReceiveChanelRequestContainer *ReceiveChanelRequestContainer
}

SlaveContainer represents the container for the slave node

func NewSlaveContainer

func NewSlaveContainer() *SlaveContainer

NewSlaveContainer creates a new container for the slave node

func (*SlaveContainer) AddCommandMap

func (s *SlaveContainer) AddCommandMap(cmdID string, data CommandMapData)

AddCommandMap adds a command map to the slave container

func (*SlaveContainer) DeleteCommandMap

func (s *SlaveContainer) DeleteCommandMap(cmdID string)

DeleteCommandMap deletes the command map from the slave container

func (*SlaveContainer) GetCommandMap

func (s *SlaveContainer) GetCommandMap(cmdID string) (CommandMapData, bool)

GetCommandMap returns the command map from the slave container

func (*SlaveContainer) SetSlaveValues

func (s *SlaveContainer) SetSlaveValues(cmdID string, slaveValues map[string]any) error

SetSlaveValues sets the slave values for the command map

func (*SlaveContainer) SetStrMap

func (s *SlaveContainer) SetStrMap(cmdID string, strMap map[string]any) error

SetStrMap sets the str map for the command map

func (*SlaveContainer) SetThreadOnlyStrMap

func (s *SlaveContainer) SetThreadOnlyStrMap(cmdID string, strMap map[string]any) error

SetThreadOnlyStrMap sets the thread only str map for the command map

type Store

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

Store is the interface to store the data

func NewStore

func NewStore() *Store

NewStore creates a new store

func (*Store) AddData

func (s *Store) AddData(bucketID, storeKey string, data []byte) error

AddData adds the data to the store

func (*Store) ExistData

func (s *Store) ExistData(bucketID, storeKey string) bool

ExistData checks if the data exists in the store

func (*Store) GetData

func (s *Store) GetData(bucketID, storeKey string) (any, bool)

GetData gets the data from the store

func (*Store) RemoveData

func (s *Store) RemoveData(bucketID, storeKey string)

RemoveData removes the data from the store

type StoreData

type StoreData struct {
	BucketID   string
	StoreKey   string
	Data       []byte
	Encryption Encryption
}

StoreData is the struct to store the store data

type StoreDataKey

type StoreDataKey struct {
	BucketID string
	StoreKey string
}

StoreDataKey is the struct to store the store data key

type StoreDataRequest

type StoreDataRequest struct {
	StoreData []StoreData
}

StoreDataRequest is the struct to store the store data request

type StoreResourceRequest

type StoreResourceRequest struct {
	Requests []StoreRespectiveRequest
}

StoreResourceRequest is the struct to store the store resource request

type StoreRespectiveRequest

type StoreRespectiveRequest struct {
	BucketID   string
	StoreKey   string
	Encryption Encryption
}

StoreRespectiveRequest is the struct to store the store respective request

type Target

type Target struct {
	target.Container
	// contains filtered or unexported fields
}

Target represents the target container for the slave node

func NewTarget

func NewTarget() *Target

NewTarget creates a new target container for the slave node

func (*Target) Add

func (t *Target) Add(id string, target target.Target)

Add adds a new target to the container

func (Target) AddFromProto

func (t Target) AddFromProto(id string, pbT *pb.Target) error

AddFromProto adds a new target from the proto to the container

func (Target) Exists

func (t Target) Exists(id string) bool

Exists checks if the target exists

func (Target) Find

func (t Target) Find(id string) (target.Target, bool)

Find finds a target from the container

func (*Target) Remove

func (t *Target) Remove(id string)

Remove removes a target from the container

type TargetResourceRequest

type TargetResourceRequest struct {
	TargetID string
}

TargetResourceRequest represents a target resource request

Jump to

Keyboard shortcuts

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