Documentation ¶
Index ¶
- func GetValueFromContext(ctx context.Context, key ContextKey) interface{}
- func ParseWorkerKeyFromContext(ctx context.Context) []byte
- func SetToContext(ctx context.Context, key ContextKey, value interface{}) context.Context
- type ContextKey
- type DBUpdateOptionFunc
- type DBUpdateOptionKeyExtractorResult
- func DBUpdateGORMExtractorKey(structField reflect.StructField) (res DBUpdateOptionKeyExtractorResult)
- func DBUpdateMongoExtractorKey(structField reflect.StructField) (res DBUpdateOptionKeyExtractorResult)
- func DBUpdateSqlExtractorKey(structField reflect.StructField) (res DBUpdateOptionKeyExtractorResult)
- type DBUpdateTools
- type ErrorRetrier
- type EventContext
- func (e *EventContext) Context() context.Context
- func (e *EventContext) Err() error
- func (e *EventContext) GetResponse() *bytes.Buffer
- func (e *EventContext) HandlerRoute() string
- func (e *EventContext) Header() map[string]string
- func (e *EventContext) Key() string
- func (e *EventContext) Message() []byte
- func (e *EventContext) Read(p []byte) (n int, err error)
- func (e *EventContext) Reset()
- func (e *EventContext) SetContext(ctx context.Context)
- func (e *EventContext) SetContextWithValue(key, value any)
- func (e *EventContext) SetError(err error)
- func (e *EventContext) SetHandlerRoute(h string)
- func (e *EventContext) SetHeader(header map[string]string)
- func (e *EventContext) SetKey(key string)
- func (e *EventContext) SetWorkerType(w string)
- func (e *EventContext) WorkerType() string
- func (e *EventContext) Write(p []byte) (n int, err error)
- func (e *EventContext) WriteResult(p []byte) (n int, err error)
- func (e *EventContext) WriteString(s string) (n int, err error)
- type Filter
- type GraphQLErrorResolver
- type Meta
- type NullableFilter
- type PublisherArgument
- type Queue
- type Result
- type SliceResult
- type TokenClaim
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetValueFromContext ¶
func GetValueFromContext(ctx context.Context, key ContextKey) interface{}
GetValueFromContext will get context with specific key
func ParseWorkerKeyFromContext ¶
ParseWorkerKeyFromContext parse token claim from given context
func SetToContext ¶
func SetToContext(ctx context.Context, key ContextKey, value interface{}) context.Context
SetToContext will set context with specific key
Types ¶
type ContextKey ¶
type ContextKey string
ContextKey represent Key of all context
const ( // ContextKeyHTTPHeader context key ContextKeyHTTPHeader ContextKey = "httpHeader" // ContextKeyTaskQueueRetry context key ContextKeyTaskQueueRetry ContextKey = "taskQueueRetry" // ContextKeyTokenClaim context key ContextKeyTokenClaim ContextKey = "tokenClaim" // ContextKeyWorkerKey context key ContextKeyWorkerKey ContextKey = "workerKey" // ContextKeySQLTransaction context key ContextKeySQLTransaction ContextKey = "sqltx" )
type DBUpdateOptionFunc ¶ added in v1.14.7
type DBUpdateOptionFunc func(*partialUpdateOption)
DBUpdateOptionFunc option func
func DBUpdateSetIgnoredFields ¶ added in v1.14.7
func DBUpdateSetIgnoredFields(fields ...string) DBUpdateOptionFunc
DBUpdateSetIgnoredFields option func
func DBUpdateSetUpdatedFields ¶ added in v1.14.7
func DBUpdateSetUpdatedFields(fields ...string) DBUpdateOptionFunc
DBUpdateSetUpdatedFields option func
type DBUpdateOptionKeyExtractorResult ¶ added in v1.17.15
DBUpdateOptionKeyExtractorResult option func
func DBUpdateGORMExtractorKey ¶ added in v1.14.7
func DBUpdateGORMExtractorKey(structField reflect.StructField) (res DBUpdateOptionKeyExtractorResult)
DBUpdateGORMExtractorKey struct field key extractor for gorm model
func DBUpdateMongoExtractorKey ¶ added in v1.14.7
func DBUpdateMongoExtractorKey(structField reflect.StructField) (res DBUpdateOptionKeyExtractorResult)
DBUpdateMongoExtractorKey struct field key extractor for mongo model
func DBUpdateSqlExtractorKey ¶ added in v1.17.9
func DBUpdateSqlExtractorKey(structField reflect.StructField) (res DBUpdateOptionKeyExtractorResult)
DBUpdateSqlExtractorKey struct field key extractor for mongo model
type DBUpdateTools ¶ added in v1.14.7
type DBUpdateTools struct { KeyExtractorFunc func(structTag reflect.StructField) (res DBUpdateOptionKeyExtractorResult) FieldValueExtractor func(reflect.Value) (val any, skip bool) IgnoredFields []string }
DBUpdateTools for construct selected field to update
func (DBUpdateTools) GetFields ¶ added in v1.16.2
func (d DBUpdateTools) GetFields(opts ...DBUpdateOptionFunc) (updates, ignores []string)
GetUpdatedFields method
func (DBUpdateTools) ToMap ¶ added in v1.14.7
func (d DBUpdateTools) ToMap(data interface{}, opts ...DBUpdateOptionFunc) map[string]interface{}
ToMap method
type ErrorRetrier ¶ added in v1.0.6
type ErrorRetrier struct { // Delay run retry, skip retry if delay <= 0 Delay time.Duration NewRetry int // Message for error value Message string // NewArgsPayload overide args message payload NewArgsPayload []byte StackTrace string NewRetryIntervalFunc func(retries int) time.Duration }
ErrorRetrier task queue worker for retry error with retry count and delay between retry
func (*ErrorRetrier) Error ¶ added in v1.0.6
func (e *ErrorRetrier) Error() string
Error implement error
type EventContext ¶ added in v1.10.0
type EventContext struct {
// contains filtered or unexported fields
}
EventContext worker context in handler
func NewEventContext ¶ added in v1.14.0
func NewEventContext(msgBuff *bytes.Buffer) *EventContext
NewEventContext event context constructor
func NewEventContextWithResult ¶ added in v1.15.3
func NewEventContextWithResult(msgBuff, resBuff *bytes.Buffer) *EventContext
NewEventContextWithResult event context constructor
func (*EventContext) Context ¶ added in v1.10.0
func (e *EventContext) Context() context.Context
Context get context
func (*EventContext) GetResponse ¶ added in v1.15.3
func (e *EventContext) GetResponse() *bytes.Buffer
GetResponse get response writer buffer
func (*EventContext) HandlerRoute ¶ added in v1.10.0
func (e *EventContext) HandlerRoute() string
HandlerRoute get handler name, contains unique topic name, or task name
func (*EventContext) Header ¶ added in v1.10.0
func (e *EventContext) Header() map[string]string
Header get context
func (*EventContext) Message ¶ added in v1.10.0
func (e *EventContext) Message() []byte
Message get context
func (*EventContext) Read ¶ added in v1.10.0
func (e *EventContext) Read(p []byte) (n int, err error)
Read implement io.Reader
func (*EventContext) SetContext ¶ added in v1.10.0
func (e *EventContext) SetContext(ctx context.Context)
SetContext setter
func (*EventContext) SetContextWithValue ¶ added in v1.16.4
func (e *EventContext) SetContextWithValue(key, value any)
SetContextWithValue set context with allow to multiple value If parent context is null will assign with context.Background() as default value
func (*EventContext) SetError ¶ added in v1.10.0
func (e *EventContext) SetError(err error)
SetError setter
func (*EventContext) SetHandlerRoute ¶ added in v1.10.0
func (e *EventContext) SetHandlerRoute(h string)
SetHandlerRoute setter can contains unique topic name, key, or task name
func (*EventContext) SetHeader ¶ added in v1.10.0
func (e *EventContext) SetHeader(header map[string]string)
SetHeader setter
func (*EventContext) SetKey ¶ added in v1.10.0
func (e *EventContext) SetKey(key string)
SetKey setter
func (*EventContext) SetWorkerType ¶ added in v1.10.0
func (e *EventContext) SetWorkerType(w string)
SetWorkerType setter
func (*EventContext) WorkerType ¶ added in v1.10.0
func (e *EventContext) WorkerType() string
WorkerType get worker type
func (*EventContext) Write ¶ added in v1.10.0
func (e *EventContext) Write(p []byte) (n int, err error)
Write implement io.Writer
func (*EventContext) WriteResult ¶ added in v1.15.3
func (e *EventContext) WriteResult(p []byte) (n int, err error)
WriteResult write result to buffer
func (*EventContext) WriteString ¶ added in v1.10.0
func (e *EventContext) WriteString(s string) (n int, err error)
WriteString write string to buffer
type Filter ¶
type Filter struct { Limit int `json:"limit" default:"10"` Page int `json:"page" default:"1"` Offset int `json:"-"` Search string `json:"search,omitempty"` OrderBy string `json:"orderBy,omitempty"` Sort string `json:"sort,omitempty" default:"desc" lower:"true"` ShowAll bool `json:"showAll"` AllowEmptyFilter bool `json:"-"` }
Filter data
type GraphQLErrorResolver ¶
GraphQLErrorResolver graphql error with extensions
func NewGraphQLErrorResolver ¶
func NewGraphQLErrorResolver(errMesage string, extensions map[string]interface{}) GraphQLErrorResolver
NewGraphQLErrorResolver constructor
type Meta ¶
type Meta struct { Page int `json:"page"` Limit int `json:"limit"` TotalRecords int `json:"totalRecords"` TotalPages int `json:"totalPages"` }
Meta model
type NullableFilter ¶ added in v1.15.7
type NullableFilter struct { Limit *int Page *int Search *string Sort *string ShowAll *bool OrderBy *string }
NullableFilter filter contains nullable value
func (*NullableFilter) ToFilter ¶ added in v1.15.7
func (n *NullableFilter) ToFilter() (filter Filter)
type PublisherArgument ¶
type PublisherArgument struct { // Topic or queue name Topic string Key string Header map[string]interface{} ContentType string Message []byte Delay time.Duration IsDeleteMessage bool // Deprecated : use Message Data interface{} }
PublisherArgument declare publisher argument
func (*PublisherArgument) Validate ¶ added in v1.14.9
func (p *PublisherArgument) Validate() error
type Queue ¶
type Queue[T any] struct { // contains filtered or unexported fields }
Queue represents a single instance of the queue data structure.
func (*Queue[T]) Peek ¶
Peek returns the element at the head of the queue. This call panics if the queue is empty.
type SliceResult ¶
SliceResult include meta
type TokenClaim ¶
type TokenClaim struct { jwt.StandardClaims Role string `json:"role"` Additional interface{} `json:"additional"` }
TokenClaim for token claim data
func ParseTokenClaimFromContext ¶
func ParseTokenClaimFromContext(ctx context.Context) *TokenClaim
ParseTokenClaimFromContext parse token claim from given context