Documentation ¶
Index ¶
- Constants
- Variables
- func HashTokenBase64(token string, salt string, secret string) stringdeprecated
- func HashTokenHex(token string, salt string, secret string) string
- func InitAppConfig[C InstanceConfig](appConfig C, settings *AppSettings) error
- type AbstractRepository
- type App
- type AppSettings
- type CacheTagHeader
- type Config
- type Context
- type HTTPRepository
- type InstanceConfig
- type Repository
- type RepositoryData
- type RepositoryDataLoader
- type Router
- type RouterError
- type Service
- func (sb *Service) Debugf(format string, a ...any)
- func (sb *Service) Errorf(format string, a ...any)
- func (sb *Service) Fatalf(format string, a ...any)
- func (sb *Service) Infof(format string, a ...any)
- func (sb *Service) NewError(format string, a ...any) error
- func (sb *Service) SystemErrorf(format string, a ...any)
- func (sb *Service) Warnf(format string, a ...any)
Constants ¶
View Source
const ContextDomain = "contextDomain"
View Source
const ContextLoggerName = "contextLogger"
View Source
const ContextMessageId = "contextMessageId"
View Source
const DefaultSeed = "dea42a58-acf4-45af-85bb-e77e94bd5025"
DefaultSeed is a default seed for hex encoded hashed tokens
View Source
const SIG_SHUTDOWN_FOR_TESTS = syscall.Signal(0x42)
Variables ¶
View Source
var IsHexRegex = regexp.MustCompile(`^[a-fA-F0-9]+$`)
Functions ¶
func HashTokenBase64
deprecated
func InitAppConfig ¶
func InitAppConfig[C InstanceConfig](appConfig C, settings *AppSettings) error
Types ¶
type AbstractRepository ¶
func NewAbstractRepository ¶
func NewAbstractRepository[T any](id string, emptyData RepositoryData[T], source RepositoryDataLoader, attempts int, refreshPeriodSec int, cacheDir string) *AbstractRepository[T]
func (*AbstractRepository[T]) ChangesChannel ¶
func (r *AbstractRepository[T]) ChangesChannel() <-chan bool
func (*AbstractRepository[T]) Close ¶
func (r *AbstractRepository[T]) Close() error
func (*AbstractRepository[T]) GetData ¶
func (r *AbstractRepository[T]) GetData() *T
type AppSettings ¶
type AppSettings struct {
Name, ConfigPath, ConfigName, ConfigType, EnvPrefix string
}
func (*AppSettings) EnvPrefixWithUnderscore ¶
func (a *AppSettings) EnvPrefixWithUnderscore() string
type CacheTagHeader ¶
type CacheTagHeader string
const ( HTTPTagLastModified CacheTagHeader = "last-modified" HTTPTagETag CacheTagHeader = "etag" HTTPTagNone CacheTagHeader = "" )
type Config ¶
type Config struct { AppSetting *AppSettings // InstanceId ID of bulker instance. It is used for identifying Kafka consumers. // If is not set, instance id will be generated and persisted to disk (~/.{appName}/instance_id) and reused on next restart. // Default: random uuid InstanceId string `mapstructure:"INSTANCE_ID"` // HTTPPort port for bulker http server. HTTPPort int `mapstructure:"HTTP_PORT"` // AuthTokens A list of hashed auth tokens that authorizes user in HTTP interface separated by comma. Each must have format: // `${salt}.${hash}` where `${salt}` should be random string. Hash is `base64(sha512($token + $salt + TokenSecrets)`. // `$token` must consist only of letters, digits, underscore and dash AuthTokens string `mapstructure:"AUTH_TOKENS"` // RawAuthTokens plain non hashed tokens separated by comma. Each token must consist only of letters, digits, underscore and dash RawAuthTokens string `mapstructure:"RAW_AUTH_TOKENS"` // See AuthTokens TokenSecrets string `mapstructure:"TOKEN_SECRET"` // LogFormat log format. Can be `text` or `json`. Default: `text` LogFormat string `mapstructure:"LOG_FORMAT"` }
func (*Config) PostInit ¶
func (c *Config) PostInit(settings *AppSettings) error
type HTTPRepository ¶
type HTTPRepository[T any] struct { *AbstractRepository[T] // contains filtered or unexported fields }
func NewHTTPRepository ¶
func NewHTTPRepository[T any](id, url, token string, tagHeader CacheTagHeader, emptyData RepositoryData[T], attempts int, refreshPeriodSec int, cacheDir string) *HTTPRepository[T]
type InstanceConfig ¶
type InstanceConfig interface {
PostInit(settings *AppSettings) error
}
type Repository ¶
type RepositoryData ¶
type RepositoryDataLoader ¶
type RepositoryDataLoader func(tag any) (reader io.ReadCloser, newTag any, modified bool, err error)
RepositoryDataLoader loads data from external source. tag can be used for etag or last modified handling
type Router ¶
type Router struct { Service // contains filtered or unexported fields }
func NewRouterBase ¶
func (*Router) ResponseError ¶
type RouterError ¶
type Service ¶
type Service struct { // ID is used as [ID] prefix in log and error messages ID string }
Service base struct for typical service objects
func NewServiceBase ¶
func (*Service) SystemErrorf ¶
Click to show internal directories.
Click to hide internal directories.