runtimevar

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

README

Runtimevar Source

The runtimevar source is a source for the Go Cloud runtimevar package

This package takes a driver.Watcher and then allows you to use it as a backend source. We expect the Snapshot value to be []byte. We use the built in encoder to decode the value. This defaults to json.

Example

A runtimevar config format in json

{
    "hosts": {
        "database": {
            "address": "10.0.0.1",
            "port": 3306
        },
        "cache": {
            "address": "10.0.0.2",
            "port": 6379
        }
    }
}

New Source

Specify runtimevar source with watcher. It will panic if not specified.

srv := runtimevar.NewSource(
	runtimevar.WithDriver(dv),
)

Config Format

To load different runtimevar formats e.g yaml, toml, xml you must specify an encoder

e := toml.NewEncoder()

src := runtimevar.NewSource(
        runtimevar.WithDriver(dv),
	source.WithEncoder(e),
)

Load Source

Load the source into config

// Create new config
conf := config.NewConfig()

// Load runtimevar source
conf.Load(src)

Documentation

Overview

package runtimevar is the source for gocloud.dev/runtimevar

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSource

func NewSource(opts ...source.Option) source.Source

func WithWatcher

func WithWatcher(dv driver.Watcher) source.Option

WithWatcher sets the runtimevar driver.Watcher

Types

This section is empty.

Jump to

Keyboard shortcuts

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