watcher

package
v0.2.0-alpha Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseWatcher

func CloseWatcher() error

func InitWatcher

func InitWatcher(ctx context.Context)

func RegisterConsumer

func RegisterConsumer(ctx context.Context, id string, filters ...common.PayloadFilterFunc) (common.Consumer, error)

func RegisterProducer

func RegisterProducer(ctx context.Context, id string) (common.Producer, error)

func WithAll

WithAll returns a filter function that returns true if all of the provided filters return true.

func WithAny

WithAny returns a filter function that returns true if any of the provided filters return true. This filter is useful if for example you want to watch for update operations on any of the supplied entities. Example:

// Watch for any update operation on repositories or organizations
consumer.SetFilters(
	watcher.WithOperationTypeFilter(common.UpdateOperation),
	watcher.WithAny(
		watcher.WithEntityTypeFilter(common.RepositoryEntityType),
		watcher.WithEntityTypeFilter(common.OrganizationEntityType),
))

func WithEntityFilter

func WithEntityFilter(entity params.ForgeEntity) dbCommon.PayloadFilterFunc

WithEntityFilter returns a filter function that filters payloads by entity. Change payloads that match the entity type and ID will return true.

func WithEntityJobFilter

func WithEntityJobFilter(ghEntity params.ForgeEntity) dbCommon.PayloadFilterFunc

func WithEntityPoolFilter

func WithEntityPoolFilter(ghEntity params.ForgeEntity) dbCommon.PayloadFilterFunc

WithEntityPoolFilter returns true if the change payload is a pool that belongs to the supplied Github entity. This is useful when an entity worker wants to watch for changes in pools that belong to it.

func WithEntityScaleSetFilter

func WithEntityScaleSetFilter(ghEntity params.ForgeEntity) dbCommon.PayloadFilterFunc

WithEntityScaleSetFilter returns true if the change payload is a scale set that belongs to the supplied Github entity.

func WithEntityTypeAndCallbackFilter

func WithEntityTypeAndCallbackFilter(entityType dbCommon.DatabaseEntityType, callback EntityTypeCallbackFilter) dbCommon.PayloadFilterFunc

WithEntityTypeAndCallbackFilter returns a filter function that filters payloads by entity type and the result of a callback function.

func WithEntityTypeFilter

func WithEntityTypeFilter(entityType dbCommon.DatabaseEntityType) dbCommon.PayloadFilterFunc

WithEntityTypeFilter returns a filter function that filters payloads by entity type. The filter function returns true if the payload's entity type matches the provided entity type.

func WithEverything

func WithEverything() dbCommon.PayloadFilterFunc

WithEverything returns a filter function that always returns true.

func WithExcludeEntityTypeFilter

func WithExcludeEntityTypeFilter(entityType dbCommon.DatabaseEntityType) dbCommon.PayloadFilterFunc

WithExcludeEntityTypeFilter returns a filter function that filters payloads by excluding the provided entity type.

func WithForgeCredentialsFilter

func WithForgeCredentialsFilter(creds params.ForgeCredentials) dbCommon.PayloadFilterFunc

WithForgeCredentialsFilter returns a filter function that filters payloads by Github or Gitea credentials.

func WithInstanceStatusFilter

func WithInstanceStatusFilter(statuses ...commonParams.InstanceStatus) dbCommon.PayloadFilterFunc

func WithNone

func WithNone() dbCommon.PayloadFilterFunc

WithNone returns a filter function that always returns false.

func WithOperationTypeFilter

func WithOperationTypeFilter(operationType dbCommon.OperationType) dbCommon.PayloadFilterFunc

WithOperationTypeFilter returns a filter function that filters payloads by operation type.

func WithScaleSetFilter

func WithScaleSetFilter(scaleset params.ScaleSet) dbCommon.PayloadFilterFunc

WithScaleSetFilter returns a filter function that matches a particular scale set.

func WithScaleSetInstanceFilter

func WithScaleSetInstanceFilter(scaleset params.ScaleSet) dbCommon.PayloadFilterFunc

func WithUserIDFilter

func WithUserIDFilter(userID string) dbCommon.PayloadFilterFunc

WithUserIDFilter returns a filter function that filters payloads by user ID.

Types

type EntityTypeCallbackFilter

type EntityTypeCallbackFilter func(payload dbCommon.ChangePayload) (bool, error)

EntityTypeCallbackFilter is a callback function that takes a ChangePayload and returns a boolean. This callback type is used in the WithEntityTypeAndCallbackFilter (and potentially others) when a filter needs to delegate logic to a specific callback function.

type IDGetter

type IDGetter interface {
	GetID() string
}

Jump to

Keyboard shortcuts

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