pubsub

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package pubsub provides a notifier that subscribes to an PubSub topic that watches change of configuration on GCP.

It requires following roles on the target project:

  • roles/pubsub.editor

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Notifier

type Notifier struct {
	// contains filtered or unexported fields
}

Notifier that watches change events on given PubSub topic.

To create a new Notifier, call NewNotifier.

func NewNotifier

func NewNotifier(topic string, opts ...Option) *Notifier

NewNotifier creates a Notifier with the given PubSub topic.

func (*Notifier) Register

func (n *Notifier) Register(loaders ...loader)

Register registers a loader to the Notifier.

func (*Notifier) Start

func (n *Notifier) Start(ctx context.Context) error

Start starts watching events on given PubSub topic and fanout to registered loaders. It blocks until ctx is done, or it returns an error.

type Option

type Option = option.ClientOption

Option configures the Notifier with specific options.

func WithLogHandler

func WithLogHandler(handler slog.Handler) Option

WithLogHandler provides the slog.Handler for logs from notifier.

By default, it uses handler from slog.Default().

func WithProject

func WithProject(project string) Option

WithProject provides GCP project ID.

By default, it fetches project ID from metadata server.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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