Documentation ¶
Index ¶
- Constants
- Variables
- func GQLArgToMapStringInt(arg []interface{}) (ret map[string]int, err error)
- func GQLArgToMapStringString(arg []interface{}) (ret map[string]string, err error)
- func InitZapLogger(cfg map[string]interface{}) (*zap.Logger, error)
- func NewContext(ctx context.Context, userID int, userName string, source string, ...) context.Context
- func Ptr[T any](v T) *T
- func WithRequestContext(ctx context.Context, requestContext Context) context.Context
- type ArrKV
- type CRONService
- func (cs *CRONService) AddFunc(spec string, cmd func(ctx context.Context) (interface{}, error)) (JobID, error)
- func (cs *CRONService) AddNamedFunc(spec string, name string, cmd func(ctx context.Context) (interface{}, error)) (JobID, error)
- func (cs *CRONService) Cron() *cron.Cron
- func (cs *CRONService) ListJobs() []*Job
- func (cs *CRONService) Prepare(eng *Engine, _ dep.Provider) (err error)
- func (cs *CRONService) Provide() interface{}
- func (cs *CRONService) SetJobContext(ctx context.Context)
- func (cs *CRONService) Start(eng *Engine, _ dep.Provider) error
- type ConfigChangeCallback
- type ConfigProvider
- type Context
- type DateIterator
- func (di *DateIterator) Curr() (time.Time, error)
- func (di *DateIterator) Current() time.Time
- func (di *DateIterator) Next() bool
- func (di *DateIterator) SetDateStep(y, m, d int)
- func (di *DateIterator) SetStep(step time.Duration)
- func (di *DateIterator) Start(from, to time.Time)
- func (di *DateIterator) StartString(from, to string) (err error)
- type DefaultContext
- func (c DefaultContext) GetExt(key string) (interface{}, bool)
- func (c DefaultContext) HasRole(role string) bool
- func (c DefaultContext) Roles() []string
- func (c DefaultContext) RolesMask() int
- func (c DefaultContext) Source() string
- func (c DefaultContext) UserID() int
- func (c DefaultContext) UserName() string
- func (c DefaultContext) UserType() int
- type Engine
- func (eng *Engine) ConfBool(key string, def ...bool) bool
- func (eng *Engine) ConfInt(key string, def ...int) int
- func (eng *Engine) ConfInt64(key string, def ...int64) int64
- func (eng *Engine) ConfString(key string, def ...string) string
- func (eng *Engine) ConfValue(key string) interface{}
- func (eng *Engine) Config() dep.ConfigProvider
- func (eng *Engine) Engine(name string) SubEngine
- func (eng *Engine) GetConfig(name string) interface{}
- func (eng *Engine) GetService(tip string) Service
- func (eng *Engine) Logger(name string) *zap.Logger
- func (eng *Engine) NotifyConfigChanged(key string, val interface{})
- func (eng *Engine) RegisterConfigChangeCallback(cb ConfigChangeCallback)
- func (eng *Engine) RegisterConfigProvider(p ConfigProvider, priority int)
- func (eng *Engine) SetConfValue(key string, val interface{}) error
- func (eng *Engine) Start() error
- func (eng *Engine) WithEngine(se SubEngine) *Engine
- func (eng *Engine) WithLogger(l *zap.Logger) *Engine
- func (eng *Engine) WithService(name string, srv Service) *Engine
- type GQLDescriptor
- func (gqld *GQLDescriptor) AddInputGenerator(name string, g GQLInputTypeGenerator)
- func (gqld *GQLDescriptor) AddMutationGenerator(name string, g GQLQueryGenerator)
- func (gqld *GQLDescriptor) AddQueryGenerator(name string, g GQLQueryGenerator)
- func (gqld *GQLDescriptor) AddTypeGenerator(name string, g GQLTypeGenerator)
- func (gqld *GQLDescriptor) GetInputType(name string) graphql.Input
- func (gqld *GQLDescriptor) GetType(name string) graphql.Output
- type GQLEngine
- func (gqe *GQLEngine) CollectStatistics(collect bool) *GQLEngine
- func (gqe *GQLEngine) Descriptor() *GQLDescriptor
- func (gqe *GQLEngine) HTTPHandler(pretty ...bool) http.HandlerFunc
- func (gqe *GQLEngine) HTTPStatisticsHandler(pretty ...bool) http.HandlerFunc
- func (gqe *GQLEngine) Prepare(_ *Engine, _ dep.Provider) error
- func (gqe *GQLEngine) Provide() interface{}
- func (gqe *GQLEngine) SetLogger(logger *zap.Logger) *GQLEngine
- func (gqe *GQLEngine) SetOptions(options GQLOptions) *GQLEngine
- func (gqe *GQLEngine) Start(eng *Engine, _ dep.Provider) error
- type GQLInputTypeGenerator
- type GQLOptions
- type GQLQueryGenerator
- type GQLTypeGenerator
- type Generator
- type Job
- type JobID
- type KVPair
- func (kv KVPair) KeyInt() int
- func (kv KVPair) KeyInteger() (int, error)
- func (kv KVPair) KeyStr() string
- func (kv KVPair) KeyString() (string, error)
- func (kv KVPair) ValInt() int
- func (kv KVPair) ValInteger() (int, error)
- func (kv KVPair) ValStr() string
- func (kv KVPair) ValString() (string, error)
- type LoggerService
- type LogrusService
- type Sequence
- type SequenceProvider
- type Service
- type ServiceProvider
- type SubEngine
- type ViperConfig
Constants ¶
View Source
const ( ServiceGQL = "gql" ServiceSequenceProvider = "sequence" ServiceScripting = "scripting" ServiceCRON = "cron" ServiceLoggingLogrus = "logging:logrus" ServiceLoggingZap = "logging:zap" ServiceNATS = "nats" ServiceSQL = "sql" ServiceSQLX = "sqlx" )
well known services
View Source
const ( //KVStringString - name for special type for Key and Value pair KVStringString = "_kv_string_string_" //KVStringStringInput - name for special input type for Key and Value pair KVStringStringInput = "_kv_string_string_input_" //KVStringInt - name for special type for Key and Value pair KVStringInt = "_kv_string_int_" //KVStringIntInput - name for special input type for Key and Value pair KVStringIntInput = "_kv_string_int_input_" KVStringIntName = "_kv_string_int_" KVStringStringName = "_kv_string_string_" KVStringStringInputName = "_kv_string_string_input_" //"StringStringKVInput" KVStringIntInputName = "_kv_string_int_input_" //"StringIntKVInput" )
Variables ¶
View Source
var ( // ErrValueIgnored - provider can not set config values ErrValueIgnored = errors.New("ignored") // ErrInvalidValueType - type of value is invalid ErrInvalidValueType = errors.New("invalid value type") )
View Source
var ( ErrInvalidDateFormat = errors.New("invalid date format") ErrCurrentWithoutNext = errors.New("current without next") )
View Source
var ( //ErrNoSequenceProvider - there is not SequenceProvider registered ErrNoSequenceProvider = errors.New("no SequenceProvider registered") // ErrItemNotFound may be returned for dictionary items (wrapped with information about dictionary and id) ErrItemNotFound = errors.New("item not found") )
View Source
var ContextID = &struct{ vivardName string }{"VivardContext"}
Functions ¶
func GQLArgToMapStringInt ¶
func GQLArgToMapStringString ¶
func NewContext ¶
Types ¶
type ArrKV ¶
type ArrKV []KVPair
func GQLArgToArrKVStringInt ¶
func MapStringIntToArrKV ¶
func MapStringStringToArrKV ¶
type CRONService ¶
type CRONService struct {
// contains filtered or unexported fields
}
CRONService provides robfig/cron functionality as a vivard service
func NewCronService ¶
func NewCronService(ctx context.Context) *CRONService
func (*CRONService) AddNamedFunc ¶
func (*CRONService) Cron ¶
func (cs *CRONService) Cron() *cron.Cron
func (*CRONService) ListJobs ¶
func (cs *CRONService) ListJobs() []*Job
func (*CRONService) Prepare ¶
func (cs *CRONService) Prepare(eng *Engine, _ dep.Provider) (err error)
func (*CRONService) Provide ¶
func (cs *CRONService) Provide() interface{}
func (*CRONService) SetJobContext ¶
func (cs *CRONService) SetJobContext(ctx context.Context)
type ConfigChangeCallback ¶ added in v0.1.22
type ConfigChangeCallback func(key string, value interface{})
type ConfigProvider ¶
type Context ¶
type Context interface { UserID() int UserType() int UserName() string Source() string HasRole(role string) bool RolesMask() int GetExt(key string) (interface{}, bool) }
Context is the interface for default request context object
func RequestContext ¶
type DateIterator ¶
type DateIterator struct {
// contains filtered or unexported fields
}
func (*DateIterator) Current ¶
func (di *DateIterator) Current() time.Time
func (*DateIterator) Next ¶
func (di *DateIterator) Next() bool
func (*DateIterator) SetDateStep ¶
func (di *DateIterator) SetDateStep(y, m, d int)
func (*DateIterator) SetStep ¶
func (di *DateIterator) SetStep(step time.Duration)
func (*DateIterator) Start ¶
func (di *DateIterator) Start(from, to time.Time)
func (*DateIterator) StartString ¶
func (di *DateIterator) StartString(from, to string) (err error)
type DefaultContext ¶
type DefaultContext struct {
// contains filtered or unexported fields
}
func (DefaultContext) GetExt ¶
func (c DefaultContext) GetExt(key string) (interface{}, bool)
func (DefaultContext) HasRole ¶
func (c DefaultContext) HasRole(role string) bool
func (DefaultContext) Roles ¶
func (c DefaultContext) Roles() []string
func (DefaultContext) RolesMask ¶
func (c DefaultContext) RolesMask() int
func (DefaultContext) Source ¶
func (c DefaultContext) Source() string
func (DefaultContext) UserID ¶
func (c DefaultContext) UserID() int
func (DefaultContext) UserName ¶
func (c DefaultContext) UserName() string
func (DefaultContext) UserType ¶
func (c DefaultContext) UserType() int
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (*Engine) Config ¶
func (eng *Engine) Config() dep.ConfigProvider
func (*Engine) GetService ¶
GetService looks for registered service and returns it; returns nil if not found
func (*Engine) NotifyConfigChanged ¶ added in v0.1.23
func (*Engine) RegisterConfigChangeCallback ¶ added in v0.1.22
func (eng *Engine) RegisterConfigChangeCallback(cb ConfigChangeCallback)
func (*Engine) RegisterConfigProvider ¶
func (eng *Engine) RegisterConfigProvider(p ConfigProvider, priority int)
func (*Engine) SetConfValue ¶
func (*Engine) WithEngine ¶
WithEngine add SubEngine to list
func (*Engine) WithLogger ¶
WithLogger sets l as Engine's logger
type GQLDescriptor ¶
type GQLDescriptor struct {
// contains filtered or unexported fields
}
func (*GQLDescriptor) AddInputGenerator ¶
func (gqld *GQLDescriptor) AddInputGenerator(name string, g GQLInputTypeGenerator)
func (*GQLDescriptor) AddMutationGenerator ¶
func (gqld *GQLDescriptor) AddMutationGenerator(name string, g GQLQueryGenerator)
func (*GQLDescriptor) AddQueryGenerator ¶
func (gqld *GQLDescriptor) AddQueryGenerator(name string, g GQLQueryGenerator)
func (*GQLDescriptor) AddTypeGenerator ¶
func (gqld *GQLDescriptor) AddTypeGenerator(name string, g GQLTypeGenerator)
func (*GQLDescriptor) GetInputType ¶
func (gqld *GQLDescriptor) GetInputType(name string) graphql.Input
type GQLEngine ¶
type GQLEngine struct {
// contains filtered or unexported fields
}
func (*GQLEngine) CollectStatistics ¶ added in v0.1.13
func (*GQLEngine) Descriptor ¶
func (gqe *GQLEngine) Descriptor() *GQLDescriptor
func (*GQLEngine) HTTPHandler ¶
func (gqe *GQLEngine) HTTPHandler(pretty ...bool) http.HandlerFunc
func (*GQLEngine) HTTPStatisticsHandler ¶ added in v0.1.13
func (gqe *GQLEngine) HTTPStatisticsHandler(pretty ...bool) http.HandlerFunc
func (*GQLEngine) SetOptions ¶ added in v0.1.14
func (gqe *GQLEngine) SetOptions(options GQLOptions) *GQLEngine
type GQLInputTypeGenerator ¶
type GQLOptions ¶ added in v0.1.14
type GQLQueryGenerator ¶
type GQLTypeGenerator ¶
type Job ¶
type Job struct { ID JobID Name string Spec string RunCount int Duration time.Duration LastRunAt time.Time LastRunDuration time.Duration LastError error LastErrorTime time.Time LastResult interface{} // contains filtered or unexported fields }
func (*Job) ScheduledAt ¶
type KVPair ¶
type KVPair struct { Key interface{} Val interface{} }
func GQLArgToKVStringInt ¶
func GQLArgToKVStringString ¶
func (KVPair) KeyInteger ¶
func (KVPair) ValInteger ¶
type LoggerService ¶
type LoggerService struct {
// contains filtered or unexported fields
}
func NewLoggerService ¶
func NewLoggerService(log *zap.Logger) *LoggerService
func (*LoggerService) Log ¶
func (ls *LoggerService) Log() *zap.Logger
func (*LoggerService) Prepare ¶
func (ls *LoggerService) Prepare(eng *Engine, _ dep.Provider) (err error)
func (*LoggerService) Provide ¶
func (ls *LoggerService) Provide() any
type LogrusService ¶
type LogrusService struct {
// contains filtered or unexported fields
}
func NewLogrusService ¶
func NewLogrusService(log *logrus.Entry) *LogrusService
func (*LogrusService) Log ¶
func (ls *LogrusService) Log() *logrus.Entry
func (*LogrusService) Prepare ¶
func (ls *LogrusService) Prepare(eng *Engine, _ dep.Provider) (err error)
func (*LogrusService) Provide ¶
func (ls *LogrusService) Provide() interface{}
type Sequence ¶
type Sequence interface { // Next incerements current value and returns it as next value for sequence Next(ctx context.Context) (int, error) // Current returns current (last returned by Next) value Current(ctx context.Context) (int, error) // SetCurrent sets current value of Sequence to value SetCurrent(ctx context.Context, value int) (int, error) }
Sequence - interface for named sequence of integer
type SequenceProvider ¶
type SequenceProvider interface { // Sequence returns Sequence object for given name Sequence(ctx context.Context, name string) (Sequence, error) // ListSequences returns sequences with names containing mask (case-insensitivity may depend on implementation) // return map with Sequence name as key and current value as value ListSequences(ctx context.Context, mask string) (map[string]int, error) }
SequenceProvider provides sequences
type Service ¶
type Service interface { // Prepare will be called for each registered service before SubEngine's Prepare Prepare(eng *Engine, provider dep.Provider) error Start(eng *Engine, provider dep.Provider) error // Provide should return some low level object, e.g. *sql.DB for sql Service Provide() interface{} }
type ServiceProvider ¶
type ServiceProvider interface {
ProvideServices(engine *Engine)
}
ServiceProvider may be implemented by SubEngine to register services
type ViperConfig ¶
type ViperConfig struct {
// contains filtered or unexported fields
}
func NewViperConfig ¶
func NewViperConfig() ViperConfig
func NewViperConfigForViper ¶
func NewViperConfigForViper(v *viper.Viper) ViperConfig
func (ViperConfig) GetConfigValue ¶
func (vc ViperConfig) GetConfigValue(key string) interface{}
func (ViperConfig) SetConfigValue ¶
func (vc ViperConfig) SetConfigValue(key string, val interface{}) error
Source Files ¶
Click to show internal directories.
Click to hide internal directories.