sync

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2019 License: MIT Imports: 20 Imported by: 5

Documentation

Index

Constants

View Source
const (
	SyncTopic = "mdm.DepSync"
)

Variables

This section is empty.

Functions

func MakeApplyAutoAssignerEndpoint

func MakeApplyAutoAssignerEndpoint(s Service) endpoint.Endpoint

func MakeGetAutoAssignersEndpoint

func MakeGetAutoAssignersEndpoint(s Service) endpoint.Endpoint

func MakeRemoveAutoAssignerEndpoint

func MakeRemoveAutoAssignerEndpoint(s Service) endpoint.Endpoint

func MakeSyncNowEndpoint

func MakeSyncNowEndpoint(s Service) endpoint.Endpoint

func MarshalEvent

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

MarshalEvent serializes an event to a protocol buffer wire format.

func RegisterHTTPHandlers

func RegisterHTTPHandlers(r *mux.Router, e Endpoints, options ...httptransport.ServerOption)

func UnmarshalEvent

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

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

Types

type AutoAssigner

type AutoAssigner struct {
	Filter      string `json:"filter"`
	ProfileUUID string `json:"profile_uuid"`
}

type Client

type Client interface {
	FetchDevices(...dep.DeviceRequestOption) (*dep.DeviceResponse, error)
	SyncDevices(string, ...dep.DeviceRequestOption) (*dep.DeviceResponse, error)
	AssignProfile(string, ...string) (*dep.ProfileResponse, error)
}

type Cursor

type Cursor struct {
	Value     string    `json:"value"`
	CreatedAt time.Time `json:"created_at"`
}

func (Cursor) Valid

func (c Cursor) Valid() bool

A cursor is valid for a week.

type DB

type DB interface {
	SaveAutoAssigner(a *AutoAssigner) error
	LoadAutoAssigners() ([]AutoAssigner, error)
	DeleteAutoAssigner(filter string) error
}

type DEPSyncService

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

func NewService

func NewService(syncer Syncer, db DB) *DEPSyncService

func (DEPSyncService) ApplyAutoAssigner

func (s DEPSyncService) ApplyAutoAssigner(ctx context.Context, aa *AutoAssigner) error

func (DEPSyncService) GetAutoAssigners

func (s DEPSyncService) GetAutoAssigners(ctx context.Context) ([]AutoAssigner, error)

func (DEPSyncService) RemoveAutoAssigner

func (s DEPSyncService) RemoveAutoAssigner(ctx context.Context, filter string) error

func (*DEPSyncService) SyncNow

func (s *DEPSyncService) SyncNow(_ context.Context) error

type Endpoints

type Endpoints struct {
	SyncNowEndpoint            endpoint.Endpoint
	ApplyAutoAssignerEndpoint  endpoint.Endpoint
	GetAutoAssignersEndpoint   endpoint.Endpoint
	RemoveAutoAssignerEndpoint endpoint.Endpoint
}

func MakeServerEndpoints

func MakeServerEndpoints(s Service, outer endpoint.Middleware, others ...endpoint.Middleware) Endpoints

func (Endpoints) ApplyAutoAssigner

func (e Endpoints) ApplyAutoAssigner(ctx context.Context, aa *AutoAssigner) error

func (Endpoints) GetAutoAssigners

func (e Endpoints) GetAutoAssigners(ctx context.Context) ([]AutoAssigner, error)

func (Endpoints) RemoveAutoAssigner

func (e Endpoints) RemoveAutoAssigner(ctx context.Context, filter string) error

func (Endpoints) SyncNow

func (e Endpoints) SyncNow(ctx context.Context) error

type Event

type Event struct {
	ID      string
	Time    time.Time
	Devices []dep.Device
}

func NewEvent

func NewEvent(devices []dep.Device) *Event

type Option

type Option func(*Watcher)

func WithClient

func WithClient(client Client) Option

func WithLogger

func WithLogger(logger log.Logger) Option

type Service

type Service interface {
	SyncNow(context.Context) error
	ApplyAutoAssigner(context.Context, *AutoAssigner) error
	GetAutoAssigners(context.Context) ([]AutoAssigner, error)
	RemoveAutoAssigner(context.Context, string) error
}

func NewHTTPClient

func NewHTTPClient(instance, token string, logger log.Logger, opts ...httptransport.ClientOption) (Service, error)

type Syncer

type Syncer interface{ SyncNow() }

type Watcher

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

func NewWatcher

func NewWatcher(db WatcherDB, pub pubsub.PublishSubscriber, opts ...Option) (*Watcher, error)

func (*Watcher) Run

func (w *Watcher) Run() error

func (*Watcher) SyncNow

func (w *Watcher) SyncNow()

type WatcherDB

type WatcherDB interface {
	LoadCursor() (*Cursor, error)
	SaveCursor(c Cursor) error
	LoadAutoAssigners() ([]AutoAssigner, error)
}

Directories

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

Jump to

Keyboard shortcuts

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