registry

package
v0.0.0-...-62b5e1f Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package registry provides a redis registry for podchaos. Reference: https://github.com/hertz-contrib/registry/blob/e0024eacdbb74cb5e334f2d060dad90324ef29d6/redis/registry.go

Index

Constants

View Source
const (
	DefaultWeight = 10
)
View Source
const (
	Redis = "redis"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Info

type Info struct {
	// ServiceName will be set in podchaos by default
	ServiceName string
	// Addr will be set in podchaos by default
	Addr net.Addr
	// Weight will be set in podchaos by default
	Weight int
	// extend other infos with Tags.
	Tags map[string]string
}

type Instance

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

func NewInstance

func NewInstance(network, address string, weight int, tags map[string]string) Instance

func (*Instance) Address

func (i *Instance) Address() net.Addr

func (*Instance) Tag

func (i *Instance) Tag(key string) (value string, exist bool)

func (*Instance) Weight

func (i *Instance) Weight() int

type Option

type Option func(opts *redis.Options)

func WithDB

func WithDB(db int) Option

func WithDialer

func WithDialer(dialer func(ctx context.Context, network, addr string) (net.Conn, error)) Option

func WithPassword

func WithPassword(password string) Option

func WithReadTimeout

func WithReadTimeout(t time.Duration) Option

func WithTLSConfig

func WithTLSConfig(t *tls.Config) Option

type Registry

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

func NewRegistry

func NewRegistry(addr string, opts ...Option) *Registry

func (*Registry) Deregister

func (r *Registry) Deregister(info *Info) error

func (*Registry) Register

func (r *Registry) Register(info *Info) error

type Resolver

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

func NewRedisResolver

func NewRedisResolver(addr string, opts ...Option) *Resolver

func (*Resolver) Name

func (r *Resolver) Name() string

func (*Resolver) Resolve

func (r *Resolver) Resolve(ctx context.Context, desc string) (Result, error)

func (*Resolver) Target

func (r *Resolver) Target(_ context.Context, target *TargetInfo) string

type Result

type Result struct {
	CacheKey  string
	Instances []Instance
}

type TargetInfo

type TargetInfo struct {
	Host string
	Tags map[string]string
}

Jump to

Keyboard shortcuts

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