bind

package
v0.0.0-...-38decf1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Topic default top
	Topic = "go.lego.topic.bind.srv"
)

Functions

func GetMapping

func GetMapping() map[string][]*Handler

GetMapping get bind mapping

func Report

func Report(ns string, data []*Element)

Report bindings (for SRV)

func SetRegistry

func SetRegistry(r Registry)

SetRegistry set registry

func Watch

func Watch()

Watch service booting to update bindings (for API)

Types

type ConsulRegistry

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

ConsulRegistry consul registry

func NewConsulRegistry

func NewConsulRegistry(address, prefix string) *ConsulRegistry

NewConsulRegistry create new registry

func (*ConsulRegistry) Add

func (r *ConsulRegistry) Add(ns string, els []*Element)

Add binding elements

func (*ConsulRegistry) GetAll

func (r *ConsulRegistry) GetAll() map[string][]*Element

GetAll get all binding elements

type Element

type Element struct {
	ID       string `json:"id"` // event id
	Priority int
}

Element binding element

type Handler

type Handler struct {
	ID       string
	Service  eproto.EventService
	Priority int
}

Handler struct

type LocalRegistry

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

LocalRegistry local registry Use local registry to set event binding mannually for developing purpose (not recommended)

func NewLocalRegistry

func NewLocalRegistry() *LocalRegistry

NewLocalRegistry create new local registry

func (*LocalRegistry) Add

func (r *LocalRegistry) Add(name string, els []*Element)

Add binding elements

func (*LocalRegistry) GetAll

func (r *LocalRegistry) GetAll() map[string][]*Element

GetAll get all binding elements

type RedisRegistry

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

RedisRegistry redis registry

func NewRedisRegistry

func NewRedisRegistry(address, prefix string) *RedisRegistry

NewRedisRegistry create redis registry

func (*RedisRegistry) Add

func (r *RedisRegistry) Add(ns string, els []*Element)

Add add binding elements

func (*RedisRegistry) GetAll

func (r *RedisRegistry) GetAll() map[string][]*Element

GetAll get all binding elements

type Registry

type Registry interface {
	// GetAll get all binding elements.
	// srv-name => [e1, e2, ...]
	GetAll() map[string][]*Element

	Add(ns string, els []*Element)
}

Registry binding registry

Jump to

Keyboard shortcuts

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