-
Notifications
You must be signed in to change notification settings - Fork 4
/
types.go
25 lines (19 loc) · 1.12 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package gosync
import "context"
// Adapter interfaces are used to allow Sync to communicate with third party services.
type Adapter interface {
Get(ctx context.Context) (things []string, err error) // Get things in a service.
Add(ctx context.Context, things []string) error // Add things to a service.
Remove(ctx context.Context, things []string) error // Remove things from a service.
}
// Service can be used for downstream services that implement Sync in your own workflow.
type Service interface {
SyncWith(ctx context.Context, adapter Adapter) error // Sync the things in a source service with this service.
}
// ConfigKey is a configuration key to Init a new adapter.
type ConfigKey = string
// A ConfigFn is used to pass additional or custom functionality to an adapter.
type ConfigFn[T Adapter] func(T)
// InitFn is an optional adapter function that can initialise a new adapter using a static configuration.
// This is to make it easier to use an adapter in a CLI or other service that invokes adapters programmatically.
type InitFn[T Adapter] func(context.Context, map[ConfigKey]string, ...ConfigFn[T]) (T, error)