repo

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package repo is responsilbe to store services and servers in a (etcd) repository.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("not found")
)

Common errors

Functions

func IDGenerator

func IDGenerator() func(string) string

IDGenerator returns a uuid generator.

Types

type Event

type Event int

Event represents a repo event. The possible valid values are Change and Delete.

const (
	Unknown Event = iota
	Change
	Delete
)

All known events. An Unknown event should never occur.

func (Event) String

func (i Event) String() string

type Namespace

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

Namespace represents the server repository.

func NewNamespace

func NewNamespace(backend store.Backend) *Namespace

NewNamespace creates a new namespace repo.

func (*Namespace) Chan added in v0.2.2

func (n *Namespace) Chan(ctx context.Context, errorHandler func(error)) <-chan *NamespaceEvent

Chan returns read-only channel of server events.

func (*Namespace) Delete

func (n *Namespace) Delete(name string) error

Delete removes given server from backend.

func (*Namespace) Get

func (n *Namespace) Get(namespaceName string) (*discovery.Namespace, error)

Get gets a server by server name.

func (*Namespace) List

func (n *Namespace) List() (discovery.Namespaces, error)

List lists all servers (if selector is empty string). Otherwise it lists the selected servers.

func (*Namespace) Save

func (n *Namespace) Save(namespace discovery.Namespace) (*discovery.Namespace, error)

Save saves a saves a new server to backend.

type NamespaceEvent added in v0.2.2

type NamespaceEvent struct {
	discovery.Namespace
	Event Event
}

NamespaceEvent contains the server and the event (change or delete).

type Server

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

Server represents the server repository.

func NewServer

func NewServer(backend store.Backend) *Server

NewServer creates a new server repo.

func (*Server) Chan

func (s *Server) Chan(ctx context.Context, errorHandler func(error)) <-chan *ServerEvent

Chan returns read-only channel of server events.

func (*Server) Delete

func (s *Server) Delete(name string) error

Delete removes given server from backend.

func (*Server) Get

func (s *Server) Get(serverName string) (*discovery.Server, error)

Get gets a server by server name.

func (*Server) List

func (s *Server) List(selector string) (discovery.Servers, error)

List lists all servers (if selector is empty string). Otherwise it lists the selected servers.

func (*Server) Save

func (s *Server) Save(server discovery.Server) (*discovery.Server, error)

Save saves a saves a new server to backend.

type ServerEvent

type ServerEvent struct {
	discovery.Server
	Event Event
}

ServerEvent contains the server and the event (change or delete).

type Service

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

Service represents the service repository.

func NewService

func NewService(backend store.Backend) *Service

NewService creates a new service repo.

func (*Service) Chan

func (s *Service) Chan(ctx context.Context, errorHandler func(error)) <-chan *ServiceEvent

Chan returns read-only channel of service events.

func (*Service) Delete

func (s *Service) Delete(id, namespace string) error

Delete removes a service from repo.

func (*Service) DeleteFromNamespace

func (s *Service) DeleteFromNamespace(namespace string) error

DeleteFromNamespace deletes all services in namespace.

func (*Service) Get

func (s *Service) Get(id, namespace string) (*discovery.Service, error)

Get gets a service by id and namespace.

func (*Service) List

func (s *Service) List(namespace, selector string) (discovery.Services, error)

List lists all services for namespace and selector. If namespace is empty string, all selected services are returned.

func (*Service) Save

func (s *Service) Save(svc discovery.Service) (*discovery.Service, error)

Save creates or updates a service. It returns the service with the generated id.

type ServiceEvent

type ServiceEvent struct {
	discovery.Service
	Event Event
}

ServiceEvent contains the service and the event (change or delete).

Jump to

Keyboard shortcuts

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