command

package
v0.0.0-...-29c6822 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2018 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package command provides utilities for creating MDM Payloads.

Index

Constants

View Source
const (

	// CommandBucket is the *bolt.DB bucket where commands are archived.
	CommandBucket = "mdm.Command.ARCHIVE"

	// CommandTopic is a PubSub topic that events are published to.
	CommandTopic = "mdm.Command"
)

Variables

This section is empty.

Functions

func EncodeError

func EncodeError(ctx context.Context, err error, w http.ResponseWriter)

EncodeError is used by the HTTP transport to encode service errors in HTTP. The EncodeError should be passed to the Go-Kit httptransport as the ServerErrorEncoder to encode error responses with JSON.

func EndpointInstrumentingMiddleware

func EndpointInstrumentingMiddleware(duration metrics.Histogram) endpoint.Middleware

EndpointInstrumentingMiddleware returns an endpoint middleware that records the duration of each invocation to the passed histogram. The middleware adds a single field: "success", which is "true" if no error is returned, and "false" otherwise.

func EndpointLoggingMiddleware

func EndpointLoggingMiddleware(logger log.Logger) endpoint.Middleware

EndpointLoggingMiddleware returns an endpoint middleware that logs the duration of each invocation, and the resulting error, if any.

func MakeNewCommandEndpoint

func MakeNewCommandEndpoint(svc Service) endpoint.Endpoint

MakeNewCommandEndpoint creates an endpoint which creates new MDM Commands.

func MarshalEvent

func MarshalEvent(e *Event) ([]byte, error)

MarshalEvent serializes an event to a protocol buffer wire format.

func UnmarshalEvent

func UnmarshalEvent(data []byte, e *Event) error

UnmarshalEvent parses a protocol buffer representation of data into the Event.

Types

type Command

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

func New

func New(db *bolt.DB, pub pubsub.Publisher) (*Command, error)

func (*Command) NewCommand

func (svc *Command) NewCommand(ctx context.Context, request *mdm.CommandRequest) (*mdm.Payload, error)

type Endpoints

type Endpoints struct {
	NewCommandEndpoint endpoint.Endpoint
}

type Event

type Event struct {
	ID         string
	Time       time.Time
	Payload    mdm.Payload
	DeviceUDID string
}

func NewEvent

func NewEvent(cmd mdm.Payload, udid string) *Event

NewEvent returns an Event with a unique ID and the current time.

type HTTPHandlers

type HTTPHandlers struct {
	NewCommandHandler http.Handler
}

func MakeHTTPHandlers

func MakeHTTPHandlers(ctx context.Context, endpoints Endpoints, opts ...httptransport.ServerOption) HTTPHandlers

type Middleware

type Middleware func(Service) Service

Middleware describes a service (as opposed to endpoint) middleware.

func ServiceInstrumentingMiddleware

func ServiceInstrumentingMiddleware(p metrics.Counter) Middleware

ServiceInstrumentingMiddleware returns a service middleware that tracks the number of payloads created by the service.

func ServiceLoggingMiddleware

func ServiceLoggingMiddleware(logger log.Logger) Middleware

ServiceLoggingMiddleware returns a service middleware that logs the parameters and result of each method invocation.

type Service

type Service interface {
	NewCommand(context.Context, *mdm.CommandRequest) (*mdm.Payload, error)
}

Directories

Path Synopsis
internal
commandproto
Package commandproto is a generated protocol buffer package.
Package commandproto is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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