candishared

package
v1.10.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2022 License: Apache-2.0 Imports: 10 Imported by: 8

Documentation

Index

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 HTTPMemstatsHandler added in v1.0.4

func HTTPMemstatsHandler(w http.ResponseWriter, r *http.Request)

HTTPMemstatsHandler calculate runtime statistic

func HTTPRoot added in v1.0.4

func HTTPRoot(serviceName, buildNumber string) http.HandlerFunc

HTTPRoot http handler

func ParseWorkerKeyFromContext

func ParseWorkerKeyFromContext(ctx context.Context) []byte

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 ErrorRetrier added in v1.0.6

type ErrorRetrier struct {
	Delay   time.Duration
	Retry   int
	Message string
	Payload []byte
}

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 (*EventContext) Context added in v1.10.0

func (e *EventContext) Context() context.Context

Context get context

func (*EventContext) Err added in v1.10.0

func (e *EventContext) Err() error

Err get error

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) Key added in v1.10.0

func (e *EventContext) Key() string

Key get key

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) 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) WriteString added in v1.10.0

func (e *EventContext) WriteString(s string) (n int, err error)

WriteString method

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

func (*Filter) CalculateOffset

func (f *Filter) CalculateOffset() int

CalculateOffset method

type GraphQLErrorResolver

type GraphQLErrorResolver interface {
	Error() string
	Extensions() map[string]interface{}
}

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

func NewMeta

func NewMeta(page, limit, totalRecords int) (m Meta)

NewMeta create new meta for slice data

func (*Meta) CalculatePages

func (m *Meta) CalculatePages()

CalculatePages meta method

type PublisherArgument

type PublisherArgument struct {
	// Topic or queue name
	Topic       string
	Key         string
	Header      map[string]interface{}
	ContentType string
	// Deprecated : use Message
	Data    interface{}
	Message []byte
}

PublisherArgument declare publisher argument

type Queue

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

Queue represents a single instance of the queue data structure.

func NewQueue

func NewQueue() *Queue

NewQueue constructs and returns a new Queue.

func (*Queue) Len

func (q *Queue) Len() int

Len returns the number of elements currently stored in the queue.

func (*Queue) Peek

func (q *Queue) Peek() (interface{}, error)

Peek returns the element at the head of the queue. This call panics if the queue is empty.

func (*Queue) Pop

func (q *Queue) Pop() (interface{}, error)

Pop Pops and returns the element from the front of the queue. If the queue is empty, the call will panic.

func (*Queue) Push

func (q *Queue) Push(elem interface{})

Push puts an element on the end of the queue.

type Result

type Result struct {
	Data  interface{}
	Error error
}

Result common output

type SliceResult

type SliceResult struct {
	Data  interface{}
	Meta  Meta
	Error error
}

SliceResult include meta

type TokenClaim

type TokenClaim struct {
	jwt.StandardClaims
	Role       string
	Additional interface{}
}

TokenClaim for token claim data

func ParseTokenClaimFromContext

func ParseTokenClaimFromContext(ctx context.Context) *TokenClaim

ParseTokenClaimFromContext parse token claim from given context

Jump to

Keyboard shortcuts

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