Documentation
¶
Index ¶
- Constants
- Variables
- func GetExpandableAnnotation(annos annotations.Annotations) (*v2.GrantExpandable, error)
- func GetExternalResourceMatchAllAnnotation(annos annotations.Annotations) (*v2.ExternalResourceMatchAll, error)
- func GetExternalResourceMatchAnnotation(annos annotations.Annotations) (*v2.ExternalResourceMatch, error)
- func GetExternalResourceMatchIDAnnotation(annos annotations.Annotations) (*v2.ExternalResourceMatchID, error)
- func IsSyncPreservable(err error) bool
- type Action
- type ActionOp
- type Progress
- type State
- type SyncOpt
- func WithC1ZPath(path string) SyncOpt
- func WithConnectorStore(store connectorstore.InternalWriter) SyncOpt
- func WithDontExpandGrants() SyncOpt
- func WithExternalResourceC1ZPath(path string) SyncOpt
- func WithExternalResourceEntitlementIdFilter(entitlementId string) SyncOpt
- func WithOnlyExpandGrants() SyncOpt
- func WithProgressHandler(f func(s *Progress)) SyncOpt
- func WithRunDuration(d time.Duration) SyncOpt
- func WithSessionStore(sessionStore sessions.SetSessionStore) SyncOpt
- func WithSkipEntitlementsAndGrants(skip bool) SyncOpt
- func WithSkipFullSync() SyncOpt
- func WithSkipGrants(skip bool) SyncOpt
- func WithSyncID(syncID string) SyncOpt
- func WithSyncResourceTypes(resourceTypeIDs []string) SyncOpt
- func WithTargetedSyncResources(resources []*v2.Resource) SyncOpt
- func WithTmpDir(path string) SyncOpt
- func WithTransitionHandler(f func(s Action)) SyncOpt
- func WithWorkerCount(count int) SyncOpt
- type Syncer
Constants ¶
const StateTokenVersion = 1
If you make a breaking change to the state token, you must increment this version.
Variables ¶
var ErrNoSyncIDFound = fmt.Errorf("no syncID found after starting or resuming sync")
var ErrSyncNotComplete = fmt.Errorf("sync exited without finishing")
var ErrTooManyWarnings = fmt.Errorf("too many warnings, exiting sync")
Functions ¶
func GetExpandableAnnotation ¶ added in v0.2.92
func GetExpandableAnnotation(annos annotations.Annotations) (*v2.GrantExpandable, error)
func GetExternalResourceMatchAllAnnotation ¶ added in v0.2.84
func GetExternalResourceMatchAllAnnotation(annos annotations.Annotations) (*v2.ExternalResourceMatchAll, error)
func GetExternalResourceMatchAnnotation ¶ added in v0.2.84
func GetExternalResourceMatchAnnotation(annos annotations.Annotations) (*v2.ExternalResourceMatch, error)
func GetExternalResourceMatchIDAnnotation ¶ added in v0.2.90
func GetExternalResourceMatchIDAnnotation(annos annotations.Annotations) (*v2.ExternalResourceMatchID, error)
func IsSyncPreservable ¶ added in v0.6.18
IsSyncPreservable returns true if the error returned by Sync() means that the sync artifact is useful. This either means that there was no error, or that the error is recoverable (we can resume the sync and possibly succeed next time).
Types ¶
type Action ¶
type Action struct {
ID string `json:"id,omitempty"`
Op ActionOp `json:"operation,omitempty"`
PageToken string `json:"page_token,omitempty"`
ResourceTypeID string `json:"resource_type_id,omitempty"`
ResourceID string `json:"resource_id,omitempty"`
ParentResourceTypeID string `json:"parent_resource_type_id,omitempty"`
ParentResourceID string `json:"parent_resource_id,omitempty"`
}
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 SyncExternalResourcesOp SyncAssetsOp SyncGrantExpansionOp SyncTargetedResourceOp SyncStaticEntitlementsOp )
Do not change the order of these constants, and only append new ones at the end. Otherwise resuming a sync started by an older version of baton-sdk will cause very strange behavior.
func (ActionOp) MarshalJSON ¶
MarshalJSON marshals the ActionOp into a json string.
func (ActionOp) String ¶
String() returns the string representation for an ActionOp. This is used for marshalling the op.
func (*ActionOp) UnmarshalJSON ¶
UnmarshalJSON unmarshals the input byte slice and updates this action op.
type Progress ¶ added in v0.0.25
type Progress struct {
Action string
ResourceTypeID string
ResourceID string
ParentResourceTypeID string
ParentResourceID string
Count uint32
}
func NewProgress ¶ added in v0.0.25
type State ¶
type State interface {
PushAction(ctx context.Context, action Action)
FinishAction(ctx context.Context, action *Action)
NextPage(ctx context.Context, actionID string, pageToken string) error
EntitlementGraph(ctx context.Context) *expand.EntitlementGraph
ClearEntitlementGraph(ctx context.Context)
Current() *Action
GetAction(id string) *Action
PeekMatchingActions(ctx context.Context, op ActionOp) []*Action
Marshal() (string, error)
Unmarshal(input string) error
NeedsExpansion() bool
SetNeedsExpansion()
HasExternalResourcesGrants() bool
SetHasExternalResourcesGrants()
ShouldFetchRelatedResources() bool
SetShouldFetchRelatedResources()
ShouldSkipEntitlementsAndGrants() bool
SetShouldSkipEntitlementsAndGrants()
ShouldSkipGrants() bool
SetShouldSkipGrants()
GetCompletedActionsCount() uint64
}
type SyncOpt ¶
type SyncOpt func(s *syncer)
func WithC1ZPath ¶ added in v0.1.0
WithC1ZPath sets the path to the c1z file. Either this or WithConnectorStore must be provided to create a new syncer.
func WithConnectorStore ¶ added in v0.1.0
func WithConnectorStore(store connectorstore.InternalWriter) SyncOpt
WithConnectorStore sets the connector store to use. This is the preferred option. Either this or WithC1ZPath must be provided to create a new syncer.
func WithDontExpandGrants ¶ added in v0.3.48
func WithDontExpandGrants() SyncOpt
WithDontExpandGrants sets whether to skip expanding grants. This is used for speeding up service mode connectors and reducing their c1z upload size. C1 will process the uploaded c1z and expand grants itself.
func WithExternalResourceC1ZPath ¶ added in v0.2.84
func WithExternalResourceEntitlementIdFilter ¶ added in v0.2.84
func WithOnlyExpandGrants ¶ added in v0.3.8
func WithOnlyExpandGrants() SyncOpt
WithOnlyExpandGrants sets whether to skip syncing resources and only expand grants.
func WithProgressHandler ¶ added in v0.0.25
WithProgressHandler sets a `progressHandler` for `NewSyncer` Options. The progress handler is called for sync action, such as listing resources, entitlements, grants, etc. If running in parallel mode, this function must be thread-safe.
func WithRunDuration ¶
WithRunDuration sets a `time.Duration` for `NewSyncer` Options. `d` represents a duration. The elapsed time between two instants as an int64 nanosecond count.
func WithSessionStore ¶ added in v0.5.0
func WithSessionStore(sessionStore sessions.SetSessionStore) SyncOpt
func WithSkipEntitlementsAndGrants ¶ added in v0.3.40
WithSkipEntitlementsAndGrants sets whether to skip syncing entitlements and grants for resources. If true, only resources will be synced.
func WithSkipFullSync ¶ added in v0.2.15
func WithSkipFullSync() SyncOpt
WithSkipFullSync skips syncing entirely.
func WithSkipGrants ¶ added in v0.5.1
WithSkipGrants sets whether to skip syncing grants for resources. Entitlements will still be synced.
func WithSyncID ¶ added in v0.3.8
func WithSyncResourceTypes ¶ added in v0.5.0
WithSyncResourceTypes sets the resource types to sync. If empty (the default), all resource types will be synced.
func WithTargetedSyncResources ¶ added in v0.6.6
func WithTmpDir ¶ added in v0.1.8
func WithTransitionHandler ¶
WithTransitionHandler sets a `transitionHandler` for `NewSyncer` Options.
func WithWorkerCount ¶ added in v0.8.0
WithWorkerCount sets the number of workers to use. If 0, sequential sync is used. If > 0, parallel sync is used. If -1, the number of workers is set to the number of CPU cores or 4, whichever is lower. If < -1, sequential sync is used. Yes, this allows for a "parallel" sync with one worker, effectively making it sequential.