Documentation
¶
Index ¶
- Constants
- Variables
- func GetAttributeValueAs[T types.AttributeValue](key string, values map[string]types.AttributeValue) (T, bool)
- func IterMap[E, F any](seq iter.Seq[E], fn func(E) F) iter.Seq[F]
- func KeyValues[E, V any, K comparable](s []E, fn func(E) (K, V)) map[K]V
- func Map[E, F any](s []E, fn func(E) F) []F
- func SetAWSConfig(cfg aws.Config)
- type App
- func (app *App) ChangesList(ctx context.Context, channelID string) ([]*drive.Change, *ChannelItem, error)
- func (app *App) Cleanup(ctx context.Context, _ CleanupOption) error
- func (app *App) Close() error
- func (app *App) CreateChannel(ctx context.Context, driveID string) error
- func (app *App) DeleteChannel(ctx context.Context, item *ChannelItem) error
- func (app *App) DriveIDs(ctx context.Context) ([]string, error)
- func (app *App) Drives(ctx context.Context) ([]*drive.Drive, error)
- func (app *App) List(ctx context.Context, o ListOption) error
- func (app *App) RotateChannel(ctx context.Context, item *ChannelItem) error
- func (app *App) SendNotification(ctx context.Context, item *ChannelItem, changes []*drive.Change) error
- func (app *App) Serve(ctx context.Context, o ServeOption) error
- func (app *App) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (app *App) Sync(ctx context.Context, _ SyncOption) error
- type AppOption
- type CLI
- type ChangeEventDetail
- type ChannelAlreadyExists
- type ChannelItem
- type ChannelNotFoundError
- type CleanupOption
- type DynamoDBStorage
- func (s *DynamoDBStorage) DeleteChannel(ctx context.Context, target *ChannelItem) error
- func (s *DynamoDBStorage) FindAllChannels(ctx context.Context) (<-chan []*ChannelItem, error)
- func (s *DynamoDBStorage) FindOneByChannelID(ctx context.Context, channelID string) (*ChannelItem, error)
- func (s *DynamoDBStorage) SaveChannel(ctx context.Context, item *ChannelItem) error
- func (s *DynamoDBStorage) UpdatePageToken(ctx context.Context, target *ChannelItem) error
- type EventBridgeClient
- type EventBridgeNotification
- type FileNotification
- type FileStorage
- func (s *FileStorage) DeleteChannel(ctx context.Context, target *ChannelItem) error
- func (s *FileStorage) FindAllChannels(ctx context.Context) (<-chan []*ChannelItem, error)
- func (s *FileStorage) FindOneByChannelID(ctx context.Context, channelID string) (*ChannelItem, error)
- func (s *FileStorage) SaveChannel(ctx context.Context, item *ChannelItem) error
- func (s *FileStorage) UpdatePageToken(ctx context.Context, target *ChannelItem) error
- type ListOption
- type Notification
- type NotificationOption
- type ServeOption
- type Storage
- type StorageOption
- type SyncOption
- type TargetEntity
Constants ¶
View Source
const ( DefaultDriveID = "__default__" DefaultDriveName = "My Drive and Individual Files" )
View Source
const ( DetailTypeFileRemoved = "File Removed" DetailTypeFileTrashed = "File Move to trash" DetailTypeFileChanged = "File Changed" DetailTypeDriveRemoved = "Shared Drive Removed" DetailTypeDriveChanged = "Drive Status Changed" )
Variables ¶
View Source
var Version = "v0.5.3"
Functions ¶
func GetAttributeValueAs ¶
func GetAttributeValueAs[T types.AttributeValue](key string, values map[string]types.AttributeValue) (T, bool)
func KeyValues ¶ added in v0.5.0
func KeyValues[E, V any, K comparable](s []E, fn func(E) (K, V)) map[K]V
func SetAWSConfig ¶ added in v0.5.0
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
func New ¶
func New(cfg AppOption, storage Storage, notification Notification, gcpOpts ...option.ClientOption) (*App, error)
func (*App) ChangesList ¶
func (*App) Cleanup ¶ added in v0.5.0
func (app *App) Cleanup(ctx context.Context, _ CleanupOption) error
func (*App) CreateChannel ¶
func (*App) DeleteChannel ¶
func (app *App) DeleteChannel(ctx context.Context, item *ChannelItem) error
func (*App) RotateChannel ¶
func (app *App) RotateChannel(ctx context.Context, item *ChannelItem) error
func (*App) SendNotification ¶ added in v0.3.0
func (app *App) SendNotification(ctx context.Context, item *ChannelItem, changes []*drive.Change) error
type CLI ¶ added in v0.5.0
type CLI struct { LogLevel string `help:"log level" default:"info" env:"GDNOTIFY_LOG_LEVEL"` LogFormat string `help:"log format" default:"text" enum:"text,json" env:"GDNOTIFY_LOG_FORMAT"` LogColor bool `help:"enable color output" default:"true" env:"GDNOTIFY_LOG_COLOR" negatable:""` Version kong.VersionFlag `help:"show version"` Storage StorageOption `embed:"" prefix:"storage-"` Nootification NotificationOption `embed:"" prefix:"notification-"` AppOption `embed:""` List ListOption `cmd:"" help:"list notification channels"` Serve ServeOption `cmd:"" help:"serve webhook server" default:"true"` Cleanup CleanupOption `cmd:"" help:"remove all notification channels"` Sync SyncOption `` /* 153-byte string literal not displayed */ }
type ChangeEventDetail ¶ added in v0.2.0
type ChangeEventDetail struct { Subject string `json:"subject"` Entity *TargetEntity `json:"entity"` Actor *drive.User `json:"actor"` Change *drive.Change `json:"change"` }
func (*ChangeEventDetail) DetailType ¶ added in v0.2.0
func (e *ChangeEventDetail) DetailType() string
func (*ChangeEventDetail) MarshalJSON ¶ added in v0.2.0
func (e *ChangeEventDetail) MarshalJSON() ([]byte, error)
func (*ChangeEventDetail) Source ¶ added in v0.2.0
func (e *ChangeEventDetail) Source(sourcePrefix string) string
type ChannelAlreadyExists ¶
type ChannelAlreadyExists struct {
ChannelID string
}
func (*ChannelAlreadyExists) Error ¶
func (err *ChannelAlreadyExists) Error() string
type ChannelItem ¶
type ChannelItem struct { ChannelID string Expiration time.Time PageToken string ResourceID string DriveID string PageTokenFetchedAt time.Time CreatedAt time.Time UpdatedAt time.Time }
func NewChannelItemWithDynamoDBAttributeValues ¶
func NewChannelItemWithDynamoDBAttributeValues(values map[string]types.AttributeValue) *ChannelItem
func (*ChannelItem) IsAboutToExpired ¶
func (*ChannelItem) ToDynamoDBAttributeValues ¶
func (item *ChannelItem) ToDynamoDBAttributeValues() map[string]types.AttributeValue
type ChannelNotFoundError ¶ added in v0.5.0
type ChannelNotFoundError struct {
ChannelID string
}
func (*ChannelNotFoundError) Error ¶ added in v0.5.0
func (err *ChannelNotFoundError) Error() string
type CleanupOption ¶ added in v0.5.0
type CleanupOption struct { }
type DynamoDBStorage ¶
type DynamoDBStorage struct {
// contains filtered or unexported fields
}
func NewDynamoDBStorage ¶
func NewDynamoDBStorage(ctx context.Context, cfg StorageOption) (*DynamoDBStorage, error)
func (*DynamoDBStorage) DeleteChannel ¶
func (s *DynamoDBStorage) DeleteChannel(ctx context.Context, target *ChannelItem) error
func (*DynamoDBStorage) FindAllChannels ¶
func (s *DynamoDBStorage) FindAllChannels(ctx context.Context) (<-chan []*ChannelItem, error)
func (*DynamoDBStorage) FindOneByChannelID ¶
func (s *DynamoDBStorage) FindOneByChannelID(ctx context.Context, channelID string) (*ChannelItem, error)
func (*DynamoDBStorage) SaveChannel ¶
func (s *DynamoDBStorage) SaveChannel(ctx context.Context, item *ChannelItem) error
func (*DynamoDBStorage) UpdatePageToken ¶
func (s *DynamoDBStorage) UpdatePageToken(ctx context.Context, target *ChannelItem) error
type EventBridgeClient ¶
type EventBridgeClient interface {
PutEvents(ctx context.Context, params *eventbridge.PutEventsInput, optFns ...func(*eventbridge.Options)) (*eventbridge.PutEventsOutput, error)
}
type EventBridgeNotification ¶
type EventBridgeNotification struct {
// contains filtered or unexported fields
}
func (*EventBridgeNotification) SendChanges ¶
func (n *EventBridgeNotification) SendChanges(ctx context.Context, item *ChannelItem, changes []*drive.Change) error
type FileNotification ¶
type FileNotification struct {
// contains filtered or unexported fields
}
func NewFileNotification ¶
func NewFileNotification(_ context.Context, cfg NotificationOption) (*FileNotification, error)
func (*FileNotification) SendChanges ¶
func (n *FileNotification) SendChanges(ctx context.Context, _ *ChannelItem, changes []*drive.Change) error
type FileStorage ¶
type FileStorage struct { Items []*ChannelItem LockFile string FilePath string // contains filtered or unexported fields }
func NewFileStorage ¶
func NewFileStorage(_ context.Context, cfg StorageOption) (*FileStorage, error)
func (*FileStorage) DeleteChannel ¶
func (s *FileStorage) DeleteChannel(ctx context.Context, target *ChannelItem) error
func (*FileStorage) FindAllChannels ¶
func (s *FileStorage) FindAllChannels(ctx context.Context) (<-chan []*ChannelItem, error)
func (*FileStorage) FindOneByChannelID ¶
func (s *FileStorage) FindOneByChannelID(ctx context.Context, channelID string) (*ChannelItem, error)
func (*FileStorage) SaveChannel ¶
func (s *FileStorage) SaveChannel(ctx context.Context, item *ChannelItem) error
func (*FileStorage) UpdatePageToken ¶
func (s *FileStorage) UpdatePageToken(ctx context.Context, target *ChannelItem) error
type ListOption ¶ added in v0.5.0
type Notification ¶
type Notification interface {
SendChanges(context.Context, *ChannelItem, []*drive.Change) error
}
func NewEventBridgeNotification ¶
func NewEventBridgeNotification(_ context.Context, cfg NotificationOption) (Notification, error)
func NewNotification ¶
func NewNotification(ctx context.Context, cfg NotificationOption) (Notification, error)
type NotificationOption ¶ added in v0.5.0
type NotificationOption struct { Type string `help:"notification type" default:"eventbridge" enum:"eventbridge,file" env:"GDNOTIFY_NOTIFICATION_TYPE"` EventBus string `help:"event bus name (eventbridge type only)" default:"default" env:"GDNOTIFY_EVENTBRIDGE_EVENT_BUS"` EventFile string `help:"event file path (file type only)" default:"gdnotify.json" env:"GDNOTIFY_EVENT_FILE"` }
type ServeOption ¶ added in v0.5.0
type ServeOption struct {
Port int `help:"webhook httpd port" default:"25254" env:"GDNOTIFY_PORT"`
}
type Storage ¶
type Storage interface { FindAllChannels(context.Context) (<-chan []*ChannelItem, error) FindOneByChannelID(context.Context, string) (*ChannelItem, error) UpdatePageToken(context.Context, *ChannelItem) error SaveChannel(context.Context, *ChannelItem) error DeleteChannel(context.Context, *ChannelItem) error }
func NewStorage ¶
func NewStorage(ctx context.Context, cfg StorageOption) (Storage, error)
type StorageOption ¶ added in v0.5.0
type StorageOption struct { Type string `help:"storage type" default:"dynamodb" enum:"dynamodb,file" env:"GDNOTIFY_STORAGE_TYPE"` TableName string `help:"dynamodb table name" default:"gdnotify" env:"GDNOTIFY_DDB_TABLE_NAME"` AutoCreate bool `help:"auto create dynamodb table" default:"false" env:"GDNOTIFY_DDB_AUTO_CREATE" negatable:""` DynamoDBEndpoint string `help:"dynamodb endpoint" env:"GDNOTIFY_DDB_ENDPOINT"` DataFile string `help:"file storage data file" default:"gdnotify.dat" env:"GDNOTIFY_FILE_STORAGE_DATA_FILE"` LockFile string `help:"file storage lock file" default:"gdnotify.lock" env:"GDNOTIFY_FILE_STORAGE_LOCK_FILE"` }
type SyncOption ¶ added in v0.5.0
type SyncOption struct { }
Source Files
¶
Click to show internal directories.
Click to hide internal directories.