device

package
v0.0.0-...-4347b6b Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2017 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PlatformIOS        = sns.PlatformAPNS
	PlatformIOSSandbox = sns.PlatformAPNSSandbox
	PlatformAndroid    = sns.PlatformGCM
)

Platform supported for a Device.

View Source
const (
	// DefaultLanguage for devices.
	DefaultLanguage = "en"
)

Variables

View Source
var (
	ErrInvalidDevice = errors.New("invalid device")
)

Common errors for Device serive implementations and validations.

Functions

func IsInvalidDevice

func IsInvalidDevice(err error) bool

IsInvalidDevice indicates if err is ErrInvalidDevice.

Types

type Device

type Device struct {
	Deleted     bool
	DeviceID    string
	Disabled    bool
	EndpointARN string
	ID          uint64
	Language    string
	Platform    sns.Platform
	Token       string
	UserID      uint64
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

Device represents a physical device like mobile phone or tablet of a user.

func (*Device) Validate

func (d *Device) Validate() error

Validate returns an error when a semantic check fails.

type Error

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

Error wraps common Device errors.

func (Error) Error

func (e Error) Error() string

type List

type List []*Device

List is a collection of devices.

type QueryOptions

type QueryOptions struct {
	Deleted      *bool
	DeviceIDs    []string
	Disabled     *bool
	EndpointARNs []string
	IDs          []uint64
	Platforms    []sns.Platform
	Tokens       []string
	UserIDs      []uint64
}

QueryOptions is used to narrow-down user queries.

type Service

type Service interface {
	service.Lifecycle

	Count(namespace string, opts QueryOptions) (uint, error)
	Put(namespace string, device *Device) (*Device, error)
	Query(namespace string, opts QueryOptions) (List, error)
}

Service for device interactions.

func PostgresService

func PostgresService(db *sqlx.DB) Service

PostgresService returns a Postgres based Service implementation.

type ServiceMiddleware

type ServiceMiddleware func(Service) Service

ServiceMiddleware is a chainable behaviour modifier for Service.

func InstrumentServiceMiddleware

func InstrumentServiceMiddleware(
	component, store string,
	errCount kitmetrics.Counter,
	opCount kitmetrics.Counter,
	opLatency *prometheus.HistogramVec,
) ServiceMiddleware

InstrumentServiceMiddleware observes key aspects of Service operations and exposes Prometheus metrics.

func LogServiceMiddleware

func LogServiceMiddleware(logger log.Logger, store string) ServiceMiddleware

LogServiceMiddleware given a Logger wraps the next Service with logging capabilities.

Jump to

Keyboard shortcuts

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