types

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: 36 Imported by: 0

Documentation

Overview

Package types contém definições de tipos e estruturas para o wrapper de API

Package types provides the base types for channels in the gobe package.

Package types provides types and methods for managing environment variables,

Index

Constants

View Source
const RequestLimit = 5
View Source
const RequestWindow = 60 * time.Second

Variables

This section is empty.

Functions

func AutoDecode

func AutoDecode[T any](data []byte, target *T, format string) error

func AutoEncode

func AutoEncode[T any](v T, format, filePath string) ([]byte, error)

func IsAlphaNum

func IsAlphaNum(c uint8) bool

func IsEqual

func IsEqual(a, b string) bool

func IsShellSpecialVar

func IsShellSpecialVar(c uint8) bool

func LoadRequestsTracerFromFile

func LoadRequestsTracerFromFile(g ci.IGoBE) (map[string]ci.IRequestsTracer, error)

func NewChannelBase

func NewChannelBase[T any](name string, buffers int, logger l.Logger) ci.IChannelBase[any]

NewChannelBase creates a new ChannelBase instance with the provided name and type.

func NewChannelCtl

func NewChannelCtl[T any](name string, logger l.Logger) ci.IChannelCtl[T]

NewChannelCtl creates a new ChannelCtl instance with the provided name.

func NewChannelCtlWithProperty

func NewChannelCtlWithProperty[T any, P ci.IProperty[T]](name string, buffers *int, property P, withMetrics bool, logger l.Logger) ci.IChannelCtl[T]

NewChannelCtlWithProperty creates a new ChannelCtl instance with the provided name and type.

func NewEnvironment

func NewEnvironment(envFile string, isConfidential bool, logger l.Logger) (ci.IEnvironment, error)

func NewMapper

func NewMapper[T any](object *T, filePath string) ci.IMapper[T]

NewMapper creates a new instance of Mapper.

func NewProperty

func NewProperty[T any](name string, v *T, withMetrics bool, cb func(any) (bool, error)) ci.IProperty[T]

NewProperty creates a new IProperty[T] with the given value and Reference.

func NewRequestsTracer

func NewRequestsTracer(g ci.IGoBE, ip, port, endpoint, method, userAgent, filePath string) ci.IRequestsTracer

func NewRequestsTracerType

func NewRequestsTracerType(g ci.IGoBE, ip, port, endpoint, method, userAgent, filePath string) ci.IRequestsTracer

func NewSignalManager

func NewSignalManager[T chan string](channelCtl chan string, logger l.Logger) ci.ISignalManager[T]

NewSignalManager creates a new SignalManager instance.

func NewTLSConfig

func NewTLSConfig(name, filePath string) ci.ITLSConfig

NewTLSConfig creates a new TLSConfig instance with the provided name and file path.

func NewVal

func NewVal[T any](name string, v *T) ci.IPropertyValBase[T]

func NewValidation

func NewValidation[T any]() ci.IValidation[T]

func NewValidationFunc

func NewValidationFunc[T any](priority int, f func(value *T, args ...any) ci.IValidationResult) ci.IValidationFunc[T]

func NewValidationResult

func NewValidationResult(isValid bool, message string, metadata map[string]any, err error) ci.IValidationResult

func SanitizeQuotesAndSpaces

func SanitizeQuotesAndSpaces(input string) string

func VldtFunc

func VldtFunc[T any](v ci.IValidation[T]) func(value *T, args ...any) ci.IValidationResult

Types

type APIRequest

type APIRequest struct{}

APIRequest (futuro espaço para lógica extra)

func NewAPIRequest

func NewAPIRequest() *APIRequest

type APIResponse

type APIResponse struct {
	Status string                 `json:"status"`
	Hash   string                 `json:"hash,omitempty"`
	Msg    string                 `json:"msg,omitempty"`
	Filter map[string]interface{} `json:"filter,omitempty"`
	Data   interface{}            `json:"data,omitempty"`
}

APIResponse encapsulando respostas

func NewAPIResponse

func NewAPIResponse() *APIResponse

type APIWrapper

type APIWrapper[T any] struct{}

APIWrapper para gerenciar requisições e respostas de maneira padronizada

func NewAPIWrapper

func NewAPIWrapper[T any]() *APIWrapper[T]

func (*APIWrapper[T]) GetContext

func (w *APIWrapper[T]) GetContext(c *gin.Context) (context.Context, error)

func (*APIWrapper[T]) HandleRequest

func (w *APIWrapper[T]) HandleRequest(c *gin.Context, method string, endpoint string, payload interface{})

func (*APIWrapper[T]) JSONResponse

func (w *APIWrapper[T]) JSONResponse(c *gin.Context, status string, msg, hash string, data interface{}, filter map[string]interface{}, httpStatus int)

func (*APIWrapper[T]) JSONResponseWithError

func (w *APIWrapper[T]) JSONResponseWithError(c *gin.Context, err error)

JSONResponseWithError sends a JSON response to the client with an error message.

func (*APIWrapper[T]) JSONResponseWithSuccess

func (w *APIWrapper[T]) JSONResponseWithSuccess(c *gin.Context, msgKey, hash string, data interface{})

JSONResponseWithSuccess sends a JSON response to the client with a success message.

func (*APIWrapper[T]) Middleware

func (w *APIWrapper[T]) Middleware() gin.HandlerFunc

Middleware para interceptar e padronizar respostas

type ChannelBase

type ChannelBase[T any] struct {
	l.Logger              // Logger for this ChannelBase instance
	*Mutexes              // Mutexes for this Channel instance
	Name     string       // The name of the channel.
	Channel  any          // The channel for the value. Main channel for this struct.
	Type     reflect.Type // The type of the channel.
	Buffers  int          // The number of buffers for the channel.
	Shared   interface{}  // Shared data for many purposes
}

ChannelBase is a struct that holds the base properties for a channel.

func (*ChannelBase[T]) Clear

func (cb *ChannelBase[T]) Clear() error

Clear clears the channel and returns an error if any.

func (*ChannelBase[T]) Close

func (cb *ChannelBase[T]) Close() error

Close closes the channel and returns an error if any.

func (*ChannelBase[T]) GetBuffers

func (cb *ChannelBase[T]) GetBuffers() int

GetBuffers returns the number of buffers for the channel.

func (*ChannelBase[T]) GetChannel

func (cb *ChannelBase[T]) GetChannel() (any, reflect.Type)

GetChannel returns the channel and its type.

func (*ChannelBase[T]) GetName

func (cb *ChannelBase[T]) GetName() string

GetName returns the name of the channel.

func (*ChannelBase[T]) GetType

func (cb *ChannelBase[T]) GetType() reflect.Type

GetType returns the type of the channel.

func (*ChannelBase[T]) SetBuffers

func (cb *ChannelBase[T]) SetBuffers(buffers int) int

SetBuffers sets the number of buffers for the channel and returns it.

func (*ChannelBase[T]) SetChannel

func (cb *ChannelBase[T]) SetChannel(typE reflect.Type, bufferSize int) any

SetChannel sets the channel and returns it.

func (*ChannelBase[T]) SetName

func (cb *ChannelBase[T]) SetName(name string) string

SetName sets the name of the channel and returns it.

type ChannelCtl

type ChannelCtl[T any] struct {

	// Logger is the Logger instance for this Channel instance.
	Logger l.Logger // Logger for this Channel instance

	// IMutexes is the interface for the mutexes in this Channel instance.
	*Mutexes // Mutexes for this Channel instance

	// Shared is a shared data used for many purposes like sync.Cond, Telemetry, Monitor, etc.
	Shared interface{} // Shared data for many purposes

	// Reference is the reference ID and name.
	*Reference `json:"reference" yaml:"reference" xml:"reference" gorm:"reference"`

	// buffers is the number of buffers for the channel.
	Buffers int `json:"buffers" yaml:"buffers" xml:"buffers" gorm:"buffers"`

	Channels map[string]any `json:"channels,omitempty" yaml:"channels,omitempty" xml:"channels,omitempty" gorm:"channels,omitempty"`
	// contains filtered or unexported fields
}

ChannelCtl is a struct that holds the properties for a channel control.

func (*ChannelCtl[T]) Close

func (cCtl *ChannelCtl[T]) Close() error

Close closes the channel control and returns an error if any.

func (*ChannelCtl[T]) GetBufferSize

func (cCtl *ChannelCtl[T]) GetBufferSize() int

GetBufferSize returns the buffer size of the channel control.

func (*ChannelCtl[T]) GetHasMetrics

func (cCtl *ChannelCtl[T]) GetHasMetrics() bool

GetHasMetrics returns true if the channel control has metrics enabled.

func (*ChannelCtl[T]) GetID

func (cCtl *ChannelCtl[T]) GetID() uuid.UUID

GetID returns the ID of the channel control.

func (*ChannelCtl[T]) GetMainChannel

func (cCtl *ChannelCtl[T]) GetMainChannel() any

GetMainChannel returns the main channel and its type.

func (*ChannelCtl[T]) GetMainChannelType

func (cCtl *ChannelCtl[T]) GetMainChannelType() reflect.Type

GetMainChannelType returns the type of the main channel.

func (*ChannelCtl[T]) GetName

func (cCtl *ChannelCtl[T]) GetName() string

GetName returns the name of the channel control.

func (*ChannelCtl[T]) GetProperty

func (cCtl *ChannelCtl[T]) GetProperty() ci.IProperty[T]

GetProperty returns the property of the channel control.

func (*ChannelCtl[T]) GetSubChannelBuffersByName

func (cCtl *ChannelCtl[T]) GetSubChannelBuffersByName(name string) (int, bool)

func (*ChannelCtl[T]) GetSubChannelByName

func (cCtl *ChannelCtl[T]) GetSubChannelByName(name string) (any, reflect.Type, bool)

GetSubChannelByName returns the sub-channel by name and its type.

func (*ChannelCtl[T]) GetSubChannelTypeByName

func (cCtl *ChannelCtl[T]) GetSubChannelTypeByName(name string) (reflect.Type, bool)

GetSubChannelTypeByName returns the type of the sub-channel by name.

func (*ChannelCtl[T]) GetSubChannels

func (cCtl *ChannelCtl[T]) GetSubChannels() map[string]interface{}

GetSubChannels returns the sub-channels of the channel control.

func (*ChannelCtl[T]) SetBufferSize

func (cCtl *ChannelCtl[T]) SetBufferSize(size int) int

SetBufferSize sets the buffer size of the channel control and returns it.

func (*ChannelCtl[T]) SetHasMetrics

func (cCtl *ChannelCtl[T]) SetHasMetrics(hasMetrics bool) bool

SetHasMetrics sets the hasMetrics flag and returns it.

func (*ChannelCtl[T]) SetMainChannel

func (cCtl *ChannelCtl[T]) SetMainChannel(channel chan T) chan T

SetMainChannel sets the main channel and returns it.

func (*ChannelCtl[T]) SetName

func (cCtl *ChannelCtl[T]) SetName(name string) string

SetName sets the name of the channel control and returns it.

func (*ChannelCtl[T]) SetSubChannelBuffersByName

func (cCtl *ChannelCtl[T]) SetSubChannelBuffersByName(name string, buffers int) (int, error)

SetSubChannelBuffersByName sets the number of buffers for the sub-channel by name and returns the number of buffers.

func (*ChannelCtl[T]) SetSubChannelByName

func (cCtl *ChannelCtl[T]) SetSubChannelByName(name string, channel any) (any, error)

SetSubChannelByName sets the sub-channel by name and returns the channel.

func (*ChannelCtl[T]) SetSubChannels

func (cCtl *ChannelCtl[T]) SetSubChannels(channels map[string]interface{}) map[string]interface{}

SetSubChannels sets the sub-channels of the channel control and returns the updated map.

func (*ChannelCtl[T]) WithBufferSize

func (cCtl *ChannelCtl[T]) WithBufferSize(size int) ci.IChannelCtl[T]

WithBufferSize sets the buffer size for the channel control and returns it.

func (*ChannelCtl[T]) WithChannel

func (cCtl *ChannelCtl[T]) WithChannel(channel chan T) ci.IChannelCtl[T]

WithChannel sets the channel for the channel control and returns it.

func (*ChannelCtl[T]) WithMetrics

func (cCtl *ChannelCtl[T]) WithMetrics(metrics bool) ci.IChannelCtl[T]

WithMetrics sets the metrics flag for the channel control and returns it.

func (*ChannelCtl[T]) WithProperty

func (cCtl *ChannelCtl[T]) WithProperty(property ci.IProperty[T]) ci.IChannelCtl[T]

WithProperty sets the property for the channel control and returns it.

type ContactForm

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

type CtxKey

type CtxKey string

type DataExporter

type DataExporter interface {
	ExportFromYAML(filename string) error
	ExportFromJSON(filename string) error
	ExportFromXML(filename string) error
	ExportFromTOML(filename string) error
	ExportFromENV(filename string) error
	ExportFromINI(filename string) error
	ExportFromCSV(filename string) error
	ExportFromProperties(filename string) error
	ExportFromText(filename string) error
	ExportFromASN(filename string) error
	ExportFromBinary(filename string) error
	ExportFromHTML(filename string) error
	ExportFromExcel(filename string) error
	ExportFromPDF(filename string) error
	ExportFromMarkdown(filename string) error
}

func NewDataExporter

func NewDataExporter() DataExporter

type DataImporter

type DataImporter interface {
	ImportFromYAML(filename string) error
	ImportFromJSON(filename string) error
	ImportFromXML(filename string) error
	ImportFromTOML(filename string) error
	ImportFromENV(filename string) error
	ImportFromINI(filename string) error
	ImportFromCSV(filename string) error
	ImportFromProperties(filename string) error
	ImportFromText(filename string) error
	ImportFromASN(filename string) error
	ImportFromBinary(filename string) error
	ImportFromHTML(filename string) error
	ImportFromExcel(filename string) error
	ImportFromPDF(filename string) error
	ImportFromMarkdown(filename string) error
}

func NewDataImporter

func NewDataImporter() DataImporter

type EnvCache

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

func NewEnvCache

func NewEnvCache() *EnvCache

type Environment

type Environment struct {
	Logger l.Logger

	*Reference

	*EnvCache

	*Mutexes
	// contains filtered or unexported fields
}

func NewEnvironmentType

func NewEnvironmentType(envFile string, isConfidential bool, logger l.Logger) (*Environment, error)

func (*Environment) BackupEnvFile

func (e *Environment) BackupEnvFile() error

func (*Environment) CPUCount

func (e *Environment) CPUCount() int

func (*Environment) DecryptEnv

func (e *Environment) DecryptEnv(encryptedValue string) (string, error)

func (*Environment) DecryptEnvFile

func (e *Environment) DecryptEnvFile() (string, error)

func (*Environment) DisableEnvFileEncryption

func (e *Environment) DisableEnvFileEncryption() error

func (*Environment) EnableEnvFileEncryption

func (e *Environment) EnableEnvFileEncryption() error

func (*Environment) EncryptEnv

func (e *Environment) EncryptEnv(value string) (string, error)

func (*Environment) EncryptEnvFile

func (e *Environment) EncryptEnvFile() error

func (*Environment) GetEnvCache

func (e *Environment) GetEnvCache() map[string]string

func (*Environment) GetEnvFilePath

func (e *Environment) GetEnvFilePath() string

func (*Environment) GetShellName

func (e *Environment) GetShellName(s string) (string, int)

func (*Environment) Getenv

func (e *Environment) Getenv(key string) string

func (*Environment) GetenvOrDefault

func (e *Environment) GetenvOrDefault(key string, defaultValue any) (ci.IPropertyValBase[any], reflect.Kind)

func (*Environment) Hostname

func (e *Environment) Hostname() string

func (*Environment) IsEncrypted

func (e *Environment) IsEncrypted(envFile string) bool

func (*Environment) IsEncryptedValue

func (e *Environment) IsEncryptedValue(value string) bool

func (*Environment) Kernel

func (e *Environment) Kernel() string

func (*Environment) LoadEnvFile

func (e *Environment) LoadEnvFile(watchFunc func(ctx context.Context, chanCbArg chan any) <-chan any) error

func (*Environment) LoadEnvFromShell

func (e *Environment) LoadEnvFromShell() error

func (*Environment) MemAvailable

func (e *Environment) MemAvailable() int

func (*Environment) MemTotal

func (e *Environment) MemTotal() int

func (*Environment) Mu

func (e *Environment) Mu() ci.IMutexes

func (*Environment) Os

func (e *Environment) Os() string

func (*Environment) ParseEnvVar

func (e *Environment) ParseEnvVar(s string) (string, string)

func (*Environment) Setenv

func (e *Environment) Setenv(key, value string) error

type GoBEConfig

type GoBEConfig struct {
	*Reference
	*Mutexes

	FilePath string `json:"file_path" yaml:"file_path" env:"FILE_PATH" toml:"file_path" xml:"file_path" gorm:"file_path"`

	WorkerThreads int `` /* 129-byte string literal not displayed */

	RateLimitLimit int           `` /* 141-byte string literal not displayed */
	RateLimitBurst int           `` /* 141-byte string literal not displayed */
	RequestWindow  time.Duration `` /* 129-byte string literal not displayed */

	ProxyEnabled   bool          `json:"proxy_enabled" yaml:"proxy_enabled" env:"PROXY_ENABLED" toml:"proxy_enabled" xml:"proxy_enabled" gorm:"proxy_enabled"`
	ProxyHost      string        `json:"proxy_host" yaml:"proxy_host" env:"PROXY_HOST" toml:"proxy_host" xml:"proxy_host" gorm:"proxy_host"`
	ProxyPort      string        `json:"proxy_port" yaml:"proxy_port" env:"PROXY_PORT" toml:"proxy_port" xml:"proxy_port" gorm:"proxy_port"`
	ProxyBindAddr  string        `` /* 135-byte string literal not displayed */
	BasePath       string        `json:"base_path" yaml:"base_path" env:"BASE_PATH" toml:"base_path" xml:"base_path" gorm:"base_path"`
	Port           string        `json:"port" yaml:"port" env:"PORT" toml:"port" xml:"port" gorm:"port"`
	BindAddress    string        `json:"bind_address" yaml:"bind_address" env:"BIND_ADDRESS" toml:"bind_address" xml:"bind_address" gorm:"bind_address"`
	Timeouts       time.Duration `json:"timeouts" yaml:"timeouts" env:"TIMEOUTS" toml:"timeouts" xml:"timeouts" gorm:"timeouts"`
	MaxConnections int           `` /* 135-byte string literal not displayed */

	LogLevel       string `json:"log_level" yaml:"log_level" env:"LOG_LEVEL" toml:"log_level" xml:"log_level" gorm:"log_level"`
	LogFormat      string `json:"log_format" yaml:"log_format" env:"LOG_FORMAT" toml:"log_format" xml:"log_format" gorm:"log_format"`
	LogDir         string `json:"log_file" yaml:"log_file" env:"LOG_FILE" toml:"log_file" xml:"log_file" gorm:"log_file"`
	RequestLogging bool   `` /* 135-byte string literal not displayed */
	MetricsEnabled bool   `` /* 135-byte string literal not displayed */

	JWTSecretKey           string        `json:"jwt_secret_key" yaml:"jwt_secret"`
	RefreshTokenExpiration time.Duration `` /* 189-byte string literal not displayed */
	AccessTokenExpiration  time.Duration `` /* 183-byte string literal not displayed */
	TLSConfig              TLSConfig     `json:"tls_config" yaml:"tls_config" env:"TLS_CONFIG" toml:"tls_config" xml:"tls_config" gorm:"tls_config"`
	AllowedOrigins         []string      `` /* 135-byte string literal not displayed */
	APIKeyAuth             bool          `json:"api_key_auth" yaml:"api_key_auth" env:"API_KEY_AUTH" toml:"api_key_auth" xml:"api_key_auth" gorm:"api_key_auth"`
	APIKey                 string        `json:"api_key" yaml:"api_key" env:"API_KEY" toml:"api_key" xml:"api_key" gorm:"api_key"`

	ConfigFormat string `json:"config_format" yaml:"config_format" env:"CONFIG_FORMAT" toml:"config_format" xml:"config_format" gorm:"config_format"`

	Mapper ci.IMapper[*GoBEConfig]
}

func NewGoBEConfig

func NewGoBEConfig(name, filePath, configFormat, bind, port string) *GoBEConfig

func (*GoBEConfig) GetAPIKey

func (c *GoBEConfig) GetAPIKey() string

func (*GoBEConfig) GetAPIKeyAuth

func (c *GoBEConfig) GetAPIKeyAuth() bool

func (*GoBEConfig) GetAccessTokenExpiration

func (c *GoBEConfig) GetAccessTokenExpiration() time.Duration

func (*GoBEConfig) GetAllowedOrigins

func (c *GoBEConfig) GetAllowedOrigins() []string

func (*GoBEConfig) GetBindAddress

func (c *GoBEConfig) GetBindAddress() string

func (*GoBEConfig) GetConfigFormat

func (c *GoBEConfig) GetConfigFormat() string

func (*GoBEConfig) GetFilePath

func (c *GoBEConfig) GetFilePath() string

func (*GoBEConfig) GetJWTSecretKey

func (c *GoBEConfig) GetJWTSecretKey() string

func (*GoBEConfig) GetLogDir

func (c *GoBEConfig) GetLogDir() string

func (*GoBEConfig) GetLogFormat

func (c *GoBEConfig) GetLogFormat() string

func (*GoBEConfig) GetLogLevel

func (c *GoBEConfig) GetLogLevel() string

func (*GoBEConfig) GetMapper

func (c *GoBEConfig) GetMapper() ci.IMapper[*GoBEConfig]

func (*GoBEConfig) GetMaxConnections

func (c *GoBEConfig) GetMaxConnections() int

func (*GoBEConfig) GetMetricsEnabled

func (c *GoBEConfig) GetMetricsEnabled() bool

func (*GoBEConfig) GetPort

func (c *GoBEConfig) GetPort() string

func (*GoBEConfig) GetProxyEnabled

func (c *GoBEConfig) GetProxyEnabled() bool

func (*GoBEConfig) GetProxyHost

func (c *GoBEConfig) GetProxyHost() string

func (*GoBEConfig) GetProxyPort

func (c *GoBEConfig) GetProxyPort() string

func (*GoBEConfig) GetRateLimitBurst

func (c *GoBEConfig) GetRateLimitBurst() int

func (*GoBEConfig) GetRateLimitLimit

func (c *GoBEConfig) GetRateLimitLimit() int

func (*GoBEConfig) GetReference

func (c *GoBEConfig) GetReference() ci.IReference

func (*GoBEConfig) GetRefreshTokenExpiration

func (c *GoBEConfig) GetRefreshTokenExpiration() time.Duration

func (*GoBEConfig) GetRequestLogging

func (c *GoBEConfig) GetRequestLogging() bool

func (*GoBEConfig) GetRequestWindow

func (c *GoBEConfig) GetRequestWindow() time.Duration

func (*GoBEConfig) GetTLSConfig

func (c *GoBEConfig) GetTLSConfig() TLSConfig

func (*GoBEConfig) GetTimeouts

func (c *GoBEConfig) GetTimeouts() time.Duration

func (*GoBEConfig) GetWorkerThreads

func (c *GoBEConfig) GetWorkerThreads() int

func (*GoBEConfig) Load

func (c *GoBEConfig) Load() error

func (*GoBEConfig) Save

func (c *GoBEConfig) Save() error

func (*GoBEConfig) SetAPIKey

func (c *GoBEConfig) SetAPIKey(apiKey string)

func (*GoBEConfig) SetAPIKeyAuth

func (c *GoBEConfig) SetAPIKeyAuth(apiKeyAuth bool)

func (*GoBEConfig) SetAccessTokenExpiration

func (c *GoBEConfig) SetAccessTokenExpiration(accessTokenExpiration time.Duration)

func (*GoBEConfig) SetAllowedOrigins

func (c *GoBEConfig) SetAllowedOrigins(allowedOrigins []string)

func (*GoBEConfig) SetBindAddress

func (c *GoBEConfig) SetBindAddress(bindAddress string)

func (*GoBEConfig) SetConfigFormat

func (c *GoBEConfig) SetConfigFormat(configFormat string)

func (*GoBEConfig) SetFilePath

func (c *GoBEConfig) SetFilePath(filePath string)

func (*GoBEConfig) SetJWTSecretKey

func (c *GoBEConfig) SetJWTSecretKey(jwtSecretKey string)

func (*GoBEConfig) SetLogFile

func (c *GoBEConfig) SetLogFile(LogDir string)

func (*GoBEConfig) SetLogFormat

func (c *GoBEConfig) SetLogFormat(logFormat string)

func (*GoBEConfig) SetLogLevel

func (c *GoBEConfig) SetLogLevel(logLevel string)

func (*GoBEConfig) SetMapper

func (c *GoBEConfig) SetMapper(mapper ci.IMapper[*GoBEConfig])

func (*GoBEConfig) SetMaxConnections

func (c *GoBEConfig) SetMaxConnections(maxConnections int)

func (*GoBEConfig) SetMetricsEnabled

func (c *GoBEConfig) SetMetricsEnabled(metricsEnabled bool)

func (*GoBEConfig) SetPort

func (c *GoBEConfig) SetPort(port string)

func (*GoBEConfig) SetProxyEnabled

func (c *GoBEConfig) SetProxyEnabled(proxyEnabled bool)

func (*GoBEConfig) SetProxyHost

func (c *GoBEConfig) SetProxyHost(proxyHost string)

func (*GoBEConfig) SetProxyPort

func (c *GoBEConfig) SetProxyPort(proxyPort string)

func (*GoBEConfig) SetRateLimitBurst

func (c *GoBEConfig) SetRateLimitBurst(rateLimitBurst int)

func (*GoBEConfig) SetRateLimitLimit

func (c *GoBEConfig) SetRateLimitLimit(rateLimitLimit int)

func (*GoBEConfig) SetRefreshTokenExpiration

func (c *GoBEConfig) SetRefreshTokenExpiration(refreshTokenExpiration time.Duration)

func (*GoBEConfig) SetRequestLogging

func (c *GoBEConfig) SetRequestLogging(requestLogging bool)

func (*GoBEConfig) SetRequestWindow

func (c *GoBEConfig) SetRequestWindow(requestWindow time.Duration)

func (*GoBEConfig) SetTLSConfig

func (c *GoBEConfig) SetTLSConfig(tlsConfig TLSConfig)

func (*GoBEConfig) SetTimeouts

func (c *GoBEConfig) SetTimeouts(timeouts time.Duration)

func (*GoBEConfig) SetWorkerThreads

func (c *GoBEConfig) SetWorkerThreads(workerThreads int)

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()
}

IMutexes is an interface that defines the methods for a mutex context map.

func NewMutexes

func NewMutexes() IMutexes

NewMutexes creates a new mutex context map interface.

type IReference

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

func NewReference

func NewReference(name string) IReference

NewReference is a function that creates a new IReference instance.

type JSONB

type JSONB map[string]any

func (*JSONB) Scan

func (m *JSONB) Scan(vl any) error

func (JSONB) Value

func (m JSONB) Value() (driver.Value, error)

Value manual para o GORM

type Mapper

type Mapper[T any] struct {
	// contains filtered or unexported fields
}

Mapper is a generic struct that implements the IMapper interface for serializing and deserializing objects.

func NewMapperPtr

func NewMapperPtr[T any](object *T, filePath string) *Mapper[*T]

NewMapperPtr creates a new instance of Mapper.

func NewMapperType

func NewMapperType[T any](object *T, filePath string) *Mapper[T]

NewMapperType creates a new instance of Mapper.

func NewMapperTypeWithObject

func NewMapperTypeWithObject[T any](object *T, filePath string) *Mapper[T]

NewMapperTypeWithObject creates a new instance of Mapper.

func (*Mapper[T]) Deserialize

func (m *Mapper[T]) Deserialize(data []byte, format string) (*T, error)

Deserialize converts a byte array in the specified format to an object of type T.

func (*Mapper[T]) DeserializeFromFile

func (m *Mapper[T]) DeserializeFromFile(format string) (*T, error)

DeserializeFromFile deserializes an object of type T from a file in the specified format.

func (*Mapper[T]) Serialize

func (m *Mapper[T]) Serialize(format string) ([]byte, error)

Serialize converts an object of type T to a byte array in the specified format.

func (*Mapper[T]) SerializeToFile

func (m *Mapper[T]) SerializeToFile(format string)

SerializeToFile serializes an object of type T to a file in the specified format.

type Mutexes

type Mutexes struct {

	// MuCtxM is a mutex for the ctx map.
	MuCtxM *sync.RWMutex
	// MuCtxL is a mutex for sync.Cond in the ctx map.
	MuCtxL *sync.RWMutex
	// MuCtxCond is a condition variable for the ctx map.
	MuCtxCond *sync.Cond
	// MuCtxWg is a wait group for the ctx map.
	MuCtxWg *sync.WaitGroup
	// contains filtered or unexported fields
}

Mutexes is a struct that holds the mutex context map

func NewMutexesType

func NewMutexesType() *Mutexes

NewMutexesType creates a new mutex context map struct pointer.

func (*Mutexes) GetMuSharedCtx

func (m *Mutexes) GetMuSharedCtx() any

GetMuSharedCtx returns the shared context

func (*Mutexes) GetMuSharedCtxValidate

func (m *Mutexes) GetMuSharedCtxValidate() func(any) (bool, error)

GetMuSharedCtxValidate returns the shared context validation function

func (*Mutexes) MuAdd

func (m *Mutexes) MuAdd(delta int)

MuAdd adds a delta to the wait group counter

func (*Mutexes) MuBroadcastCond

func (m *Mutexes) MuBroadcastCond()

MuBroadcastCond broadcasts the condition variable

func (*Mutexes) MuDone

func (m *Mutexes) MuDone()

MuDone signals that the wait group is done

func (*Mutexes) MuLock

func (m *Mutexes) MuLock()

MuLock locks the mutex

func (*Mutexes) MuRLock

func (m *Mutexes) MuRLock()

MuRLock locks the mutex for reading

func (*Mutexes) MuRUnlock

func (m *Mutexes) MuRUnlock()

MuRUnlock unlocks the mutex for reading

func (*Mutexes) MuSignalCond

func (m *Mutexes) MuSignalCond()

MuSignalCond signals the condition variable

func (*Mutexes) MuTryLock

func (m *Mutexes) MuTryLock() bool

MuTryLock tries to lock the mutex without blocking

func (*Mutexes) MuTryRLock

func (m *Mutexes) MuTryRLock() bool

MuTryRLock tries to lock the mutex for reading without blocking

func (*Mutexes) MuUnlock

func (m *Mutexes) MuUnlock()

MuUnlock unlocks the mutex

func (*Mutexes) MuWait

func (m *Mutexes) MuWait()

MuWait waits for the wait group counter to reach zero

func (*Mutexes) MuWaitCond

func (m *Mutexes) MuWaitCond()

MuWaitCond waits for the condition variable to be signaled

func (*Mutexes) MuWaitCondWithTimeout

func (m *Mutexes) MuWaitCondWithTimeout(timeout time.Duration) bool

MuWaitCondWithTimeout waits for the condition variable to be signaled with a timeout

func (*Mutexes) SetMuSharedCtx

func (m *Mutexes) SetMuSharedCtx(ctx any)

SetMuSharedCtx sets the shared context

func (*Mutexes) SetMuSharedCtxValidate

func (m *Mutexes) SetMuSharedCtxValidate(validate func(any) (bool, error))

SetMuSharedCtxValidate sets the shared context validation function

type Property

type Property[T any] struct {
	// contains filtered or unexported fields
}

Property is a struct that holds the properties of the GoLife instance.

func (*Property[T]) Deserialize

func (p *Property[T]) Deserialize(data []byte, format, filePath string) error

Deserialize deserializes the data into the ProcessInput instance.

func (*Property[T]) GetLogger

func (p *Property[T]) GetLogger() l.Logger

GetLogger returns the logger of the property.

func (*Property[T]) GetName

func (p *Property[T]) GetName() string

GetName returns the name of the property.

func (*Property[T]) GetReference

func (p *Property[T]) GetReference() (uuid.UUID, string)

GetReference returns the reference of the property.

func (*Property[T]) GetValue

func (p *Property[T]) GetValue() T

GetValue returns the value of the property.

func (*Property[T]) LoadFromFile

func (p *Property[T]) LoadFromFile(filename, format string) error

LoadFromFile loads the property from a file in the specified format.

func (*Property[T]) Prop

func (p *Property[T]) Prop() ci.IPropertyValBase[T]

Prop is a struct that holds the properties of the GoLife instance.

func (*Property[T]) SaveToFile

func (p *Property[T]) SaveToFile(filePath string, format string) error

SaveToFile saves the property to a file in the specified format.

func (*Property[T]) Serialize

func (p *Property[T]) Serialize(format, filePath string) ([]byte, error)

Serialize serializes the ProcessInput instance to the specified format.

func (*Property[T]) SetValue

func (p *Property[T]) SetValue(v *T)

SetValue sets the value of the property.

type PropertyValBase

type PropertyValBase[T any] struct {
	// Logger is the logger for this context.
	Logger l.Logger

	// v is the value.
	*atomic.Pointer[T]

	// Reference is the identifiers for the context.
	// IReference
	*Reference

	//muCtx is the mutexes for the context.
	*Mutexes

	// validation is the validation for the value.
	*Validation[T]

	// Channel is the channel for the value.
	ci.IChannelCtl[T]
	// contains filtered or unexported fields
}

PropertyValBase is a type for the value.

func (*PropertyValBase[T]) Clear

func (v *PropertyValBase[T]) Clear() bool

Clear is a method that clears the value.

func (*PropertyValBase[T]) Deserialize

func (v *PropertyValBase[T]) Deserialize(data []byte, format, filePath string) error

Deserialize is a method that deserializes the data into the value.

func (*PropertyValBase[T]) Get

func (v *PropertyValBase[T]) Get(async bool) any

Get is a method that returns the value.

func (*PropertyValBase[T]) GetID

func (v *PropertyValBase[T]) GetID() uuid.UUID

GetID is a method that returns the ID of the value.

func (*PropertyValBase[T]) GetLogger

func (v *PropertyValBase[T]) GetLogger() l.Logger

GetLogger is a method that returns the logger for the value.

func (*PropertyValBase[T]) GetName

func (v *PropertyValBase[T]) GetName() string

GetName is a method that returns the name of the value.

func (*PropertyValBase[T]) IsNil

func (v *PropertyValBase[T]) IsNil() bool

IsNil is a method that checks if the value is nil.

func (*PropertyValBase[T]) Serialize

func (v *PropertyValBase[T]) Serialize(filePath, format string) ([]byte, error)

Serialize is a method that serializes the value.

func (*PropertyValBase[T]) Set

func (v *PropertyValBase[T]) Set(t *T) bool

Set is a method that sets the value.

func (*PropertyValBase[T]) StartCtl

func (v *PropertyValBase[T]) StartCtl() <-chan string

StartCtl is a method that starts the control channel.

func (*PropertyValBase[T]) Type

func (v *PropertyValBase[T]) Type() reflect.Type

Type is a method that returns the type of the value.

func (*PropertyValBase[T]) Value

func (v *PropertyValBase[T]) Value() *T

Value is a method that returns the value.

type Reference

type Reference struct {
	// refID is the unique identifier for this context.
	ID uuid.UUID
	// refName is the name of the context.
	Name string
}

Reference is a struct that holds the Reference ID and name.

func (*Reference) GetID

func (r *Reference) GetID() uuid.UUID

GetID is a method that returns the ID of the reference.

func (*Reference) GetName

func (r *Reference) GetName() string

GetName is a method that returns the name of the reference.

func (*Reference) GetReference

func (r *Reference) GetReference() *Reference

GetReference is a method that returns the reference struct (non-interface).

func (*Reference) SetName

func (r *Reference) SetName(name string)

SetName is a method that sets the name of the reference.

func (*Reference) String

func (r *Reference) String() string

String is a method that returns the string representation of the reference.

type RequestTracers

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

func NewRequestTracers

func NewRequestTracers(g ci.IGoBE) *RequestTracers

func (*RequestTracers) AddRequestTracer

func (r *RequestTracers) AddRequestTracer(name string, tracer ci.IRequestsTracer)

func (*RequestTracers) GetRequestTracer

func (r *RequestTracers) GetRequestTracer(name string) (ci.IRequestsTracer, bool)

func (*RequestTracers) GetRequestTracers

func (r *RequestTracers) GetRequestTracers() map[string]ci.IRequestsTracer

func (*RequestTracers) RemoveRequestTracer

func (r *RequestTracers) RemoveRequestTracer(name string)

func (RequestTracers) RequestsTracerMiddleware

func (r RequestTracers) RequestsTracerMiddleware() gin.HandlerFunc

func (*RequestTracers) SetRequestTracers

func (r *RequestTracers) SetRequestTracers(tracers map[string]ci.IRequestsTracer)

type RequestsTracer

type RequestsTracer struct {
	Mutexes       ci.IMutexes `json:"-" yaml:"-" xml:"-" toml:"-" gorm:"-"`
	IP            string      `json:"ip" yaml:"ip" xml:"ip" toml:"ip" gorm:"ip"`
	Port          string      `json:"port" yaml:"port" xml:"port" toml:"port" gorm:"port"`
	LastUserAgent string      `json:"last_user_agent" yaml:"last_user_agent" xml:"last_user_agent" toml:"last_user_agent" gorm:"last_user_agent"`
	UserAgents    []string    `json:"user_agents" yaml:"user_agents" xml:"user_agents" toml:"user_agents" gorm:"user_agents"`
	Endpoint      string      `json:"endpoint" yaml:"endpoint" xml:"endpoint" toml:"endpoint" gorm:"endpoint"`
	Method        string      `json:"method" yaml:"method" xml:"method" toml:"method" gorm:"method"`
	TimeList      []time.Time `json:"time_list" yaml:"time_list" xml:"time_list" toml:"time_list" gorm:"time_list"`
	Count         int         `json:"count" yaml:"count" xml:"count" toml:"count" gorm:"count"`
	Valid         bool        `json:"-" yaml:"-" xml:"-" toml:"-" gorm:"-"`
	Error         error       `json:"-" yaml:"-" xml:"-" toml:"-" gorm:"-"`

	Mapper ci.IMapper[ci.IRequestsTracer] `json:"-" yaml:"-" xml:"-" toml:"-" gorm:"-"`
	// contains filtered or unexported fields
}

func (*RequestsTracer) GetCount

func (r *RequestsTracer) GetCount() int

func (*RequestsTracer) GetEndpoint

func (r *RequestsTracer) GetEndpoint() string

func (*RequestsTracer) GetError

func (r *RequestsTracer) GetError() error

func (*RequestsTracer) GetFilePath

func (r *RequestsTracer) GetFilePath() string

func (*RequestsTracer) GetIP

func (r *RequestsTracer) GetIP() string

func (*RequestsTracer) GetLastUserAgent

func (r *RequestsTracer) GetLastUserAgent() string

func (*RequestsTracer) GetMapper

func (r *RequestsTracer) GetMapper() ci.IMapper[ci.IRequestsTracer]

func (*RequestsTracer) GetMethod

func (r *RequestsTracer) GetMethod() string

func (*RequestsTracer) GetMutexes

func (r *RequestsTracer) GetMutexes() ci.IMutexes

func (*RequestsTracer) GetOldFilePath

func (r *RequestsTracer) GetOldFilePath() string

func (*RequestsTracer) GetPort

func (r *RequestsTracer) GetPort() string

func (*RequestsTracer) GetRequestLimit

func (r *RequestsTracer) GetRequestLimit() int

func (*RequestsTracer) GetRequestWindow

func (r *RequestsTracer) GetRequestWindow() time.Duration

func (*RequestsTracer) GetTimeList

func (r *RequestsTracer) GetTimeList() []time.Time

func (*RequestsTracer) GetUserAgents

func (r *RequestsTracer) GetUserAgents() []string

func (*RequestsTracer) IsValid

func (r *RequestsTracer) IsValid() bool

func (*RequestsTracer) Mu

func (r *RequestsTracer) Mu() ci.IMutexes

func (*RequestsTracer) SetFilePath

func (r *RequestsTracer) SetFilePath(filePath string)

func (*RequestsTracer) SetMapper

func (r *RequestsTracer) SetMapper(mapper ci.IMapper[ci.IRequestsTracer])

func (*RequestsTracer) SetRequestLimit

func (r *RequestsTracer) SetRequestLimit(limit int)

func (*RequestsTracer) SetRequestWindow

func (r *RequestsTracer) SetRequestWindow(window time.Duration)

type SignalManager

type SignalManager[T chan string] struct {
	// Logger is the Logger instance for this GoLife instance.
	Logger l.Logger
	// Reference is the reference ID and name.
	*Reference
	// SigChan is the channel for the signal.
	SigChan chan os.Signal
	// contains filtered or unexported fields
}

func (*SignalManager[T]) ListenForSignals

func (sm *SignalManager[T]) ListenForSignals() (<-chan string, error)

ListenForSignals sets up the signal channel to listen for specific signals.

func (*SignalManager[T]) StopListening

func (sm *SignalManager[T]) StopListening()

StopListening stops listening for signals and closes the channel.

type TLSConfig

type TLSConfig struct {
	*Reference
	*Mutexes
	CertFile      string `json:"cert_file" yaml:"cert_file" env:"CERT_FILE" toml:"cert_file" xml:"cert_file" gorm:"cert_file"`
	KeyFile       string `json:"key_file" yaml:"key_file" env:"KEY_FILE" toml:"key_file" xml:"key_file" gorm:"key_file"`
	CAFile        string `json:"ca_file" yaml:"ca_file" env:"CA_FILE" toml:"ca_file" xml:"ca_file" gorm:"ca_file"`
	Enabled       bool   `json:"enabled" yaml:"enabled" env:"TLS_ENABLED" toml:"tls_enabled" xml:"tls_enabled" gorm:"tls_enabled"`
	SkipVerify    bool   `` /* 127-byte string literal not displayed */
	StrictHostKey bool   `` /* 151-byte string literal not displayed */
	MinVersion    string `` /* 127-byte string literal not displayed */
	Mapper        ci.IMapper[*TLSConfig]
}

TLSConfig is a struct that holds the TLS configuration for the GoBE instance.

func (*TLSConfig) GetCAFile

func (t *TLSConfig) GetCAFile() string

func (*TLSConfig) GetCertFile

func (t *TLSConfig) GetCertFile() string

func (*TLSConfig) GetEnabled

func (t *TLSConfig) GetEnabled() bool

func (*TLSConfig) GetKeyFile

func (t *TLSConfig) GetKeyFile() string

func (*TLSConfig) GetMinVersion

func (t *TLSConfig) GetMinVersion() string

func (*TLSConfig) GetMutexes

func (t *TLSConfig) GetMutexes() ci.IMutexes

func (*TLSConfig) GetReference

func (t *TLSConfig) GetReference() ci.IReference

func (*TLSConfig) GetSkipVerify

func (t *TLSConfig) GetSkipVerify() bool

func (*TLSConfig) GetStrictHostKey

func (t *TLSConfig) GetStrictHostKey() bool

func (*TLSConfig) GetTLSConfig

func (t *TLSConfig) GetTLSConfig() ci.ITLSConfig

func (*TLSConfig) Load

func (t *TLSConfig) Load() error

func (*TLSConfig) Save

func (t *TLSConfig) Save() error

func (*TLSConfig) SetCAFile

func (t *TLSConfig) SetCAFile(caFile string)

func (*TLSConfig) SetCertFile

func (t *TLSConfig) SetCertFile(certFile string)

func (*TLSConfig) SetEnabled

func (t *TLSConfig) SetEnabled(enabled bool)

func (*TLSConfig) SetKeyFile

func (t *TLSConfig) SetKeyFile(keyFile string)

func (*TLSConfig) SetMinVersion

func (t *TLSConfig) SetMinVersion(minVersion string)

func (*TLSConfig) SetMutexes

func (t *TLSConfig) SetMutexes(mutexes ci.IMutexes)

func (*TLSConfig) SetReference

func (t *TLSConfig) SetReference(ref ci.IReference)

func (*TLSConfig) SetSkipVerify

func (t *TLSConfig) SetSkipVerify(skipVerify bool)

func (*TLSConfig) SetStrictHostKey

func (t *TLSConfig) SetStrictHostKey(strictHostKey bool)

func (*TLSConfig) SetTLSConfig

func (t *TLSConfig) SetTLSConfig(tlsConfig ci.ITLSConfig)

type Telemetry

type Telemetry struct {
	// TelemetryIdentifier is the identifier for telemetry data
	TelemetryIdentifier
	// TelemetryLogger is the Logger for telemetry data
	TelemetryLogger
	// TelemetryData is the telemetry data
	TelemetryData
	// TelemetryMutex is a mutex for synchronizing access to the telemetry data
	TelemetryMutex
	// TelemetryChannel is a struct that holds channels for telemetry data
	TelemetryChannel
	// TelemetryProperty is a struct that holds a property for telemetry data
	TelemetryProperty
	// TelemetryConfig is a struct that holds the configuration for telemetry data
	TelemetryConfig
}

Telemetry is a struct that holds telemetry data for a process

func NewTelemetry

func NewTelemetry() *Telemetry

NewTelemetry creates a new Telemetry instance

func (*Telemetry) GetLastUpdated

func (t *Telemetry) GetLastUpdated() time.Time

GetLastUpdated returns the last updated time of the telemetry

func (*Telemetry) GetMetrics

func (t *Telemetry) GetMetrics() map[string]float64

GetMetrics returns the telemetry metrics

func (*Telemetry) ResetMetrics

func (t *Telemetry) ResetMetrics()

ResetMetrics resets the telemetry metrics

func (*Telemetry) UpdateMetrics

func (t *Telemetry) UpdateMetrics(data map[string]float64)

UpdateMetrics updates the telemetry metrics with the given data

type TelemetryChannel

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

TelemetryChannel is a struct that holds channels for telemetry data

type TelemetryConfig

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

TelemetryConfig is a struct that holds the configuration for telemetry data

type TelemetryData

type TelemetryData struct {
	// LastUpdated is the last time the telemetry data was updated
	LastUpdated time.Time
	// Metrics is a map of metric names to their values
	Metrics map[string]float64
}

TelemetryData is a struct that holds telemetry data

type TelemetryIdentifier

type TelemetryIdentifier struct {
	// ID is the unique identifier for this telemetry instance
	ID string
	// Name is the name of the telemetry instance
	Name string
	// Logger is the Logger instance for this telemetry
	Logger l.Logger
	// Type is the type of telemetry (e.g., CPU, Memory, etc.)
	Type string
}

TelemetryIdentifier is a struct that holds the identifier for telemetry data

type TelemetryLogger

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

TelemetryLogger is a struct that holds a Logger for telemetry data

type TelemetryMutex

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

TelemetryMutex is a struct that holds mutexes for synchronizing access to telemetry data

type TelemetryProperty

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

TelemetryProperty is a struct that holds a property for telemetry data

type Validation

type Validation[T any] struct {
	// contains filtered or unexported fields
}

Validation is a struct that holds the validation function and the errors.

func (*Validation[T]) AddValidator

func (v *Validation[T]) AddValidator(validator ci.IValidationFunc[T]) error

AddValidator is a function that adds a validator to the map of validators.

func (*Validation[T]) CheckIfWillValidate

func (v *Validation[T]) CheckIfWillValidate() bool

func (*Validation[T]) ClearResults

func (v *Validation[T]) ClearResults()

ClearResults is a function that clears the map of errors.

func (*Validation[T]) GetResults

func (v *Validation[T]) GetResults() map[int]ci.IValidationResult

GetResults is a function that gets the map of errors.

func (*Validation[T]) GetValidator

func (v *Validation[T]) GetValidator(priority int) (any, error)

GetValidator is a function that gets a validator from the map of validators.

func (*Validation[T]) GetValidators

func (v *Validation[T]) GetValidators() map[int]ci.IValidationFunc[T]

GetValidators is a function that gets the map of validators.

func (*Validation[T]) IsValid

func (v *Validation[T]) IsValid() bool

IsValid is a function that gets the boolean that indicates if the value is valid.

func (*Validation[T]) RemoveValidator

func (v *Validation[T]) RemoveValidator(priority int) error

RemoveValidator is a function that removes a validator from the map of validators.

func (*Validation[T]) Validate

func (v *Validation[T]) Validate(value *T, args ...any) ci.IValidationResult

Validate is the function that validates the value.

type ValidationFilterType

type ValidationFilterType string
const (
	ValidationFilterTypeEvent    ValidationFilterType = "event"    // Event filter
	ValidationFilterTypeListener ValidationFilterType = "listener" // Listener filter
	ValidationFilterTypeResult   ValidationFilterType = "result"   // Result filter
)

type ValidationFunc

type ValidationFunc[T any] struct {
	Priority int
	Func     func(value *T, args ...any) ci.IValidationResult
	Result   ci.IValidationResult
}

func (*ValidationFunc[T]) GetFunction

func (vf *ValidationFunc[T]) GetFunction() func(value *T, args ...any) ci.IValidationResult

func (*ValidationFunc[T]) GetPriority

func (vf *ValidationFunc[T]) GetPriority() int

func (*ValidationFunc[T]) GetResult

func (vf *ValidationFunc[T]) GetResult() ci.IValidationResult

func (*ValidationFunc[T]) SetFunction

func (vf *ValidationFunc[T]) SetFunction(f func(value *T, args ...any) ci.IValidationResult)

func (*ValidationFunc[T]) SetPriority

func (vf *ValidationFunc[T]) SetPriority(priority int)

func (*ValidationFunc[T]) SetResult

func (vf *ValidationFunc[T]) SetResult(result ci.IValidationResult)

type ValidationListener

type ValidationListener struct {
	*Mutexes
	Filters   map[ValidationFilterType]func(*ValidationResult) bool
	Handlers  []func(*ValidationResult)
	Listeners map[Reference]map[ValidationListenerType]func(*ValidationResult)
}

func NewValidationListener

func NewValidationListener() *ValidationListener

func (*ValidationListener) AddFilter

func (vl *ValidationListener) AddFilter(filterType ValidationFilterType, filter func(*ValidationResult) bool)

func (*ValidationListener) AddHandler

func (vl *ValidationListener) AddHandler(handler func(*ValidationResult))

func (*ValidationListener) AddListener

func (vl *ValidationListener) AddListener(reference Reference, listenerType ValidationListenerType, handler func(*ValidationResult))

func (*ValidationListener) GetFilters

func (vl *ValidationListener) GetFilters() map[string]func(*ValidationResult) bool

func (*ValidationListener) GetHandlers

func (vl *ValidationListener) GetHandlers() []func(*ValidationResult)

func (*ValidationListener) GetHandlersByName

func (vl *ValidationListener) GetHandlersByName(name string) []func(*ValidationResult)

func (*ValidationListener) GetListeners

func (vl *ValidationListener) GetListeners() map[Reference]map[ValidationListenerType]func(*ValidationResult)

func (*ValidationListener) GetListenersByName

func (vl *ValidationListener) GetListenersByName(name string) map[ValidationListenerType]func(*ValidationResult)

func (*ValidationListener) GetListenersKeys

func (vl *ValidationListener) GetListenersKeys() map[string]Reference

func (*ValidationListener) RegisterListener

func (vl *ValidationListener) RegisterListener(reference Reference, handler func(*ValidationResult))

func (*ValidationListener) RemoveFilter

func (vl *ValidationListener) RemoveFilter(filterType ValidationFilterType)

func (*ValidationListener) RemoveHandler

func (vl *ValidationListener) RemoveHandler(handler func(*ValidationResult))

func (*ValidationListener) RemoveListener

func (vl *ValidationListener) RemoveListener(reference Reference, listenerType ValidationListenerType)

func (*ValidationListener) Trigger

func (vl *ValidationListener) Trigger(event string, result *ValidationResult)

type ValidationListenerType

type ValidationListenerType string
const (
	ValidationListenerTypeBefore  ValidationListenerType = "before"  // Before validation
	ValidationListenerTypeAfter   ValidationListenerType = "after"   // After validation
	ValidationListenerTypeError   ValidationListenerType = "error"   // Error validation
	ValidationListenerTypeSuccess ValidationListenerType = "success" // Success validation
	ValidationListenerTypeDefault ValidationListenerType = "default" // Default validation
)

type ValidationResult

type ValidationResult struct {
	*Mutexes
	*Reference
	IsValid  bool
	Message  string
	Error    error
	Metadata map[string]any
	Callback func(result *ValidationResult)
}

func (*ValidationResult) GetAllMetadataKeys

func (vr *ValidationResult) GetAllMetadataKeys() []string

func (*ValidationResult) GetError

func (vr *ValidationResult) GetError() error

func (*ValidationResult) GetID

func (vr *ValidationResult) GetID() uuid.UUID

func (*ValidationResult) GetIsValid

func (vr *ValidationResult) GetIsValid() bool

func (*ValidationResult) GetMessage

func (vr *ValidationResult) GetMessage() string

func (*ValidationResult) GetMetadata

func (vr *ValidationResult) GetMetadata(key string) (any, bool)

func (*ValidationResult) GetName

func (vr *ValidationResult) GetName() string

func (*ValidationResult) SetMetadata

func (vr *ValidationResult) SetMetadata(key string, value any)

func (*ValidationResult) String

func (vr *ValidationResult) String() string

Jump to

Keyboard shortcuts

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