worker

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyToken           = NewResponseError(ErrorCodeBadDeviceToken, errors.New("empty device token"))
	ErrUnknownResponseError = NewResponseError(ErrorCodeUnknown, errors.New("unknown response error"))
	ErrInvalidOutDataType   = NewResponseError(ErrorCodeBadRequest, errors.New("invalid out data type"))
)

Functions

func KindStringKeys

func KindStringKeys() []string

func ReadFile added in v1.0.2

func ReadFile(path string, maxSize int64) ([]byte, error)

Types

type Config

type Config struct {
	*conversion.Config `mapstructure:"-"`
	ProjectID          string `mapstructure:"project-id"`
	NopMode            bool   `mapstructure:"nop-mode"`
	CountThreads       int    `mapstructure:"workers"`
	Sandbox            bool   `mapstructure:"sandbox"`
}

func NewConfig

func NewConfig(src *viper.Viper) (*Config, error)

type ErrorCode

type ErrorCode int
const (
	ErrorCodeUnknown        ErrorCode = 0
	ErrorCodeUnregistered   ErrorCode = 1
	ErrorCodeBadDeviceToken ErrorCode = 2
	ErrorCodeBadRequest     ErrorCode = 3
)

type FnSendNotification

type FnSendNotification func(ctx context.Context, out provider.IRequest) error

type IWorker

type IWorker interface {
	Kind() Kind
	ProjectID() string
	Send(context.Context, *Request) <-chan *Response
	ConversionConfig() *conversion.Config
	SupportsVoIP() bool
}

type Kind

type Kind int
const (
	KindUnknown Kind = 0
	KindApns    Kind = 1
	KindFcm     Kind = 2
	KindGcm     Kind = 3
)

func KindByString

func KindByString(src string) Kind

func (Kind) String

func (k Kind) String() string

type Request

type Request struct {
	Devices       []string
	CorrelationID string
	Payload       provider.IRequest
}

type Response

type Response struct {
	ProjectID   string
	DeviceToken string
	Error       error
}

type ResponseError

type ResponseError struct {
	Code ErrorCode
	// contains filtered or unexported fields
}

func NewResponseError

func NewResponseError(code ErrorCode, err error) *ResponseError

func NewResponseErrorBadDeviceToken

func NewResponseErrorBadDeviceToken(err error) *ResponseError

func NewResponseErrorFromAnswer

func NewResponseErrorFromAnswer(code int, err error) *ResponseError

func (*ResponseError) Err

func (r *ResponseError) Err() error

func (*ResponseError) Error

func (r *ResponseError) Error() string

type Worker

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

func New

func New(
	cfg *Config,
	kind Kind,
	sandbox bool,
	logger *zap.Logger,
	svcMetric *metric.Service,
	fnSendNotification FnSendNotification,
) (*Worker, error)

func (*Worker) ConversionConfig

func (w *Worker) ConversionConfig() *conversion.Config

func (*Worker) Kind

func (w *Worker) Kind() Kind

func (*Worker) NoOpMode

func (w *Worker) NoOpMode() bool

func (*Worker) ProjectID

func (w *Worker) ProjectID() string

func (*Worker) Send

func (w *Worker) Send(ctx context.Context, req *Request) <-chan *Response

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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