sync

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSyncNotComplete = fmt.Errorf("sync exited without finishing")
)

Functions

This section is empty.

Types

type Action

type Action struct {
	Op             ActionOp `json:"operation"`
	PageToken      string   `json:"page_token"`
	ResourceTypeID string   `json:"resource_type_id"`
	ResourceID     string   `json:"resource_id"`
}

Action stores the current operation, page token, and optional fields for which resource is being worked with.

type ActionOp

type ActionOp uint8

ActionOp represents a sync operation.

const (
	UnknownOp ActionOp = iota
	InitOp
	SyncResourceTypesOp
	SyncResourcesOp
	SyncEntitlementsOp
	ListResourcesForEntitlementsOp
	SyncGrantsOp
	SyncAssetsOp
)

func (*ActionOp) MarshalJSON

func (s *ActionOp) MarshalJSON() ([]byte, error)

MarshalJSON marshals the ActionOp insto a json string.

func (ActionOp) String

func (s ActionOp) String() string

String() returns the string representation for an ActionOp. This is used for marshalling the op.

func (*ActionOp) UnmarshalJSON

func (s *ActionOp) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshal's the input byte slice and updates this action op.

type State

type State interface {
	PushAction(ctx context.Context, action Action)
	FinishAction(ctx context.Context)
	NextPage(ctx context.Context, pageToken string) error
	ResourceTypeID(ctx context.Context) string
	ResourceID(ctx context.Context) string
	PageToken(ctx context.Context) string
	Current() *Action
	Marshal() (string, error)
	Unmarshal(input string) error
}

type SyncOpt

type SyncOpt func(s *syncer)

func WithRunDuration

func WithRunDuration(d time.Duration) SyncOpt

WithRunDuration sets a `time.Duration` for `NewSyncer` Options. `d` represents a duration. The elapsed time between two instants as an int64 nanosecond count.

func WithTransitionHandler

func WithTransitionHandler(f func(s Action)) SyncOpt

WithTransitionHandler sets a `transitionHandler` for `NewSyncer` Options.

type Syncer

type Syncer interface {
	Sync(ctx context.Context) error
	Close() error
}

func NewSyncer

func NewSyncer(store connectorstore.Writer, c types.ClientWrapper, opts ...SyncOpt) Syncer

NewSyncer returns a new syncer object.

Jump to

Keyboard shortcuts

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