Documentation
¶
Index ¶
- Constants
- Variables
- func AuthHasAccess(ctx context.Context, action string, subject string) (bool, error)
- func Cfg(ctx context.Context) any
- func ConfigFillEnv(v any) error
- func ConfigFromEnv[T any]() (T, error)
- func ConfigLoadWithOIDC[T any](ctx context.Context) (T, error)
- func ConfigToContext(ctx context.Context, config any) context.Context
- func DBPropertiesToMap(props JSONMap) map[string]string
- func ErrorIsNoRows(err error) bool
- func GetLoggingOptions() []logging.Option
- func IsTenancyChecksOnClaimSkipped(ctx context.Context) bool
- func JwtFromContext(ctx context.Context) string
- func LanguageFromContext(ctx context.Context) []string
- func LanguageFromGrpcRequest(ctx context.Context) []string
- func LanguageFromMap(m map[string]string) []string
- func LanguageToMap(m map[string]string, lang []string) map[string]string
- func LangugageToContext(ctx context.Context, lang []string) context.Context
- func NewGrpcHealthServer(service *Service) grpc_health_v1.HealthServer
- func RecoveryHandlerFun(ctx context.Context, p any) error
- func SafeChannelWrite[T any](ctx context.Context, ch chan<- JobResult[T], value JobResult[T]) error
- func SkipTenancyChecksOnClaims(ctx context.Context) context.Context
- func SubmitJob[T any](ctx context.Context, s *Service, job Job[T]) error
- func SvcToContext(ctx context.Context, service *Service) context.Context
- type AuthenticationClaims
- func (a *AuthenticationClaims) AsMetadata() map[string]string
- func (a *AuthenticationClaims) ClaimsToContext(ctx context.Context) context.Context
- func (a *AuthenticationClaims) GetAccessID() string
- func (a *AuthenticationClaims) GetContactID() string
- func (a *AuthenticationClaims) GetDeviceID() string
- func (a *AuthenticationClaims) GetPartitionID() string
- func (a *AuthenticationClaims) GetRoles() []string
- func (a *AuthenticationClaims) GetServiceName() string
- func (a *AuthenticationClaims) GetSessionID() string
- func (a *AuthenticationClaims) GetTenantID() string
- type BaseModel
- func (model *BaseModel) BeforeCreate(db *gorm.DB) error
- func (model *BaseModel) BeforeSave(db *gorm.DB) error
- func (model *BaseModel) BeforeUpdate(_ *gorm.DB) error
- func (model *BaseModel) CopyPartitionInfo(parent *BaseModel)
- func (model *BaseModel) GenID(ctx context.Context)
- func (model *BaseModel) GetID() string
- func (model *BaseModel) GetVersion() uint
- func (model *BaseModel) ValidXID(id string) bool
- type BaseModelI
- type BaseRepository
- func (repo *BaseRepository) Delete(id string) error
- func (repo *BaseRepository) GetAllBy(properties map[string]any, result []BaseModelI) error
- func (repo *BaseRepository) GetByID(id string, result BaseModelI) error
- func (repo *BaseRepository) GetLastestBy(properties map[string]any, result BaseModelI) error
- func (repo *BaseRepository) Save(instance BaseModelI) error
- func (repo *BaseRepository) Search(query string, searchFields []string, result []BaseModelI) error
- type BaseRepositoryI
- type Checker
- type CheckerFunc
- type ConfigurationAuthorization
- type ConfigurationCORS
- type ConfigurationDatabase
- type ConfigurationDefault
- func (c *ConfigurationDefault) CanDatabaseTraceQueries() bool
- func (c *ConfigurationDefault) DoDatabaseMigrate() bool
- func (c *ConfigurationDefault) GetAuthorizationServiceReadURI() string
- func (c *ConfigurationDefault) GetAuthorizationServiceWriteURI() string
- func (c *ConfigurationDefault) GetCORSAllowedHeaders() []string
- func (c *ConfigurationDefault) GetCORSAllowedMethods() []string
- func (c *ConfigurationDefault) GetCORSAllowedOrigins() []string
- func (c *ConfigurationDefault) GetCORSExposedHeaders() []string
- func (c *ConfigurationDefault) GetCORSMaxAge() int
- func (c *ConfigurationDefault) GetCPUFactor() int
- func (c *ConfigurationDefault) GetCapacity() int
- func (c *ConfigurationDefault) GetCount() int
- func (c *ConfigurationDefault) GetDatabaseMigrationPath() string
- func (c *ConfigurationDefault) GetDatabasePrimaryHostURL() []string
- func (c *ConfigurationDefault) GetDatabaseReplicaHostURL() []string
- func (c *ConfigurationDefault) GetDatabaseSlowQueryLogThreshold() time.Duration
- func (c *ConfigurationDefault) GetEventsQueueName() string
- func (c *ConfigurationDefault) GetEventsQueueURL() string
- func (c *ConfigurationDefault) GetExpiryDuration() time.Duration
- func (c *ConfigurationDefault) GetMaxConnectionLifeTimeInSeconds() time.Duration
- func (c *ConfigurationDefault) GetMaxIdleConnections() int
- func (c *ConfigurationDefault) GetMaxOpenConnections() int
- func (c *ConfigurationDefault) GetOauth2AuthorizationEndpoint() string
- func (c *ConfigurationDefault) GetOauth2EndSessionEndpoint() string
- func (c *ConfigurationDefault) GetOauth2Issuer() string
- func (c *ConfigurationDefault) GetOauth2RegistrationEndpoint() string
- func (c *ConfigurationDefault) GetOauth2RevocationEndpoint() string
- func (c *ConfigurationDefault) GetOauth2ServiceAdminURI() string
- func (c *ConfigurationDefault) GetOauth2ServiceAudience() string
- func (c *ConfigurationDefault) GetOauth2ServiceClientID() string
- func (c *ConfigurationDefault) GetOauth2ServiceClientSecret() string
- func (c *ConfigurationDefault) GetOauth2ServiceURI() string
- func (c *ConfigurationDefault) GetOauth2TokenEndpoint() string
- func (c *ConfigurationDefault) GetOauth2UserInfoEndpoint() string
- func (c *ConfigurationDefault) GetOauth2WellKnownJwk() string
- func (c *ConfigurationDefault) GetOauth2WellKnownJwkData() string
- func (c *ConfigurationDefault) GetOauth2WellKnownOIDC() string
- func (c *ConfigurationDefault) GrpcPort() string
- func (c *ConfigurationDefault) HTTPPort() string
- func (c *ConfigurationDefault) IsCORSAllowCredentials() bool
- func (c *ConfigurationDefault) IsCORSEnabled() bool
- func (c *ConfigurationDefault) IsRunSecurely() bool
- func (c *ConfigurationDefault) LoadOauth2Config(ctx context.Context) error
- func (c *ConfigurationDefault) LoggingColored() bool
- func (c *ConfigurationDefault) LoggingFormat() string
- func (c *ConfigurationDefault) LoggingLevel() string
- func (c *ConfigurationDefault) LoggingLevelIsDebug() bool
- func (c *ConfigurationDefault) LoggingShowStackTrace() bool
- func (c *ConfigurationDefault) LoggingTimeFormat() string
- func (c *ConfigurationDefault) Port() string
- func (c *ConfigurationDefault) PreferSimpleProtocol() bool
- func (c *ConfigurationDefault) SetTLSCertAndKeyPath(certificatePath, certificateKeyPath string)
- func (c *ConfigurationDefault) SkipDefaultTransaction() bool
- func (c *ConfigurationDefault) TLSCertKeyPath() string
- func (c *ConfigurationDefault) TLSCertPath() string
- type ConfigurationEvents
- type ConfigurationLogLevel
- type ConfigurationOAUTH2
- type ConfigurationPorts
- type ConfigurationSecurity
- type ConfigurationTLS
- type ConfigurationWorkerPool
- type DataSource
- func (d DataSource) ChangePort(newPort string) (DataSource, error)
- func (d DataSource) DelPath() DataSource
- func (d DataSource) ExtendPath(epath ...string) DataSource
- func (d DataSource) ExtendQuery(key, value string) DataSource
- func (d DataSource) GetQuery(key string) string
- func (d DataSource) IsCache() bool
- func (d DataSource) IsDB() bool
- func (d DataSource) IsMem() bool
- func (d DataSource) IsMySQL() bool
- func (d DataSource) IsNats() bool
- func (d DataSource) IsPostgres() bool
- func (d DataSource) IsQueue() bool
- func (d DataSource) IsRedis() bool
- func (d DataSource) PrefixPath(prefix string) DataSource
- func (d DataSource) RemoveQuery(key ...string) DataSource
- func (d DataSource) String() string
- func (d DataSource) SuffixPath(suffix string) DataSource
- func (d DataSource) ToArray() []DataSource
- func (d DataSource) ToURI() (*url.URL, error)
- func (d DataSource) WithPassword(password string) (DataSource, error)
- func (d DataSource) WithPath(path string) (DataSource, error)
- func (d DataSource) WithPathSuffix(suffix string) (DataSource, error)
- func (d DataSource) WithQuery(query string) (DataSource, error)
- func (d DataSource) WithUser(user string) (DataSource, error)
- func (d DataSource) WithUserAndPassword(userName, password string) (DataSource, error)
- type DatastoreMigrator
- type EventI
- type JSONMap
- func (m *JSONMap) GormDBDataType(db *gorm.DB, _ *schema.Field) string
- func (m *JSONMap) GormDataType() string
- func (m *JSONMap) GormValue(_ context.Context, db *gorm.DB) clause.Expr
- func (m *JSONMap) MarshalJSON() ([]byte, error)
- func (m *JSONMap) Scan(value interface{}) error
- func (m *JSONMap) UnmarshalJSON(data []byte) error
- func (m *JSONMap) Value() (driver.Value, error)
- type JSONWebKeys
- type Job
- func NewJob[T any](process func(ctx context.Context, result JobResultPipe[T]) error) Job[T]
- func NewJobWithBuffer[T any](process func(ctx context.Context, result JobResultPipe[T]) error, buffer int) Job[T]
- func NewJobWithBufferAndRetry[T any](process func(ctx context.Context, result JobResultPipe[T]) error, ...) Job[T]
- func NewJobWithRetry[T any](process func(ctx context.Context, result JobResultPipe[T]) error, retries int) Job[T]
- type JobImpl
- func (ji *JobImpl[T]) CanRun() bool
- func (ji *JobImpl[T]) Close()
- func (ji *JobImpl[T]) F() func(ctx context.Context, result JobResultPipe[T]) error
- func (ji *JobImpl[T]) ID() string
- func (ji *JobImpl[T]) IncreaseRuns()
- func (ji *JobImpl[T]) ReadResult(ctx context.Context) (JobResult[T], bool)
- func (ji *JobImpl[T]) ResultBufferSize() int
- func (ji *JobImpl[T]) ResultChan() <-chan JobResult[T]
- func (ji *JobImpl[T]) Retries() int
- func (ji *JobImpl[T]) Runs() int
- func (ji *JobImpl[T]) WriteError(ctx context.Context, val error) error
- func (ji *JobImpl[T]) WriteResult(ctx context.Context, val T) error
- type JobResult
- type JobResultPipe
- type Jwks
- type Migration
- type MigrationPatch
- type OIDCMap
- type Option
- func WithBackgroundConsumer(deque func(_ context.Context) error) Option
- func WithConfig(config any) Option
- func WithDatastore() Option
- func WithDatastoreConnection(postgresqlConnection string, readOnly bool) Option
- func WithDatastoreConnectionWithName(name string, postgresqlConnection string, readOnly bool) Option
- func WithEnableGRPCServerReflection() Option
- func WithEnableTracing() Option
- func WithEnvironment(environment string) Option
- func WithGRPCPort(port string) Option
- func WithGRPCServer(grpcServer *grpc.Server) Option
- func WithGRPCServerListener(listener net.Listener) Option
- func WithHTTPHandler(h http.Handler) Option
- func WithHealthCheckPath(path string) Option
- func WithLogger() Option
- func WithMetricsReader(reader sdkmetrics.Reader) Option
- func WithName(name string) Option
- func WithNoopDriver() Option
- func WithPropagationTextMap(carrier propagation.TextMapPropagator) Option
- func WithRegisterEvents(events ...EventI) Option
- func WithRegisterPublisher(reference string, queueURL string) Option
- func WithRegisterSubscriber(reference string, queueURL string, handlers ...SubscribeWorker) Option
- func WithServerListener(listener net.Listener) Option
- func WithTraceExporter(exporter sdktrace.SpanExporter) Option
- func WithTraceLogsExporter(exporter sdklogs.Exporter) Option
- func WithTraceSampler(sampler sdktrace.Sampler) Option
- func WithTranslations(translationsFolder string, languages ...string) Option
- func WithVersion(version string) Option
- func WithWorkerPoolOptions(options ...WorkerPoolOption) Option
- type Pool
- type Publisher
- type Service
- func (s *Service) AddCleanupMethod(f func(ctx context.Context))
- func (s *Service) AddHealthCheck(checker Checker)
- func (s *Service) AddPreStartMethod(f func(ctx context.Context, s *Service))
- func (s *Service) AddPublisher(ctx context.Context, reference string, queueURL string) error
- func (s *Service) AddSubscriber(ctx context.Context, reference string, queueURL string, ...) error
- func (s *Service) Authenticate(ctx context.Context, jwtToken string, audience string, issuer string) (context.Context, error)
- func (s *Service) AuthenticationMiddleware(next http.Handler, audience string, issuer string) http.Handler
- func (s *Service) Bundle() *i18n.Bundle
- func (s *Service) Config() any
- func (s *Service) DB(ctx context.Context, readOnly bool) *gorm.DB
- func (s *Service) DBPool(name ...string) *Pool
- func (s *Service) DBWithName(ctx context.Context, name string, readOnly bool) *gorm.DB
- func (s *Service) DiscardPublisher(ctx context.Context, reference string) error
- func (s *Service) DiscardSubscriber(ctx context.Context, reference string) error
- func (s *Service) Emit(ctx context.Context, name string, payload any) error
- func (s *Service) Environment() string
- func (s *Service) GetPublisher(reference string) (Publisher, error)
- func (s *Service) GetSubscriber(reference string) (Subscriber, error)
- func (s *Service) H() http.Handler
- func (s *Service) HandleHealth(w http.ResponseWriter, _ *http.Request)
- func (s *Service) HandleHealthByDefault(w http.ResponseWriter, r *http.Request)
- func (s *Service) HealthCheckers() []Checker
- func (s *Service) Init(ctx context.Context, opts ...Option)
- func (s *Service) InvokeRestService(ctx context.Context, method string, endpointURL string, payload map[string]any, ...) (int, []byte, error)
- func (s *Service) InvokeRestServiceURLEncoded(ctx context.Context, method string, endpointURL string, payload url.Values, ...) (int, []byte, error)
- func (s *Service) JwtClient() map[string]any
- func (s *Service) JwtClientID() string
- func (s *Service) JwtClientSecret() string
- func (s *Service) LanguageHTTPMiddleware(next http.Handler) http.Handler
- func (s *Service) LanguageStreamInterceptor() grpc.StreamServerInterceptor
- func (s *Service) LanguageUnaryInterceptor() grpc.UnaryServerInterceptor
- func (s *Service) Log(ctx context.Context) *util.LogEntry
- func (s *Service) MigrateDatastore(ctx context.Context, migrationsDirPath string, migrations ...any) error
- func (s *Service) MigratePool(ctx context.Context, pool *Pool, migrationsDirPath string, migrations ...any) error
- func (s *Service) Name() string
- func (s *Service) NewMigrator(ctx context.Context, poolOpts ...*Pool) *DatastoreMigrator
- func (s *Service) Publish(ctx context.Context, reference string, payload any, ...) error
- func (s *Service) RegisterForJwt(ctx context.Context) error
- func (s *Service) RegisterForJwtWithParams(ctx context.Context, oauth2ServiceAdminHost string, clientName string, ...) (map[string]any, error)
- func (s *Service) Run(ctx context.Context, address string) error
- func (s *Service) SLog(ctx context.Context) *slog.Logger
- func (s *Service) SaveMigration(ctx context.Context, migrationPatches ...*MigrationPatch) error
- func (s *Service) SaveMigrationWithPool(ctx context.Context, pool *Pool, migrationPatches ...*MigrationPatch) error
- func (s *Service) SetJwtClient(jwtCli map[string]any)
- func (s *Service) Stop(ctx context.Context)
- func (s *Service) StreamAuthInterceptor(audience string, issuer string) grpc.StreamServerInterceptor
- func (s *Service) TLSEnabled() bool
- func (s *Service) Translate(ctx context.Context, request any, messageID string) string
- func (s *Service) TranslateWithMap(ctx context.Context, request any, messageID string, variables map[string]any) string
- func (s *Service) TranslateWithMapAndCount(ctx context.Context, request any, messageID string, variables map[string]any, ...) string
- func (s *Service) UnRegisterForJwt(ctx context.Context, oauth2ServiceAdminHost string, clientID string) error
- func (s *Service) UnaryAuthInterceptor(audience string, issuer string) grpc.UnaryServerInterceptor
- func (s *Service) Version() string
- type SubscribeWorker
- type Subscriber
- type SubscriberMetrics
- type SubscriberState
- type WorkerPool
- type WorkerPoolOption
- func WithConcurrency(concurrency int) WorkerPoolOption
- func WithPoolCount(count int) WorkerPoolOption
- func WithPoolDisablePurge(disable bool) WorkerPoolOption
- func WithPoolExpiryDuration(duration time.Duration) WorkerPoolOption
- func WithPoolLogger(logger *util.LogEntry) WorkerPoolOption
- func WithPoolNonblocking(nonblocking bool) WorkerPoolOption
- func WithPoolPanicHandler(handler func(any)) WorkerPoolOption
- func WithPoolPreAlloc(preAlloc bool) WorkerPoolOption
- func WithSinglePoolCapacity(capacity int) WorkerPoolOption
- type WorkerPoolOptions
Constants ¶
const ConstSystemScopeExternal = "system_ext"
const ConstSystemScopeInternal = "system_int"
const (
DefaultSlowQueryThreshold = 200 * time.Millisecond
)
const (
PostgresScheme = "postgres"
)
Constants for database drivers.
Variables ¶
var ErrHealthCheckFailed = errors.New("health check failed")
var ErrTLSPathsNotProvided = errors.New("TLS certificate path or key path not provided")
var ErrWorkerPoolResultChannelIsClosed = errors.New("worker job is already closed")
Functions ¶
func AuthHasAccess ¶ added in v1.4.0
AuthHasAccess binary check to confirm if subject can perform action specified.
func Cfg ¶ added in v1.39.0
Cfg extracts service configuration from the supplied context if any exist.
func ConfigFillEnv ¶ added in v1.43.7
ConfigFillEnv convenience method to fill a config object with environment data.
func ConfigFromEnv ¶ added in v1.29.0
ConfigFromEnv convenience method to process configs.
func ConfigLoadWithOIDC ¶ added in v1.30.0
ConfigLoadWithOIDC convenience method to process configs.
func ConfigToContext ¶ added in v1.25.4
ConfigToContext adds service configuration to the current supplied context.
func DBPropertiesToMap ¶ added in v1.2.6
DBPropertiesToMap converts the supplied db json content into a golang map.
func ErrorIsNoRows ¶ added in v1.33.0
ErrorIsNoRows validate if supplied error is because of record missing in DB.
func GetLoggingOptions ¶ added in v1.17.6
func IsTenancyChecksOnClaimSkipped ¶ added in v1.26.0
func JwtFromContext ¶ added in v1.17.3
JwtFromContext extracts authentication jwt from the supplied context if any exist.
func LanguageFromContext ¶ added in v1.48.0
LanguageFromContext extracts language from the supplied context if any exist.
func LanguageFromGrpcRequest ¶ added in v1.48.0
func LanguageFromMap ¶ added in v1.48.0
func LanguageToMap ¶ added in v1.48.0
func LangugageToContext ¶ added in v1.48.0
LangugageToContext adds language to the current supplied context.
func NewGrpcHealthServer ¶ added in v1.13.3
func NewGrpcHealthServer(service *Service) grpc_health_v1.HealthServer
func RecoveryHandlerFun ¶ added in v1.21.5
func SafeChannelWrite ¶ added in v1.21.6
SafeChannelWrite writes a value to a channel, returning an error if the context is canceled.
func SkipTenancyChecksOnClaims ¶ added in v1.26.0
SkipTenancyChecksOnClaims removes authentication claims from the current supplied context.
Types ¶
type AuthenticationClaims ¶ added in v1.0.7
type AuthenticationClaims struct { Ext map[string]any `json:"ext,omitempty"` TenantID string `json:"tenant_id,omitempty"` PartitionID string `json:"partition_id,omitempty"` AccessID string `json:"access_id,omitempty"` ContactID string `json:"contact_id,omitempty"` SessionID string `json:"session_id,omitempty"` DeviceID string `json:"device_id,omitempty"` ServiceName string `json:"service_name,omitempty"` Roles []string `json:"roles,omitempty"` jwt.RegisteredClaims }
AuthenticationClaims defines the structure for JWT claims, embedding jwt.StandardClaims to include standard fields like expiry time, and adding custom claims.
func ClaimsFromContext ¶ added in v1.0.7
func ClaimsFromContext(ctx context.Context) *AuthenticationClaims
ClaimsFromContext extracts authentication claims from the supplied context if any exist.
func ClaimsFromMap ¶ added in v1.1.0
func ClaimsFromMap(m map[string]string) *AuthenticationClaims
ClaimsFromMap extracts authentication claims from the supplied map if they exist.
func (*AuthenticationClaims) AsMetadata ¶ added in v1.0.7
func (a *AuthenticationClaims) AsMetadata() map[string]string
AsMetadata Creates a string map to be used as metadata in queue data.
func (*AuthenticationClaims) ClaimsToContext ¶ added in v1.0.7
func (a *AuthenticationClaims) ClaimsToContext(ctx context.Context) context.Context
ClaimsToContext adds authentication claims to the current supplied context.
func (*AuthenticationClaims) GetAccessID ¶ added in v1.43.0
func (a *AuthenticationClaims) GetAccessID() string
func (*AuthenticationClaims) GetContactID ¶ added in v1.43.0
func (a *AuthenticationClaims) GetContactID() string
func (*AuthenticationClaims) GetDeviceID ¶ added in v1.43.0
func (a *AuthenticationClaims) GetDeviceID() string
func (*AuthenticationClaims) GetPartitionID ¶ added in v1.43.0
func (a *AuthenticationClaims) GetPartitionID() string
func (*AuthenticationClaims) GetRoles ¶ added in v1.20.3
func (a *AuthenticationClaims) GetRoles() []string
func (*AuthenticationClaims) GetServiceName ¶ added in v1.30.3
func (a *AuthenticationClaims) GetServiceName() string
func (*AuthenticationClaims) GetSessionID ¶ added in v1.55.2
func (a *AuthenticationClaims) GetSessionID() string
func (*AuthenticationClaims) GetTenantID ¶ added in v1.43.0
func (a *AuthenticationClaims) GetTenantID() string
type BaseModel ¶
type BaseModel struct { ID string `gorm:"type:varchar(50);primary_key"` CreatedAt time.Time ModifiedAt time.Time Version uint `gorm:"DEFAULT 0"` TenantID string `gorm:"type:varchar(50);index:,composite:base_tenancy"` PartitionID string `gorm:"type:varchar(50);index:,composite:base_tenancy"` AccessID string `gorm:"type:varchar(50);index:,composite:base_tenancy"` DeletedAt gorm.DeletedAt `sql:"index"` }
BaseModel base table struct to be extended by other models.
func (*BaseModel) BeforeSave ¶ added in v1.2.9
BeforeSave Ensures we update a migrations time stamps.
func (*BaseModel) BeforeUpdate ¶
BeforeUpdate Updates time stamp every time we update status of a migration.
func (*BaseModel) CopyPartitionInfo ¶ added in v1.18.3
func (*BaseModel) GetVersion ¶ added in v1.7.3
type BaseModelI ¶
type BaseRepository ¶ added in v1.7.4
type BaseRepository struct {
// contains filtered or unexported fields
}
func NewBaseRepository ¶ added in v1.7.5
func NewBaseRepository(readDB *gorm.DB, writeDB *gorm.DB, instanceCreator func() BaseModelI) *BaseRepository
func (*BaseRepository) Delete ¶ added in v1.7.4
func (repo *BaseRepository) Delete(id string) error
func (*BaseRepository) GetAllBy ¶ added in v1.7.4
func (repo *BaseRepository) GetAllBy(properties map[string]any, result []BaseModelI) error
func (*BaseRepository) GetByID ¶ added in v1.7.4
func (repo *BaseRepository) GetByID(id string, result BaseModelI) error
func (*BaseRepository) GetLastestBy ¶ added in v1.7.4
func (repo *BaseRepository) GetLastestBy(properties map[string]any, result BaseModelI) error
func (*BaseRepository) Save ¶ added in v1.7.4
func (repo *BaseRepository) Save(instance BaseModelI) error
func (*BaseRepository) Search ¶ added in v1.7.4
func (repo *BaseRepository) Search(query string, searchFields []string, result []BaseModelI) error
type BaseRepositoryI ¶ added in v1.7.6
type BaseRepositoryI interface { GetByID(id string, result BaseModelI) error Delete(id string) error Save(instance BaseModelI) error }
type Checker ¶ added in v1.7.13
type Checker interface {
CheckHealth() error
}
Checker wraps the CheckHealth method.
CheckHealth returns nil if the resource is healthy, or a non-nil error if the resource is not healthy. CheckHealth must be safe to call from multiple goroutines.
type CheckerFunc ¶ added in v1.7.13
type CheckerFunc func() error
CheckerFunc is an adapter type to allow the use of ordinary functions as health checks. If f is a function with the appropriate signature, CheckerFunc(f) is a Checker that calls f.
func (CheckerFunc) CheckHealth ¶ added in v1.7.13
func (f CheckerFunc) CheckHealth() error
CheckHealth calls f().
type ConfigurationAuthorization ¶ added in v1.7.21
type ConfigurationCORS ¶ added in v1.16.0
type ConfigurationDatabase ¶ added in v1.8.0
type ConfigurationDatabase interface { GetDatabasePrimaryHostURL() []string GetDatabaseReplicaHostURL() []string DoDatabaseMigrate() bool SkipDefaultTransaction() bool PreferSimpleProtocol() bool GetMaxIdleConnections() int GetMaxOpenConnections() int GetMaxConnectionLifeTimeInSeconds() time.Duration GetDatabaseMigrationPath() string CanDatabaseTraceQueries() bool GetDatabaseSlowQueryLogThreshold() time.Duration }
type ConfigurationDefault ¶ added in v1.7.21
type ConfigurationDefault struct { LogLevel string `envDefault:"info" env:"LOG_LEVEL" yaml:"log_level"` LogFormat string `envDefault:"info" env:"LOG_FORMAT" yaml:"log_format"` LogTimeFormat string `envDefault:"2006-01-02T15:04:05Z07:00" env:"LOG_TIME_FORMAT" yaml:"log_time_format"` LogColored bool `envDefault:"true" env:"LOG_COLORED" yaml:"log_colored"` LogShowStackTrace bool `envDefault:"false" env:"LOG_SHOW_STACK_TRACE" yaml:"log_show_stack_trace"` ServiceName string `envDefault:"" env:"SERVICE_NAME" yaml:"service_name"` ServiceEnvironment string `envDefault:"" env:"SERVICE_ENVIRONMENT" yaml:"service_environment"` ServiceVersion string `envDefault:"" env:"SERVICE_VERSION" yaml:"service_version"` RunServiceSecurely bool `envDefault:"true" env:"RUN_SERVICE_SECURELY" yaml:"run_service_securely"` ServerPort string `envDefault:":7000" env:"PORT" yaml:"server_port"` HTTPServerPort string `envDefault:":8080" env:"HTTP_PORT" yaml:"http_server_port"` GrpcServerPort string `envDefault:":50051" env:"GRPC_PORT" yaml:"grpc_server_port"` // Worker pool settings WorkerPoolCPUFactorForWorkerCount int `envDefault:"10" env:"WORKER_POOL_CPU_FACTOR_FOR_WORKER_COUNT" yaml:"worker_pool_cpu_factor_for_worker_count"` WorkerPoolCapacity int `envDefault:"100" env:"WORKER_POOL_CAPACITY" yaml:"worker_pool_capacity"` WorkerPoolCount int `envDefault:"100" env:"WORKER_POOL_COUNT" yaml:"worker_pool_count"` WorkerPoolExpiryDuration string `envDefault:"1s" env:"WORKER_POOL_EXPIRY_DURATION" yaml:"worker_pool_expiry_duration"` CORSEnabled bool `envDefault:"false" env:"CORS_ENABLED" yaml:"cors_enabled"` CORSAllowCredentials bool `envDefault:"false" env:"CORS_ALLOW_CREDENTIALS" yaml:"cors_allow_credentials"` CORSAllowedHeaders []string `envDefault:"Authorization" env:"CORS_ALLOWED_HEADERS" yaml:"cors_allowed_headers"` CORSExposedHeaders []string `envDefault:"*" env:"CORS_EXPOSED_HEADERS" yaml:"cors_exposed_headers"` CORSAllowedOrigins []string `envDefault:"*" env:"CORS_ALLOWED_ORIGINS" yaml:"cors_allowed_origins"` CORSAllowedMethods []string `envDefault:"GET,HEAD,POST,PUT,OPTIONS" env:"CORS_ALLOWED_METHODS" yaml:"cors_allowed_methods"` CORSMaxAge int `envDefault:"3600" env:"CORS_MAX_AGE" yaml:"cors_max_age"` TLSCertificatePath string `env:"TLS_CERTIFICATE_PATH" yaml:"tls_certificate_path"` TLSCertificateKeyPath string `env:"TLS_CERTIFICATE_KEY_PATH" yaml:"tls_certificate_key_path"` Oauth2ServiceURI string `env:"OAUTH2_SERVICE_URI" yaml:"oauth2_service_uri"` Oauth2ServiceAdminURI string `env:"OAUTH2_SERVICE_ADMIN_URI" yaml:"oauth2_service_admin_uri"` Oauth2WellKnownOIDCPath string `env:"OAUTH2_WELL_KNOWN_OIDC_PATH" yaml:"oauth2_well_known_oidc_path" envDefault:".well-known/openid-configuration"` Oauth2WellKnownJwkData string `env:"OAUTH2_WELL_KNOWN_JWK_DATA" yaml:"oauth2_well_known_jwk_data"` Oauth2ServiceAudience string `env:"OAUTH2_SERVICE_AUDIENCE" yaml:"oauth2_service_audience"` Oauth2JwtVerifyAudience string `env:"OAUTH2_JWT_VERIFY_AUDIENCE" yaml:"oauth2_jwt_verify_audience"` Oauth2JwtVerifyIssuer string `env:"OAUTH2_JWT_VERIFY_ISSUER" yaml:"oauth2_jwt_verify_issuer"` Oauth2ServiceClientID string `env:"OAUTH2_SERVICE_CLIENT_ID" yaml:"oauth2_service_client_id"` Oauth2ServiceClientSecret string `env:"OAUTH2_SERVICE_CLIENT_SECRET" yaml:"oauth2_service_client_secret"` AuthorizationServiceReadURI string `env:"AUTHORIZATION_SERVICE_READ_URI" yaml:"authorization_service_read_uri"` AuthorizationServiceWriteURI string `env:"AUTHORIZATION_SERVICE_WRITE_URI" yaml:"authorization_service_write_uri"` DatabasePrimaryURL []string `env:"DATABASE_URL" yaml:"database_url"` DatabaseReplicaURL []string `env:"REPLICA_DATABASE_URL" yaml:"replica_database_url"` DatabaseMigrate bool `env:"DO_MIGRATION" yaml:"do_migration" envDefault:"false"` DatabaseMigrationPath string `env:"MIGRATION_PATH" yaml:"migration_path" envDefault:"./migrations/0001"` DatabaseSkipDefaultTransaction bool `env:"SKIP_DEFAULT_TRANSACTION" yaml:"skip_default_transaction" envDefault:"true"` DatabasePreferSimpleProtocol bool `env:"PREFER_SIMPLE_PROTOCOL" yaml:"prefer_simple_protocol" envDefault:"true"` DatabaseMaxIdleConnections int `envDefault:"2" env:"DATABASE_MAX_IDLE_CONNECTIONS" yaml:"database_max_idle_connections"` DatabaseMaxOpenConnections int `envDefault:"5" env:"DATABASE_MAX_OPEN_CONNECTIONS" yaml:"database_max_open_connections"` DatabaseMaxConnectionLifeTimeSeconds int `envDefault:"300" env:"DATABASE_MAX_CONNECTION_LIFE_TIME_IN_SECONDS" yaml:"database_max_connection_life_time_seconds"` DatabaseTraceQueries bool `envDefault:"false" env:"DATABASE_LOG_QUERIES" yaml:"database_log_queries"` DatabaseSlowQueryLogThreshold string `envDefault:"200ms" env:"DATABASE_SLOW_QUERY_THRESHOLD" yaml:"database_slow_query_threshold"` EventsQueueName string `envDefault:"frame.events.internal_._queue" env:"EVENTS_QUEUE_NAME" yaml:"events_queue_name"` EventsQueueURL string `envDefault:"mem://frame.events.internal_._queue" env:"EVENTS_QUEUE_URL" yaml:"events_queue_url"` // contains filtered or unexported fields }
func (*ConfigurationDefault) CanDatabaseTraceQueries ¶ added in v1.41.0
func (c *ConfigurationDefault) CanDatabaseTraceQueries() bool
func (*ConfigurationDefault) DoDatabaseMigrate ¶ added in v1.8.0
func (c *ConfigurationDefault) DoDatabaseMigrate() bool
func (*ConfigurationDefault) GetAuthorizationServiceReadURI ¶ added in v1.7.21
func (c *ConfigurationDefault) GetAuthorizationServiceReadURI() string
func (*ConfigurationDefault) GetAuthorizationServiceWriteURI ¶ added in v1.7.21
func (c *ConfigurationDefault) GetAuthorizationServiceWriteURI() string
func (*ConfigurationDefault) GetCORSAllowedHeaders ¶ added in v1.16.0
func (c *ConfigurationDefault) GetCORSAllowedHeaders() []string
func (*ConfigurationDefault) GetCORSAllowedMethods ¶ added in v1.16.0
func (c *ConfigurationDefault) GetCORSAllowedMethods() []string
func (*ConfigurationDefault) GetCORSAllowedOrigins ¶ added in v1.16.0
func (c *ConfigurationDefault) GetCORSAllowedOrigins() []string
func (*ConfigurationDefault) GetCORSExposedHeaders ¶ added in v1.20.2
func (c *ConfigurationDefault) GetCORSExposedHeaders() []string
func (*ConfigurationDefault) GetCORSMaxAge ¶ added in v1.20.2
func (c *ConfigurationDefault) GetCORSMaxAge() int
func (*ConfigurationDefault) GetCPUFactor ¶ added in v1.50.0
func (c *ConfigurationDefault) GetCPUFactor() int
func (*ConfigurationDefault) GetCapacity ¶ added in v1.50.0
func (c *ConfigurationDefault) GetCapacity() int
func (*ConfigurationDefault) GetCount ¶ added in v1.50.0
func (c *ConfigurationDefault) GetCount() int
func (*ConfigurationDefault) GetDatabaseMigrationPath ¶ added in v1.8.0
func (c *ConfigurationDefault) GetDatabaseMigrationPath() string
func (*ConfigurationDefault) GetDatabasePrimaryHostURL ¶ added in v1.8.5
func (c *ConfigurationDefault) GetDatabasePrimaryHostURL() []string
func (*ConfigurationDefault) GetDatabaseReplicaHostURL ¶ added in v1.8.5
func (c *ConfigurationDefault) GetDatabaseReplicaHostURL() []string
func (*ConfigurationDefault) GetDatabaseSlowQueryLogThreshold ¶ added in v1.41.0
func (c *ConfigurationDefault) GetDatabaseSlowQueryLogThreshold() time.Duration
func (*ConfigurationDefault) GetEventsQueueName ¶ added in v1.8.18
func (c *ConfigurationDefault) GetEventsQueueName() string
func (*ConfigurationDefault) GetEventsQueueURL ¶ added in v1.43.0
func (c *ConfigurationDefault) GetEventsQueueURL() string
func (*ConfigurationDefault) GetExpiryDuration ¶ added in v1.50.0
func (c *ConfigurationDefault) GetExpiryDuration() time.Duration
func (*ConfigurationDefault) GetMaxConnectionLifeTimeInSeconds ¶ added in v1.24.0
func (c *ConfigurationDefault) GetMaxConnectionLifeTimeInSeconds() time.Duration
func (*ConfigurationDefault) GetMaxIdleConnections ¶ added in v1.24.0
func (c *ConfigurationDefault) GetMaxIdleConnections() int
func (*ConfigurationDefault) GetMaxOpenConnections ¶ added in v1.24.0
func (c *ConfigurationDefault) GetMaxOpenConnections() int
func (*ConfigurationDefault) GetOauth2AuthorizationEndpoint ¶ added in v1.30.0
func (c *ConfigurationDefault) GetOauth2AuthorizationEndpoint() string
func (*ConfigurationDefault) GetOauth2EndSessionEndpoint ¶ added in v1.30.0
func (c *ConfigurationDefault) GetOauth2EndSessionEndpoint() string
func (*ConfigurationDefault) GetOauth2Issuer ¶ added in v1.30.0
func (c *ConfigurationDefault) GetOauth2Issuer() string
func (*ConfigurationDefault) GetOauth2RegistrationEndpoint ¶ added in v1.30.0
func (c *ConfigurationDefault) GetOauth2RegistrationEndpoint() string
func (*ConfigurationDefault) GetOauth2RevocationEndpoint ¶ added in v1.30.0
func (c *ConfigurationDefault) GetOauth2RevocationEndpoint() string
func (*ConfigurationDefault) GetOauth2ServiceAdminURI ¶ added in v1.8.5
func (c *ConfigurationDefault) GetOauth2ServiceAdminURI() string
func (*ConfigurationDefault) GetOauth2ServiceAudience ¶ added in v1.8.5
func (c *ConfigurationDefault) GetOauth2ServiceAudience() string
func (*ConfigurationDefault) GetOauth2ServiceClientID ¶ added in v1.55.1
func (c *ConfigurationDefault) GetOauth2ServiceClientID() string
func (*ConfigurationDefault) GetOauth2ServiceClientSecret ¶ added in v1.8.5
func (c *ConfigurationDefault) GetOauth2ServiceClientSecret() string
func (*ConfigurationDefault) GetOauth2ServiceURI ¶ added in v1.7.21
func (c *ConfigurationDefault) GetOauth2ServiceURI() string
func (*ConfigurationDefault) GetOauth2TokenEndpoint ¶ added in v1.30.0
func (c *ConfigurationDefault) GetOauth2TokenEndpoint() string
func (*ConfigurationDefault) GetOauth2UserInfoEndpoint ¶ added in v1.30.0
func (c *ConfigurationDefault) GetOauth2UserInfoEndpoint() string
func (*ConfigurationDefault) GetOauth2WellKnownJwk ¶ added in v1.30.0
func (c *ConfigurationDefault) GetOauth2WellKnownJwk() string
func (*ConfigurationDefault) GetOauth2WellKnownJwkData ¶ added in v1.30.0
func (c *ConfigurationDefault) GetOauth2WellKnownJwkData() string
func (*ConfigurationDefault) GetOauth2WellKnownOIDC ¶ added in v1.30.0
func (c *ConfigurationDefault) GetOauth2WellKnownOIDC() string
func (*ConfigurationDefault) GrpcPort ¶ added in v1.13.0
func (c *ConfigurationDefault) GrpcPort() string
func (*ConfigurationDefault) HTTPPort ¶ added in v1.43.0
func (c *ConfigurationDefault) HTTPPort() string
func (*ConfigurationDefault) IsCORSAllowCredentials ¶ added in v1.19.8
func (c *ConfigurationDefault) IsCORSAllowCredentials() bool
func (*ConfigurationDefault) IsCORSEnabled ¶ added in v1.16.0
func (c *ConfigurationDefault) IsCORSEnabled() bool
func (*ConfigurationDefault) IsRunSecurely ¶ added in v1.25.4
func (c *ConfigurationDefault) IsRunSecurely() bool
func (*ConfigurationDefault) LoadOauth2Config ¶ added in v1.30.0
func (c *ConfigurationDefault) LoadOauth2Config(ctx context.Context) error
func (*ConfigurationDefault) LoggingColored ¶ added in v1.41.0
func (c *ConfigurationDefault) LoggingColored() bool
func (*ConfigurationDefault) LoggingFormat ¶ added in v1.41.0
func (c *ConfigurationDefault) LoggingFormat() string
func (*ConfigurationDefault) LoggingLevel ¶ added in v1.19.1
func (c *ConfigurationDefault) LoggingLevel() string
func (*ConfigurationDefault) LoggingLevelIsDebug ¶ added in v1.19.1
func (c *ConfigurationDefault) LoggingLevelIsDebug() bool
func (*ConfigurationDefault) LoggingShowStackTrace ¶ added in v1.41.2
func (c *ConfigurationDefault) LoggingShowStackTrace() bool
func (*ConfigurationDefault) LoggingTimeFormat ¶ added in v1.41.0
func (c *ConfigurationDefault) LoggingTimeFormat() string
func (*ConfigurationDefault) Port ¶ added in v1.13.0
func (c *ConfigurationDefault) Port() string
func (*ConfigurationDefault) PreferSimpleProtocol ¶ added in v1.31.0
func (c *ConfigurationDefault) PreferSimpleProtocol() bool
func (*ConfigurationDefault) SetTLSCertAndKeyPath ¶ added in v1.13.0
func (c *ConfigurationDefault) SetTLSCertAndKeyPath(certificatePath, certificateKeyPath string)
func (*ConfigurationDefault) SkipDefaultTransaction ¶ added in v1.23.3
func (c *ConfigurationDefault) SkipDefaultTransaction() bool
func (*ConfigurationDefault) TLSCertKeyPath ¶ added in v1.13.0
func (c *ConfigurationDefault) TLSCertKeyPath() string
func (*ConfigurationDefault) TLSCertPath ¶ added in v1.13.0
func (c *ConfigurationDefault) TLSCertPath() string
type ConfigurationEvents ¶ added in v1.8.18
type ConfigurationLogLevel ¶ added in v1.19.1
type ConfigurationOAUTH2 ¶ added in v1.7.21
type ConfigurationOAUTH2 interface { LoadOauth2Config(ctx context.Context) error GetOauth2WellKnownOIDC() string GetOauth2WellKnownJwk() string GetOauth2WellKnownJwkData() string GetOauth2Issuer() string GetOauth2AuthorizationEndpoint() string GetOauth2RegistrationEndpoint() string GetOauth2TokenEndpoint() string GetOauth2UserInfoEndpoint() string GetOauth2RevocationEndpoint() string GetOauth2EndSessionEndpoint() string GetOauth2ServiceURI() string GetOauth2ServiceClientID() string GetOauth2ServiceClientSecret() string GetOauth2ServiceAudience() string GetOauth2ServiceAdminURI() string }
type ConfigurationPorts ¶ added in v1.14.0
type ConfigurationSecurity ¶ added in v1.25.4
type ConfigurationSecurity interface {
IsRunSecurely() bool
}
type ConfigurationTLS ¶ added in v1.13.0
type ConfigurationWorkerPool ¶ added in v1.50.0
type DataSource ¶ added in v1.50.0
type DataSource string
A DataSource for conveniently handling a URI connection string.
func (DataSource) ChangePort ¶ added in v1.54.8
func (d DataSource) ChangePort(newPort string) (DataSource, error)
func (DataSource) DelPath ¶ added in v1.50.0
func (d DataSource) DelPath() DataSource
func (DataSource) ExtendPath ¶ added in v1.50.0
func (d DataSource) ExtendPath(epath ...string) DataSource
func (DataSource) ExtendQuery ¶ added in v1.50.0
func (d DataSource) ExtendQuery(key, value string) DataSource
func (DataSource) GetQuery ¶ added in v1.50.0
func (d DataSource) GetQuery(key string) string
func (DataSource) IsCache ¶ added in v1.50.0
func (d DataSource) IsCache() bool
func (DataSource) IsDB ¶ added in v1.50.0
func (d DataSource) IsDB() bool
func (DataSource) IsMem ¶ added in v1.50.0
func (d DataSource) IsMem() bool
func (DataSource) IsMySQL ¶ added in v1.50.0
func (d DataSource) IsMySQL() bool
func (DataSource) IsNats ¶ added in v1.50.0
func (d DataSource) IsNats() bool
func (DataSource) IsPostgres ¶ added in v1.50.0
func (d DataSource) IsPostgres() bool
func (DataSource) IsQueue ¶ added in v1.50.0
func (d DataSource) IsQueue() bool
func (DataSource) IsRedis ¶ added in v1.50.0
func (d DataSource) IsRedis() bool
func (DataSource) PrefixPath ¶ added in v1.50.0
func (d DataSource) PrefixPath(prefix string) DataSource
func (DataSource) RemoveQuery ¶ added in v1.50.0
func (d DataSource) RemoveQuery(key ...string) DataSource
func (DataSource) String ¶ added in v1.50.0
func (d DataSource) String() string
func (DataSource) SuffixPath ¶ added in v1.50.0
func (d DataSource) SuffixPath(suffix string) DataSource
func (DataSource) ToArray ¶ added in v1.50.0
func (d DataSource) ToArray() []DataSource
func (DataSource) WithPassword ¶ added in v1.50.0
func (d DataSource) WithPassword(password string) (DataSource, error)
func (DataSource) WithPath ¶ added in v1.50.0
func (d DataSource) WithPath(path string) (DataSource, error)
func (DataSource) WithPathSuffix ¶ added in v1.50.0
func (d DataSource) WithPathSuffix(suffix string) (DataSource, error)
func (DataSource) WithQuery ¶ added in v1.50.0
func (d DataSource) WithQuery(query string) (DataSource, error)
func (DataSource) WithUser ¶ added in v1.50.0
func (d DataSource) WithUser(user string) (DataSource, error)
func (DataSource) WithUserAndPassword ¶ added in v1.50.0
func (d DataSource) WithUserAndPassword(userName, password string) (DataSource, error)
type DatastoreMigrator ¶ added in v1.43.0
type DatastoreMigrator struct {
// contains filtered or unexported fields
}
func (*DatastoreMigrator) ApplyNewMigrations ¶ added in v1.43.0
func (m *DatastoreMigrator) ApplyNewMigrations(ctx context.Context) error
func (*DatastoreMigrator) DB ¶ added in v1.43.0
func (m *DatastoreMigrator) DB(ctx context.Context) *gorm.DB
func (*DatastoreMigrator) SaveMigrationString ¶ added in v1.43.0
type EventI ¶ added in v1.6.1
type EventI interface { // Name represents the unique human readable id of the event that is used to pick it from the registry // or route follow up processing for system to processFunc using this particular event Name() string // PayloadType determines the type of payload the event uses. This is useful for decoding queue data. PayloadType() any // Validate enables automatic validation of payload supplied to the event without handling it in the execute block Validate(ctx context.Context, payload any) error // Execute performs all the logic required to action a step in the sequence of events required to achieve the end goal. Execute(ctx context.Context, payload any) error }
EventI an interface to represent a system event. All logic of an event is handled in the execute task and can also emit other events into the system or if they don't emit an event the processFunc is deemed complete.
type JSONMap ¶ added in v1.49.0
type JSONMap map[string]interface{}
JSONMap is a GORM-compatible map[string]interface{} that stores JSONB/JSON in a DB.
func DBPropertiesFromMap ¶ added in v1.2.6
DBPropertiesFromMap converts a map into a JSONMap object.
func (*JSONMap) GormDBDataType ¶ added in v1.49.0
GormDBDataType returns the dialect-specific database column type.
func (*JSONMap) GormDataType ¶ added in v1.49.0
GormDataType returns the common GORM data type.
func (*JSONMap) GormValue ¶ added in v1.49.0
GormValue optimizes how values are rendered in SQL for specific dialects.
func (*JSONMap) MarshalJSON ¶ added in v1.49.0
MarshalJSON customizes the JSON encoding.
func (*JSONMap) Scan ¶ added in v1.49.0
Scan implements the sql.Scanner interface for database deserialization.
func (*JSONMap) UnmarshalJSON ¶ added in v1.49.0
UnmarshalJSON deserializes JSON into the map.
type JSONWebKeys ¶ added in v1.1.7
type Job ¶ added in v1.9.1
type Job[T any] interface { JobResultPipe[T] F() func(ctx context.Context, result JobResultPipe[T]) error ID() string CanRun() bool Retries() int Runs() int IncreaseRuns() }
Job represents a task that can be executed and produce results of type T.
func NewJobWithBuffer ¶ added in v1.28.0
func NewJobWithBuffer[T any](process func(ctx context.Context, result JobResultPipe[T]) error, buffer int) Job[T]
NewJobWithBuffer creates a new job with a specified buffer size.
func NewJobWithBufferAndRetry ¶ added in v1.28.0
func NewJobWithBufferAndRetry[T any]( process func(ctx context.Context, result JobResultPipe[T]) error, resultBufferSize, retries int, ) Job[T]
NewJobWithBufferAndRetry creates a new job with specified buffer size and retry count.
func NewJobWithRetry ¶ added in v1.28.0
func NewJobWithRetry[T any](process func(ctx context.Context, result JobResultPipe[T]) error, retries int) Job[T]
NewJobWithRetry creates a new job with a specified retry count.
type JobImpl ¶ added in v1.9.1
type JobImpl[T any] struct { // contains filtered or unexported fields }
JobImpl is the concrete implementation of a Job.
func (*JobImpl[T]) F ¶ added in v1.15.2
func (ji *JobImpl[T]) F() func(ctx context.Context, result JobResultPipe[T]) error
func (*JobImpl[T]) IncreaseRuns ¶ added in v1.23.0
func (ji *JobImpl[T]) IncreaseRuns()
func (*JobImpl[T]) ReadResult ¶ added in v1.23.0
func (*JobImpl[T]) ResultBufferSize ¶ added in v1.22.0
func (*JobImpl[T]) ResultChan ¶ added in v1.22.0
func (*JobImpl[T]) WriteError ¶ added in v1.28.1
type JobResult ¶ added in v1.28.0
JobResult represents the result of a job execution, which can be either a value of type T or an error.
func ErrorResult ¶ added in v1.51.0
type JobResultPipe ¶ added in v1.23.0
type JobResultPipe[T any] interface { ResultBufferSize() int ResultChan() <-chan JobResult[T] WriteError(ctx context.Context, val error) error WriteResult(ctx context.Context, val T) error ReadResult(ctx context.Context) (JobResult[T], bool) Close() }
JobResultPipe is a channel-based pipeline for passing job results.
type Jwks ¶ added in v1.1.7
type Jwks struct {
Keys []JSONWebKeys `json:"keys"`
}
type Migration ¶
type Migration struct { BaseModel Name string `gorm:"type:text;uniqueIndex:idx_migrations_name"` Patch string `gorm:"type:text"` RevertPatch string `gorm:"type:text"` AppliedAt sql.NullTime }
Migration Our simple table holding all the migration data.
type MigrationPatch ¶ added in v1.31.7
type Option ¶
func WithBackgroundConsumer ¶ added in v1.43.0
WithBackgroundConsumer sets a background consumer function for the worker pool.
func WithConfig ¶ added in v1.42.0
WithConfig Option that helps to specify or override the configuration object of our service.
func WithDatastore ¶ added in v1.42.0
func WithDatastore() Option
func WithDatastoreConnection ¶ added in v1.42.0
WithDatastoreConnection Option method to store a connection that will be utilized when connecting to the database.
func WithDatastoreConnectionWithName ¶ added in v1.42.0
func WithEnableGRPCServerReflection ¶ added in v1.43.0
func WithEnableGRPCServerReflection() Option
WithEnableGRPCServerReflection enables gRPC server reflection.
func WithEnableTracing ¶ added in v1.54.14
func WithEnableTracing() Option
WithEnableTracing disable tracing for the service.
func WithEnvironment ¶ added in v1.55.1
WithEnvironment specifies the environment the service will utilize.
func WithGRPCPort ¶ added in v1.43.0
WithGRPCPort specifies the gRPC port for the server to bind to.
func WithGRPCServer ¶ added in v1.43.0
WithGRPCServer specifies an instantiated gRPC server with an implementation that can be utilized to handle incoming requests.
func WithGRPCServerListener ¶ added in v1.43.0
WithGRPCServerListener specifies a user-preferred gRPC listener instead of the default provided one.
func WithHTTPHandler ¶ added in v1.43.0
WithHTTPHandler specifies an HTTP handlers that can be used to handle inbound HTTP requests.
func WithHealthCheckPath ¶ added in v1.42.0
WithHealthCheckPath Option checks that the system is up and running.
func WithLogger ¶ added in v1.38.0
func WithLogger() Option
WithLogger Option that helps with initialization of our internal dbLogger.
func WithMetricsReader ¶ added in v1.50.1
func WithMetricsReader(reader sdkmetrics.Reader) Option
WithMetricsReader specifies the metrics reader for the service.
func WithNoopDriver ¶ added in v1.42.0
func WithNoopDriver() Option
WithNoopDriver uses a no-op driver, mostly useful when writing tests against the frame service.
func WithPropagationTextMap ¶ added in v1.50.1
func WithPropagationTextMap(carrier propagation.TextMapPropagator) Option
WithPropagationTextMap specifies the trace baggage carrier exporter to use.
func WithRegisterEvents ¶ added in v1.42.0
WithRegisterEvents registers events for the service. All events are unique and shouldn't share a name otherwise the last one registered will take precedence.
func WithRegisterPublisher ¶ added in v1.42.0
WithRegisterPublisher Option to register publishing path referenced within the system.
func WithRegisterSubscriber ¶ added in v1.42.0
func WithRegisterSubscriber(reference string, queueURL string, handlers ...SubscribeWorker) Option
WithRegisterSubscriber Option to register a new subscription handlers.
func WithServerListener ¶ added in v1.42.0
WithServerListener specifies a user-preferred listener instead of the default provided one.
func WithTraceExporter ¶ added in v1.42.0
func WithTraceExporter(exporter sdktrace.SpanExporter) Option
WithTraceExporter specifies the trace exporter to use.
func WithTraceLogsExporter ¶ added in v1.50.1
WithTraceLogsExporter specifies the trace logs exporter for the service.
func WithTraceSampler ¶ added in v1.42.0
WithTraceSampler specifies the trace sampler to use.
func WithTranslations ¶ added in v1.42.0
WithTranslations Option to initialize/loadOIDC different language packs.
func WithVersion ¶ added in v1.55.1
WithVersion specifies the version the service will utilize.
func WithWorkerPoolOptions ¶ added in v1.43.0
func WithWorkerPoolOptions(options ...WorkerPoolOption) Option
WithWorkerPoolOptions provides a way to set custom options for the ants worker pool. Renamed from WithAntsOptions and changed parameter type.
type Pool ¶ added in v1.31.1
type Pool struct {
// contains filtered or unexported fields
}
func (*Pool) CanMigrate ¶ added in v1.31.3
func (*Pool) CheckHealth ¶ added in v1.31.1
CheckHealth iterates all known DBs, pings them, and updates pool membership accordingly.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service framework struct to hold together all application components An instance of this type scoped to stay for the lifetime of the application. It is pushed and pulled from contexts to make it easy to pass around.
func NewService ¶
NewService creates a new instance of Service with the name and supplied options. Internally it calls NewServiceWithContext and creates a background context for use.
func NewServiceWithContext ¶ added in v1.25.3
func NewServiceWithContext(ctx context.Context, name string, opts ...Option) (context.Context, *Service)
NewServiceWithContext creates a new instance of Service with context, name and supplied options It is used together with the Init option to setup components of a service that is not yet running.
func (*Service) AddCleanupMethod ¶
AddCleanupMethod Adds user defined functions to be run just before completely stopping the service. These are responsible for properly and gracefully stopping active components.
func (*Service) AddHealthCheck ¶
AddHealthCheck Adds health checks that are run periodically to ascertain the system is ok The arguments are implementations of the checker interface and should work with just about any system that is given to them.
func (*Service) AddPreStartMethod ¶ added in v1.1.3
AddPreStartMethod Adds user defined functions that can be run just before the service starts receiving requests but is fully initialized.
func (*Service) AddPublisher ¶ added in v1.16.2
func (*Service) AddSubscriber ¶ added in v1.35.0
func (*Service) Authenticate ¶ added in v1.8.14
func (*Service) AuthenticationMiddleware ¶ added in v1.7.17
func (s *Service) AuthenticationMiddleware(next http.Handler, audience string, issuer string) http.Handler
AuthenticationMiddleware is an HTTP middleware that verifies and extracts authentication data supplied in a JWT as an Authorization bearer token.
func (*Service) Bundle ¶ added in v1.0.6
Bundle Access the translation bundle instatiated in the system.
func (*Service) DBWithName ¶ added in v1.31.0
func (*Service) DiscardPublisher ¶ added in v1.37.0
func (*Service) DiscardSubscriber ¶ added in v1.37.0
func (*Service) Environment ¶ added in v1.7.13
Environment gets the runtime environment of the service.
func (*Service) GetPublisher ¶ added in v1.35.0
func (*Service) GetSubscriber ¶ added in v1.35.0
func (s *Service) GetSubscriber(reference string) (Subscriber, error)
func (*Service) HandleHealth ¶ added in v1.12.5
func (s *Service) HandleHealth(w http.ResponseWriter, _ *http.Request)
HandleHealth returns 200 if it is healthy, 500 otherwise.
func (*Service) HandleHealthByDefault ¶ added in v1.12.6
func (s *Service) HandleHealthByDefault(w http.ResponseWriter, r *http.Request)
HandleHealthByDefault returns 200 if it is healthy, 500 when there is an err or 404 otherwise.
func (*Service) HealthCheckers ¶ added in v1.7.13
func (*Service) Init ¶ added in v1.0.4
Init evaluates the options provided as arguments and supplies them to the service object.
func (*Service) InvokeRestService ¶ added in v1.0.15
func (s *Service) InvokeRestService(ctx context.Context, method string, endpointURL string, payload map[string]any, headers map[string][]string) (int, []byte, error)
InvokeRestService convenience method to call a http endpoint and utilize the raw results.
func (*Service) InvokeRestServiceURLEncoded ¶ added in v1.43.0
func (s *Service) InvokeRestServiceURLEncoded(ctx context.Context, method string, endpointURL string, payload url.Values, headers map[string]string) (int, []byte, error)
InvokeRestServiceURLEncoded sends an HTTP request to the specified endpoint with a URL-encoded payload.
func (*Service) JwtClient ¶ added in v1.10.0
JwtClient gets the authenticated jwt client if configured at startup.
func (*Service) JwtClientID ¶ added in v1.10.0
JwtClientID gets the authenticated JWT client ID if configured at startup.
func (*Service) JwtClientSecret ¶ added in v1.10.1
JwtClientSecret gets the authenticated jwt client if configured at startup.
func (*Service) LanguageHTTPMiddleware ¶ added in v1.48.0
LanguageHTTPMiddleware is an HTTP middleware that extracts language information and sets it in the context.
func (*Service) LanguageStreamInterceptor ¶ added in v1.48.0
func (s *Service) LanguageStreamInterceptor() grpc.StreamServerInterceptor
LanguageStreamInterceptor A language extractor that will extract .
func (*Service) LanguageUnaryInterceptor ¶ added in v1.48.0
func (s *Service) LanguageUnaryInterceptor() grpc.UnaryServerInterceptor
LanguageUnaryInterceptor Simple grpc interceptor to extract the language supplied via metadata.
func (*Service) MigrateDatastore ¶
func (s *Service) MigrateDatastore(ctx context.Context, migrationsDirPath string, migrations ...any) error
MigrateDatastore finds missing migrations and records them in the database.
func (*Service) MigratePool ¶ added in v1.31.7
func (s *Service) MigratePool(ctx context.Context, pool *Pool, migrationsDirPath string, migrations ...any) error
MigratePool finds missing migrations and records them in the database.
func (*Service) Name ¶ added in v1.4.0
Name gets the name of the service. Its the first argument used when NewService is called.
func (*Service) NewMigrator ¶ added in v1.43.0
func (s *Service) NewMigrator(ctx context.Context, poolOpts ...*Pool) *DatastoreMigrator
func (*Service) Publish ¶
func (s *Service) Publish(ctx context.Context, reference string, payload any, headers ...map[string]string) error
Publish Queue method to write a new message into the queue pre initialized with the supplied reference.
func (*Service) RegisterForJwt ¶ added in v1.10.1
RegisterForJwt function hooks in jwt client registration to make sure service is authenticated.
func (*Service) RegisterForJwtWithParams ¶ added in v1.8.1
func (s *Service) RegisterForJwtWithParams(ctx context.Context, oauth2ServiceAdminHost string, clientName string, clientID string, clientSecret string, scope string, audienceList []string, metadata map[string]string) (map[string]any, error)
RegisterForJwtWithParams registers for JWT with the given parameters. This is useful for situations where one may need to register external applications for access token generation.
func (*Service) SaveMigration ¶ added in v1.31.7
func (s *Service) SaveMigration(ctx context.Context, migrationPatches ...*MigrationPatch) error
func (*Service) SaveMigrationWithPool ¶ added in v1.31.7
func (*Service) SetJwtClient ¶ added in v1.43.0
SetJwtClient sets the authenticated jwt client.
func (*Service) Stop ¶
Stop Used to gracefully run clean up methods ensuring all requests that were being handled are completed well without interuptions.
func (*Service) StreamAuthInterceptor ¶ added in v1.7.17
func (s *Service) StreamAuthInterceptor(audience string, issuer string) grpc.StreamServerInterceptor
StreamAuthInterceptor An authentication claims extractor that will always verify the information flowing in the streams as true jwt claims.
func (*Service) TLSEnabled ¶ added in v1.13.0
func (*Service) Translate ¶ added in v1.1.9
Translate performs a quick translation based on the supplied message id.
func (*Service) TranslateWithMap ¶ added in v1.1.9
func (s *Service) TranslateWithMap( ctx context.Context, request any, messageID string, variables map[string]any, ) string
TranslateWithMap performs a translation with variables based on the supplied message id.
func (*Service) TranslateWithMapAndCount ¶ added in v1.1.9
func (s *Service) TranslateWithMapAndCount( ctx context.Context, request any, messageID string, variables map[string]any, count int, ) string
TranslateWithMapAndCount performs a translation with variables based on the supplied message id and can pluralize.
func (*Service) UnRegisterForJwt ¶ added in v1.8.9
func (s *Service) UnRegisterForJwt(ctx context.Context, oauth2ServiceAdminHost string, clientID string) error
UnRegisterForJwt utilizing client id we de register external applications for access token generation.
func (*Service) UnaryAuthInterceptor ¶ added in v1.7.17
func (s *Service) UnaryAuthInterceptor(audience string, issuer string) grpc.UnaryServerInterceptor
UnaryAuthInterceptor Simple grpc interceptor to extract the jwt supplied via authorization bearer token and verify the authentication claims in the token.
type SubscribeWorker ¶
type Subscriber ¶ added in v1.35.0
type SubscriberMetrics ¶ added in v1.46.0
type SubscriberMetrics struct { ActiveMessages *atomic.Int64 // Currently active messages being processed LastActivity *atomic.Int64 // Last activity timestamp in UnixNano ProcessingTime *atomic.Int64 // Total processing time in nanoseconds MessageCount *atomic.Int64 // Total messages processed ErrorCount *atomic.Int64 // Total number of errors encountered }
SubscriberMetrics tracks operational metrics for a subscriber.
func (*SubscriberMetrics) AverageProcessingTime ¶ added in v1.46.0
func (m *SubscriberMetrics) AverageProcessingTime() time.Duration
AverageProcessingTime returns the average time spent processing messages.
func (*SubscriberMetrics) IdleTime ¶ added in v1.46.0
func (m *SubscriberMetrics) IdleTime(state SubscriberState) time.Duration
IdleTime returns the duration since last activity if the subscriber is idle.
func (*SubscriberMetrics) IsIdle ¶ added in v1.46.0
func (m *SubscriberMetrics) IsIdle(state SubscriberState) bool
IsIdle and is in waiting state.
type SubscriberState ¶ added in v1.46.0
type SubscriberState int
const ( SubscriberStateWaiting SubscriberState = iota SubscriberStateProcessing SubscriberStateInError )
type WorkerPool ¶ added in v1.43.0
WorkerPool defines the common methods for worker pool operations. This allows the Service to hold either a single ants.Pool or an ants.MultiPool.
type WorkerPoolOption ¶ added in v1.43.0
type WorkerPoolOption func(*WorkerPoolOptions)
WorkerPoolOption defines a function that configures worker pool options.
func WithConcurrency ¶ added in v1.9.1
func WithConcurrency(concurrency int) WorkerPoolOption
WithConcurrency sets the concurrency for the worker pool.
func WithPoolCount ¶ added in v1.43.0
func WithPoolCount(count int) WorkerPoolOption
WithPoolCount sets the number of worker pools.
func WithPoolDisablePurge ¶ added in v1.43.0
func WithPoolDisablePurge(disable bool) WorkerPoolOption
WithPoolDisablePurge disables the purge mechanism in the pool.
func WithPoolExpiryDuration ¶ added in v1.43.0
func WithPoolExpiryDuration(duration time.Duration) WorkerPoolOption
WithPoolExpiryDuration sets the expiry duration for workers.
func WithPoolLogger ¶ added in v1.43.0
func WithPoolLogger(logger *util.LogEntry) WorkerPoolOption
WithPoolLogger sets a logger for the pool.
func WithPoolNonblocking ¶ added in v1.43.0
func WithPoolNonblocking(nonblocking bool) WorkerPoolOption
WithPoolNonblocking sets the non-blocking option for the pool.
func WithPoolPanicHandler ¶ added in v1.43.0
func WithPoolPanicHandler(handler func(any)) WorkerPoolOption
WithPoolPanicHandler sets a panic handlers for the pool.
func WithPoolPreAlloc ¶ added in v1.43.0
func WithPoolPreAlloc(preAlloc bool) WorkerPoolOption
WithPoolPreAlloc pre-allocates memory for the pool.
func WithSinglePoolCapacity ¶ added in v1.43.0
func WithSinglePoolCapacity(capacity int) WorkerPoolOption
WithSinglePoolCapacity sets the capacity for a single worker pool.
type WorkerPoolOptions ¶ added in v1.43.0
type WorkerPoolOptions struct { PoolCount int SinglePoolCapacity int Concurrency int ExpiryDuration time.Duration Nonblocking bool PreAlloc bool PanicHandler func(any) Logger *util.LogEntry DisablePurge bool }
WorkerPoolOptions defines configurable options for the service's internal worker pool.