gcs

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package gcs loads configuration from GCP Cloud Storage.

It requires following roles on the target GCS object:

  • roles/storage.objectViewer

Change notification

By default, it periodically polls the configuration only. It also listens to change events by register it to PubSub notifier with Pub/Sub notifications for Cloud Storage.

Only OBJECT_FINALIZE events trigger polling the configuration and other type of events are ignored.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GCS

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

GCS is a Provider that loads configuration from GCP Cloud Storage.

To create a new GCS, call New.

func New

func New(uri string, opts ...Option) *GCS

New creates a GCS with the given endpoint and Option(s).

func (*GCS) Load

func (g *GCS) Load() (map[string]any, error)

func (*GCS) OnEvent added in v1.1.0

func (g *GCS) OnEvent(attributes map[string]string) error

func (*GCS) Status

func (g *GCS) Status(onStatus func(bool, error))

func (*GCS) String

func (g *GCS) String() string

func (*GCS) Watch

func (g *GCS) Watch(ctx context.Context, onChange func(map[string]any)) error

type Option

type Option = option.ClientOption

func WithPollInterval

func WithPollInterval(interval time.Duration) Option

WithPollInterval provides the interval for polling the configuration.

The default interval is 1 minute.

func WithUnmarshal

func WithUnmarshal(unmarshal func([]byte, any) error) Option

WithUnmarshal provides the function used to parses the configuration. The unmarshal function must be able to unmarshal the configuration into a map[string]any.

The default function is json.Unmarshal.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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