v1

package
v0.0.0-...-da4ef6a Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultReceiveSettings = pubsub.DefaultReceiveSettings

Functions

func NewSubscriber

func NewSubscriber(logger log.Logger, opts SubscriberOptions) (background.Routine, error)

NewSubscriber creates a new background routine for receiving SAMS notifications from given GCP project ID and Pub/Sub subscription ID.

Users should prefer to use the top-level 'sams.NewNotificationsV1Subscriber' constructor instead.

Types

type ReceiveSettings

type ReceiveSettings = pubsub.ReceiveSettings

type SubscriberHandlers

type SubscriberHandlers struct {
	// OnUserDeleted is called when a "UserDeleted" notification is received.
	//
	// It indicates that a user has been permanently deleted from SAMS and the
	// handler MUST delete any user-related PII from the system and/or integrated
	// vendor systems to stay in compliance. In the event of an error, the handler
	// MUST make sure the error is surfaced (by either returning or logging the
	// error) to be retried or to a human operator.
	OnUserDeleted func(ctx context.Context, data *UserDeletedData) error
}

SubscriberHandlers is a collection of subscription handlers for each type of SAMS notifications. If the handler of a notification is nil, the notification will be acknowledged automatically without any processing.

If a handler returns an error, the notification will be unacknowledged and retried later.

type SubscriberOptions

type SubscriberOptions struct {
	// ProjectID is the GCP project ID that the Pub/Sub subscription belongs to. It
	// is almost always the same GCP project that the Cloud Run service is deployed
	// to.
	ProjectID string
	// SubscriptionID is the GCP Pub/Sub subscription ID to receive SAMS
	// notifications from.
	SubscriptionID string
	// ReceiveSettings is the settings for receiving messages of the subscription. A
	// zero value means to use the default settings.
	ReceiveSettings ReceiveSettings
	// Handlers is the collection of subscription handlers for each type of SAMS
	// notifications.
	Handlers SubscriberHandlers
	// Credentials is the account credentials to be used for the GCP Pub/Sub client.
	// Default credentials will be used when not set.
	Credentials *google.Credentials
}

func (SubscriberOptions) Validate

func (opts SubscriberOptions) Validate() error

type UserDeletedData

type UserDeletedData struct {
	// AccountID is the SAMS external ID of the deleted user.
	AccountID string `json:"account_id"`
	// Email is the email address of the deleted user.
	Email string `json:"email"`
}

UserDeletedData contains information of a "UserDeleted" notification.

Jump to

Keyboard shortcuts

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