viper

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2024 License: MIT Imports: 7 Imported by: 0

README

Viper Topology Provider

The Viper topology provider allows you to work with Tarantool configuration and retrieve topology from all sources, which are supported by Viper in file formats.

There are 2 supported configuration formats: moonlibs and tarantool3.

Examples

ETCD v3
import (
	"context"
        "github.com/spf13/viper"
	_ "github.com/spf13/viper/remote" // dont forget to import remote pkg for viper remote
        vprovider "github.com/tarantool/go-vshard-router/providers/viper"
)

// ...
ctx := context.TODO()
key := "/myapp"
etcdViper := viper.New()
err = etcdViper.AddRemoteProvider("etcd3", "http://127.0.0.1:2379", key)
if err != nil {
	panic(err)
}

etcdViper.SetConfigType("yaml")
err = etcdViper.ReadRemoteConfig()
if err != nil {
panic(err)
}

provider := vprovider.NewProvider(ctx, etcdViper, vprovider.ConfigTypeTarantool3)

/// ...

Check more config examples in test dir or inside provider_test.go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigType added in v1.3.1

type ConfigType int
const (
	ConfigTypeMoonlibs ConfigType = iota
	ConfigTypeTarantool3
)

type Convertable added in v1.3.1

type Convertable interface {
	Convert() map[vshardrouter.ReplicasetInfo][]vshardrouter.InstanceInfo
}

type Provider

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

func NewProvider

func NewProvider(ctx context.Context, v *srcviper.Viper, cfgType ConfigType) *Provider

func (*Provider) Close

func (p *Provider) Close()

func (*Provider) Init

func (*Provider) Topology added in v1.3.1

func (*Provider) Validate

func (p *Provider) Validate() error

func (*Provider) WatchChanges

func (p *Provider) WatchChanges() *Provider

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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