interfaces

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package interfaces defines the IEnvironment interface for managing environment variables and system information.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContactForm

type ContactForm struct {
	Token                string `json:"token"`
	Name                 string `json:"name"`
	Email                string `json:"email"`
	Message              string `json:"message"`
	IMapper[ContactForm] `json:"-" yaml:"-" xml:"-" toml:"-" gorm:"-"`
}

type IBitstate

type IBitstate[T ~uint64] interface {
	Set(flag T)
	Clear(flag T)
	Has(flag T) bool
	WaitFor(flag T)
}

type IChannelBase

type IChannelBase[T any] interface {
	IMutexes

	GetName() string                 // The name of the channel.
	GetChannel() (any, reflect.Type) // The channel for the value. Main channel for this struct.
	GetType() reflect.Type           // The type of the channel.
	GetBuffers() int                 // The number of buffers for the channel.

	SetName(name string) string       // Set the name of the channel.
	SetChannel(reflect.Type, int) any // The channel for the value. Main channel for this struct.
	SetBuffers(buffers int) int       // The number of buffers for the channel.

	Close() error // Close the channel.
	Clear() error // Clear the channel.
}

type IChannelCtl

type IChannelCtl[T any] interface {
	IMutexes

	GetID() uuid.UUID
	GetName() string
	SetName(name string) string

	GetProperty() IProperty[T]

	GetSubChannels() map[string]interface{}
	SetSubChannels(channels map[string]interface{}) map[string]interface{}

	GetSubChannelByName(name string) (any, reflect.Type, bool)
	SetSubChannelByName(name string, channel any) (any, error)

	GetSubChannelTypeByName(name string) (reflect.Type, bool)

	GetSubChannelBuffersByName(name string) (int, bool)
	SetSubChannelBuffersByName(name string, buffers int) (int, error)

	GetMainChannel() any
	SetMainChannel(channel chan T) chan T
	GetMainChannelType() reflect.Type

	GetHasMetrics() bool
	SetHasMetrics(hasMetrics bool) bool
	GetBufferSize() int
	SetBufferSize(size int) int

	Close() error

	WithProperty(property IProperty[T]) IChannelCtl[T]
	WithChannel(channel chan T) IChannelCtl[T]
	WithBufferSize(size int) IChannelCtl[T]
	WithMetrics(metrics bool) IChannelCtl[T]
}

type IEnvironment

type IEnvironment interface {
	Mu() IMutexes
	CPUCount() int
	MemTotal() int
	Hostname() string
	Os() string
	Kernel() string
	LoadEnvFile(watchFunc func(ctx context.Context, chanCbArg chan any) <-chan any) error
	GetEnvFilePath() string
	Getenv(key string) string
	GetenvOrDefault(key string, defaultValue any) (IPropertyValBase[any], reflect.Kind)
	Setenv(key, value string) error
	GetEnvCache() map[string]string
	ParseEnvVar(s string) (string, string)
	LoadEnvFromShell() error
	MemAvailable() int
	GetShellName(s string) (string, int)
	BackupEnvFile() error
	EncryptEnvFile() error
	DecryptEnvFile() (string, error)
	EncryptEnv(value string) (string, error)
	DecryptEnv(encryptedValue string) (string, error)
	IsEncrypted(envFile string) bool
	IsEncryptedValue(value string) bool
	EnableEnvFileEncryption() error
	DisableEnvFileEncryption() error
}

type IGoBE

type IGoBE interface {
	GetReference() IReference
	Environment() IEnvironment
	InitializeResources() error
	InitializeServer() (IRouter, error)
	GetLogger() l.Logger
	StartGoBE()
	StopGoBE()
	GetChanCtl() chan string
	GetLogFilePath() string
	GetConfigFilePath() string
	SetDatabaseService(dbService gdbf.DBService)
	GetDatabaseService() gdbf.DBService
	LogsGoBE() (*io.OffsetWriter, error)
}

type IGoBEConfig

type IGoBEConfig interface {
	GetFilePath() string
	GetWorkerThreads() int
	GetRateLimitLimit() int
	GetRateLimitBurst() int
	GetRequestWindow() time.Duration
	GetProxyEnabled() bool
	GetProxyHost() string
	GetProxyPort() string
	GetBindAddress() string
	GetPort() string
	GetTimeouts() time.Duration
	GetMaxConnections() int
	GetLogLevel() string
	GetLogFormat() string
	GetLogDir() string
	GetRequestLogging() bool
	GetMetricsEnabled() bool
	GetJWTSecretKey() string
	GetRefreshTokenExpiration() time.Duration
	GetAccessTokenExpiration() time.Duration
	GetTLSConfig() ITLSConfig
	GetAllowedOrigins() []string
	GetAPIKeyAuth() bool
	GetAPIKey() string
	GetConfigFormat() string
	GetMapper() IMapper[IGoBEConfig]
	SetFilePath(string)
	SetWorkerThreads(int)
	SetRateLimitLimit(int)
	SetRateLimitBurst(int)
	SetRequestWindow(time.Duration)
	SetProxyEnabled(bool)
	SetProxyHost(string)
	SetProxyPort(string)
	SetBindAddress(string)
	SetPort(string)
	SetTimeouts(time.Duration)
	SetMaxConnections(int)
	SetLogLevel(string)
	SetLogFormat(string)
	SetLogFile(string)
	SetRequestLogging(bool)
	SetMetricsEnabled(bool)
	SetJWTSecretKey(string)
	SetRefreshTokenExpiration(time.Duration)
	SetAccessTokenExpiration(time.Duration)
	SetTLSConfig(ITLSConfig)
	SetAllowedOrigins([]string)
	SetAPIKeyAuth(bool)
	SetAPIKey(string)
	SetConfigFormat(string)
	SetMapper(IMapper[IGoBEConfig])
	Save() error
	Load() error
}

type IMapper

type IMapper[T any] interface {
	// SerializeToFile serializes an object of type T to a file in the specified format.
	SerializeToFile(format string)
	// DeserializeFromFile deserializes an object of type T from a file in the specified format.
	DeserializeFromFile(format string) (*T, error)
	// Serialize converts an object of type T to a byte array in the specified format.
	Serialize(format string) ([]byte, error)
	// Deserialize converts a byte array in the specified format to an object of type T.
	Deserialize(data []byte, format string) (*T, error)
}

IMapper is a generic interface for serializing and deserializing objects of type T.

type IMutexes

type IMutexes interface {
	MuLock()
	MuUnlock()
	MuRLock()
	MuRUnlock()
	MuTryLock() bool
	MuTryRLock() bool

	MuWaitCond()
	MuSignalCond()
	MuBroadcastCond()

	GetMuSharedCtx() any
	SetMuSharedCtx(ctx any)
	GetMuSharedCtxValidate() func(any) (bool, error)
	SetMuSharedCtxValidate(validate func(any) (bool, error))
	MuWaitCondWithTimeout(timeout time.Duration) bool

	MuAdd(delta int)
	MuDone()
	MuWait()
}

type IProperty

type IProperty[T any] interface {
	GetName() string
	GetValue() T
	SetValue(v *T)
	GetReference() (uuid.UUID, string)
	Prop() IPropertyValBase[T]
	GetLogger() l.Logger
	Serialize(format, filePath string) ([]byte, error)
	Deserialize(data []byte, format, filePath string) error
	SaveToFile(filePath string, format string) error
	LoadFromFile(filename, format string) error
}

IProperty is an interface that defines the methods for a property.

type IPropertyValBase

type IPropertyValBase[T any] interface {
	GetLogger() l.Logger
	GetID() uuid.UUID
	GetName() string
	Value() *T
	StartCtl() <-chan string
	Type() reflect.Type
	Get(async bool) any
	Set(t *T) bool
	Clear() bool
	IsNil() bool
	Serialize(format, filePath string) ([]byte, error)
	Deserialize(data []byte, format, filePath string) error
}

IPropertyValBase is an interface that defines the methods for a property value.

type IReference

type IReference interface {
	GetID() uuid.UUID
	GetName() string
	SetName(name string)
	String() string
}

type IRequestsTracer

type IRequestsTracer interface {
	GetIP() string
	GetPort() string
	GetLastUserAgent() string
	GetUserAgents() []string
	GetEndpoint() string
	GetMethod() string
	GetTimeList() []time.Time
	GetCount() int
	GetError() error
	GetMutexes() IMutexes
	IsValid() bool
	GetOldFilePath() string

	GetFilePath() string
	SetFilePath(filePath string)
	GetMapper() IMapper[IRequestsTracer]
	SetMapper(mapper IMapper[IRequestsTracer])
	GetRequestWindow() time.Duration
	SetRequestWindow(window time.Duration)
	GetRequestLimit() int
	SetRequestLimit(limit int)
	Mu() IMutexes
}

type IRoute

type IRoute interface {
	Method() string
	Path() string
	ContentType() string
	RateLimitLimit() int
	RequestWindow() time.Duration
	Secure() bool
	ValidateAndSanitize() bool
	SecureProperties() map[string]bool
	Handler() gin.HandlerFunc
	Middlewares() map[string]gin.HandlerFunc
	DBConfig() gdbf.DBConfig
}

type IRouter

type IRouter interface {
	GetDebug() bool
	GetLogger() l.Logger
	GetConfigPath() string
	GetBindingAddress() string
	GetPort() string
	GetBasePath() string
	GetEngine() *gin.Engine
	GetDatabaseService() gdbf.DBService
	HandleFunc(path string, handler gin.HandlerFunc) gin.IRoutes
	DBConfig() gdbf.IDBConfig
	Start() error
	Stop() error
	SetProperty(key string, value any)
	GetProperty(key string) any
	GetProperties() map[string]any
	SetProperties(properties map[string]any)
	GetRoutes() map[string]map[string]IRoute
	GetMiddlewares() map[string]gin.HandlerFunc
	RegisterMiddleware(name string, middleware gin.HandlerFunc, global bool)
	RegisterRoute(groupName, routeName string, route IRoute, middlewares []string)
	StartServer()
	ShutdownServerGracefully()
	MonitorServer()
	ValidateRouter() error
	DummyHandler(_ chan interface{}) gin.HandlerFunc
}

type ISignalManager

type ISignalManager[T chan string] interface {
	ListenForSignals() (<-chan string, error)
	StopListening()
}

type ITLSConfig

type ITLSConfig interface {
	GetCertFile() string
	GetKeyFile() string
	GetCAFile() string
	GetEnabled() bool
	GetSkipVerify() bool
	GetStrictHostKey() bool
	GetMinVersion() string
	SetCertFile(string)
	SetKeyFile(string)
	SetCAFile(string)
	SetEnabled(bool)
	SetSkipVerify(bool)
	SetStrictHostKey(bool)
	SetMinVersion(string)
	GetTLSConfig() ITLSConfig
	SetTLSConfig(ITLSConfig)
	GetReference() IReference
	GetMutexes() IMutexes
	SetReference(IReference)
	SetMutexes(IMutexes)
	Save() error
	Load() error
}

type IValidation

type IValidation[T any] interface {
	CheckIfWillValidate() bool
	Validate(value *T, args ...any) IValidationResult
	AddValidator(validator IValidationFunc[T]) error
	RemoveValidator(priority int) error
	GetValidator(priority int) (any, error)
	GetValidators() map[int]IValidationFunc[T]
	GetResults() map[int]IValidationResult
	ClearResults()
	IsValid() bool
}

type IValidationFunc

type IValidationFunc[T any] interface {
	GetPriority() int
	SetPriority(priority int)
	GetFunction() func(value *T, args ...any) IValidationResult
	SetFunction(function func(value *T, args ...any) IValidationResult)
	GetResult() IValidationResult
	SetResult(result IValidationResult)
}

type IValidationResult

type IValidationResult interface {
	String() string
	GetID() uuid.UUID
	GetName() string
	GetIsValid() bool
	GetMessage() string
	GetError() error
	GetMetadata(key string) (any, bool)
	SetMetadata(key string, value any)
	GetAllMetadataKeys() []string
}

Jump to

Keyboard shortcuts

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