registry

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2021 License: MIT Imports: 4 Imported by: 5 modules, 5 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultRegistry Registry

	// ErrNotFound not found error when GetService is called
	ErrNotFound = errors.New("service not found")
	// ErrWatcherStopped watcher stopped error when watcher is stopped
	ErrWatcherStopped = errors.New("watcher stopped")
)

Functions

func Deregister

func Deregister(s *Service) error

Deregister a service node

func Register

func Register(s *Service, opts ...RegisterOption) error

Register a service node. Additionally supply options such as TTL.

func String

func String() string

Types

type APIKeysSecurity added in v0.23.0

type APIKeysSecurity struct {
	Type string `json:"type,omitempty"`
	// header
	In   string `json:"in,omitempty"`
	Name string `json:"name,omitempty"`
}

APIKeysSecurity is swagger API keys Authorization security (https://swagger.io/docs/specification/authentication/api-keys/)

type ApplicationContent added in v0.23.0

type ApplicationContent struct {
	Schema *Schema `json:"schema,omitempty"`
}

type BasicSecurity added in v0.23.0

type BasicSecurity struct {
	// http, apiKey, oauth, openIdConnect
	Type   string `json:"type,omitempty"`
	Scheme string `json:"scheme,omitempty"`
}

BasicSecurity is swagger Basic Authorization security (https://swagger.io/docs/specification/authentication/basic-authentication/)

type BearerSecurity added in v0.23.0

type BearerSecurity struct {
	// http
	Type   string `json:"type,omitempty"`
	Scheme string `json:"scheme,omitempty"`
	// JWT
	BearerFormat string `json:"bearerFormat,omitempty"`
}

BearerSecurity is swagger Bearer Authorization security (https://swagger.io/docs/specification/authentication/bearer-authentication/)

type DeregisterOption

type DeregisterOption func(*DeregisterOptions)

func DeregisterContext

func DeregisterContext(ctx context.Context) DeregisterOption

type DeregisterOptions

type DeregisterOptions struct {
	Context context.Context
}

type Endpoint added in v0.23.0

type Endpoint struct {
	Name     string            `json:"name,omitempty"`
	Request  *Value            `json:"request,omitempty"`
	Response *Value            `json:"response,omitempty"`
	Metadata map[string]string `json:"metadata,omitempty"`
}

Endpoint is a endpoint provided by a service

type Event added in v0.23.0

type Event struct {
	// Event Id
	Id string `json:"id,omitempty"`
	// type of event
	Type EventType `json:"type,omitempty"`
	// unix timestamp of event
	Timestamp int64 `json:"timestamp,omitempty"`
	// service entry
	Service *Service `json:"service,omitempty"`
}

Event is registry event

type EventType added in v0.23.0

type EventType string
const (
	EventCreate EventType = "Create"
	EventUpdate EventType = "Update"
	EventDelete EventType = "Delete"
)

type GetOption

type GetOption func(*GetOptions)

func GetContext

func GetContext(ctx context.Context) GetOption

type GetOptions

type GetOptions struct {
	Context context.Context
}

type ListOption

type ListOption func(*ListOptions)

func ListContext

func ListContext(ctx context.Context) ListOption

type ListOptions

type ListOptions struct {
	Context context.Context
}

type Model added in v0.23.0

type Model struct {
	// string, number, integer, boolean, array, object
	Type       string             `json:"type,omitempty"`
	Properties map[string]*Schema `json:"properties,omitempty"`
	Required   []string           `json:"required,omitempty"`
}

Model is swagger data models (https://swagger.io/docs/specification/data-models/)

type Node added in v0.23.0

type Node struct {
	Id       string            `json:"id,omitempty"`
	Address  string            `json:"address,omitempty"`
	Port     int64             `json:"port,omitempty"`
	Metadata map[string]string `json:"metadata,omitempty"`
}

Node represents the node the service is on

type OpenAPI added in v0.23.0

type OpenAPI struct {
	Openapi      string                  `json:"openapi,omitempty"`
	Info         *OpenAPIInfo            `json:"info,omitempty"`
	ExternalDocs *OpenAPIExternalDocs    `json:"externalDocs,omitempty"`
	Servers      []*OpenAPIServer        `json:"servers,omitempty"`
	Tags         []*OpenAPITag           `json:"tags,omitempty"`
	Paths        map[string]*OpenAPIPath `json:"paths,omitempty"`
	Components   *OpenAPIComponents      `json:"components,omitempty"`
}

type OpenAPIComponents added in v0.23.0

type OpenAPIComponents struct {
	SecuritySchemes *SecuritySchemes  `json:"securitySchemes,omitempty"`
	Schemas         map[string]*Model `json:"schemas,omitempty"`
}

type OpenAPIContact added in v0.23.0

type OpenAPIContact struct {
	Name  string `json:"name,omitempty"`
	Email string `json:"email,omitempty"`
}

type OpenAPIExternalDocs added in v0.23.0

type OpenAPIExternalDocs struct {
	Description string `json:"description,omitempty"`
	Url         string `json:"url,omitempty"`
}

type OpenAPIInfo added in v0.23.0

type OpenAPIInfo struct {
	Title          string          `json:"title,omitempty"`
	Description    string          `json:"description,omitempty"`
	TermsOfService string          `json:"termsOfService,omitempty"`
	Contact        *OpenAPIContact `json:"contact,omitempty"`
	License        *OpenAPILicense `json:"license,omitempty"`
	Version        string          `json:"version,omitempty"`
}

type OpenAPILicense added in v0.23.0

type OpenAPILicense struct {
	Name string `json:"name,omitempty"`
	Url  string `json:"url,omitempty"`
}

type OpenAPIOption

type OpenAPIOption func(*OpenAPIOptions)

type OpenAPIOptions

type OpenAPIOptions struct {
	Context context.Context
}

type OpenAPIPath added in v0.23.0

type OpenAPIPath struct {
	Get    *OpenAPIPathDocs `json:"get,omitempty"`
	Post   *OpenAPIPathDocs `json:"post,omitempty"`
	Put    *OpenAPIPathDocs `json:"put,omitempty"`
	Patch  *OpenAPIPathDocs `json:"patch,omitempty"`
	Delete *OpenAPIPathDocs `json:"delete,omitempty"`
}

type OpenAPIPathDocs added in v0.23.0

type OpenAPIPathDocs struct {
	Tags        []string                 `json:"tags,omitempty"`
	Summary     string                   `json:"summary,omitempty"`
	Description string                   `json:"description,omitempty"`
	OperationId string                   `json:"operationId,omitempty"`
	Deprecated  bool                     `json:"deprecated,omitempty"`
	RequestBody *PathRequestBody         `json:"requestBody,omitempty"`
	Parameters  []*PathParameters        `json:"parameters,omitempty"`
	Responses   map[string]*PathResponse `json:"responses,omitempty"`
	Security    []*PathSecurity          `json:"security,omitempty"`
}

type OpenAPIServer added in v0.23.0

type OpenAPIServer struct {
	Url         string `json:"url,omitempty"`
	Description string `json:"Description,omitempty"`
}

type OpenAPITag added in v0.23.0

type OpenAPITag struct {
	Name         string               `json:"name,omitempty"`
	Description  string               `json:"description,omitempty"`
	ExternalDocs *OpenAPIExternalDocs `json:"externalDocs,omitempty"`
}

type Option

type Option func(*Options)

func Addrs

func Addrs(addrs ...string) Option

Addrs is the registry addresses to use

func Secure

func Secure(b bool) Option

Secure communication with the registry

func TLSConfig

func TLSConfig(t *tls.Config) Option

TLSConfig Specify TLS Config

func Timeout

func Timeout(t time.Duration) Option

type Options

type Options struct {
	Addrs     []string
	Timeout   time.Duration
	Secure    bool
	TLSConfig *tls.Config
	// Other options for implementations of the interface
	// can be stored in a context
	Context context.Context
}

type PathParameters added in v0.23.0

type PathParameters struct {
	// query, cookie, path
	In              string  `json:"in,omitempty"`
	Name            string  `json:"name,omitempty"`
	Required        bool    `json:"required,omitempty"`
	Description     string  `json:"description,omitempty"`
	AllowReserved   bool    `json:"allowReserved,omitempty"`
	Style           string  `json:"style,omitempty"`
	Explode         bool    `json:"explode,omitempty"`
	AllowEmptyValue bool    `json:"allowEmptyValue,omitempty"`
	Schema          *Schema `json:"schema,omitempty"`
	Example         string  `json:"example,omitempty"`
}

type PathRequestBody added in v0.23.0

type PathRequestBody struct {
	Description string                  `json:"description,omitempty"`
	Required    bool                    `json:"required,omitempty"`
	Content     *PathRequestBodyContent `json:"content,omitempty"`
}

type PathRequestBodyContent added in v0.23.0

type PathRequestBodyContent struct {
	ApplicationJson *ApplicationContent `json:"application/json,omitempty"`
	ApplicationXml  *ApplicationContent `json:"application/xml,omitempty"`
}

type PathResponse added in v0.23.0

type PathResponse struct {
	Description string                  `json:"description,omitempty"`
	Content     *PathRequestBodyContent `json:"content,omitempty"`
}

PathResponse is swagger path response

type PathSecurity added in v0.23.0

type PathSecurity struct {
	Basic   []string `json:"basic,omitempty"`
	ApiKeys []string `json:"apiKeys,omitempty"`
	Bearer  []string `json:"bearer,omitempty"`
}

type RegisterOption

type RegisterOption func(*RegisterOptions)

func RegisterContext

func RegisterContext(ctx context.Context) RegisterOption

func RegisterTTL

func RegisterTTL(t time.Duration) RegisterOption

type RegisterOptions

type RegisterOptions struct {
	TTL time.Duration
	// Other options for implementations of the interface
	// can be stored in a context
	Context context.Context
}

type Registry

type Registry interface {
	Init(...Option) error
	Options() Options
	Register(*Service, ...RegisterOption) error
	Deregister(*Service, ...DeregisterOption) error
	GetService(string, ...GetOption) ([]*Service, error)
	ListServices(...ListOption) ([]*Service, error)
	Watch(...WatchOption) (Watcher, error)
	String() string
}

Registry the registry provides an interface for service discovery and an abstraction over varying implementations {consul, etcd, zookeeper, ...}

type Result added in v0.23.0

type Result struct {
	Action    string   `json:"action,omitempty"`
	Service   *Service `json:"service,omitempty"`
	Timestamp int64    `json:"timestamp,omitempty"`
}

Result is returns by the watcher

type Schema added in v0.23.0

type Schema struct {
	Type                 string            `json:"type,omitempty"`
	Format               string            `json:"format,omitempty"`
	Description          string            `json:"description,omitempty"`
	Example              string            `json:"example,omitempty"`
	Pattern              string            `json:"pattern,omitempty"`
	Nullable             bool              `json:"nullable,omitempty"`
	ReadOnly             bool              `json:"readOnly,omitempty"`
	WriteOnly            bool              `json:"writeOnly,omitempty"`
	Required             bool              `json:"required,omitempty"`
	Ref                  string            `json:"$ref,omitempty"`
	Default              string            `json:"default,omitempty"`
	MinLength            int32             `json:"minLength,omitempty"`
	MaxLength            int32             `json:"maxLength,omitempty"`
	MultipleOf           int32             `json:"multipleOf,omitempty"`
	Minimum              int32             `json:"minimum,omitempty"`
	ExclusiveMinimum     bool              `json:"exclusiveMinimum,omitempty"`
	Maximum              int32             `json:"maximum,omitempty"`
	ExclusiveMaximum     bool              `json:"exclusiveMaximum,omitempty"`
	Enum                 []string          `json:"enum,omitempty"`
	Items                *Schema           `json:"items,omitempty"`
	Parameters           []*PathParameters `json:"parameters,omitempty"`
	AdditionalProperties *Schema           `json:"additionalProperties,omitempty"`
}

type SecuritySchemes added in v0.23.0

type SecuritySchemes struct {
	Basic   *BasicSecurity   `json:"basic,omitempty"`
	ApiKeys *APIKeysSecurity `json:"apiKeys,omitempty"`
	Bearer  *BearerSecurity  `json:"bearer,omitempty"`
}

type Service added in v0.23.0

type Service struct {
	Name      string            `json:"name,omitempty"`
	Version   string            `json:"version,omitempty"`
	Metadata  map[string]string `json:"metadata,omitempty"`
	Endpoints []*Endpoint       `json:"endpoints,omitempty"`
	Nodes     []*Node           `json:"nodes,omitempty"`
	TTL       int64             `json:"ttl,omitempty"`
	Apis      []*OpenAPI        `json:"apis,omitempty"`
}

Service represents a vine service

func GetService

func GetService(name string) ([]*Service, error)

GetService retrieve a service. A slice is returned since we separate Name/Version.

func ListServices

func ListServices() ([]*Service, error)

ListServices list the services. Only returns service names

type Value added in v0.23.0

type Value struct {
	Name   string   `json:"name,omitempty"`
	Type   string   `json:"type,omitempty"`
	Values []*Value `json:"values,omitempty"`
}

Value is an opaque value for a request or response

type WatchOption

type WatchOption func(*WatchOptions)

func WatchContext

func WatchContext(ctx context.Context) WatchOption

func WatchService

func WatchService(name string) WatchOption

WatchService watches a service

type WatchOptions

type WatchOptions struct {
	// Specify a service to watch
	// If blank, the watch is for all services
	Service string
	// Other options for implementations of the interface
	// can be stored in a context
	Context context.Context
}

type Watcher

type Watcher interface {
	// Next is a blocking call
	Next() (*Result, error)
	Stop()
}

Watcher is an interface that returns updates about services within the registry.

func Watch

func Watch(opts ...WatchOption) (Watcher, error)

Watch returns a watcher which allows you to track updates to the registry.

Directories

Path Synopsis
Package mdns provides a multicast dns registry
Package mdns provides a multicast dns registry
Package memory provides an in-memory registry
Package memory provides an in-memory registry

Jump to

Keyboard shortcuts

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