registry

package
v0.0.0-...-ee9fa08 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package registry is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	model.ServiceRegistry
	// Exists returns whether the specified service is in.
	Exists(name string) bool

	// RegisterServiceEventHandler registers a handler to handle service event.
	RegisterServiceEventHandler(handler ServiceEventHandler)
	// RegisterInstanceEventHandler registers a handler to handle instance event.
	RegisterInstanceEventHandler(handler InstanceEventHandler)
}

Cache is used to cache all registered services from the underlying registry, and provides a notification mechanism which means the caller could receive and handle the service and instance change event.

Handlers execute on one single worker queue in the order by they are registered, and the execution is synchronous. To receive all events, all handlers must be registerd before starting the cache container.

func NewCache

func NewCache(r model.ServiceRegistry, opts ...CacheOption) Cache

NewCache creates a cache container for service registry.

type CacheOption

type CacheOption func(o *cacheOptions)

CacheOption sets the options for cache.

func SyncFreq

func SyncFreq(freq time.Duration) CacheOption

SyncFreq sets the sync frequency.

func SyncJitter

func SyncJitter(jitter float64) CacheOption

SyncJitter sets the jitter for sync frequency.

type EventType

type EventType uint8

EventType indicates the type of event.

const (
	EventAdd EventType = iota + 1
	EventUpdate
	EventDelete
)

The following shows the available event types.

type InstanceEvent

type InstanceEvent struct {
	Type        EventType
	ServiceName string
	Instances   []*model.ServiceInstance
}

InstanceEvent represents a instance event.

type InstanceEventHandler

type InstanceEventHandler func(event *InstanceEvent)

InstanceEventHandler is used to handel instance event.

type MockCache

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

MockCache is a mock of Cache interface

func NewMockCache

func NewMockCache(ctrl *gomock.Controller) *MockCache

NewMockCache creates a new mock instance

func (*MockCache) EXPECT

func (m *MockCache) EXPECT() *MockCacheMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockCache) Exists

func (m *MockCache) Exists(name string) bool

Exists mocks base method

func (*MockCache) Get

func (m *MockCache) Get(name string) (*model.Service, error)

Get mocks base method

func (*MockCache) List

func (m *MockCache) List() ([]string, error)

List mocks base method

func (*MockCache) RegisterInstanceEventHandler

func (m *MockCache) RegisterInstanceEventHandler(handler InstanceEventHandler)

RegisterInstanceEventHandler mocks base method

func (*MockCache) RegisterServiceEventHandler

func (m *MockCache) RegisterServiceEventHandler(handler ServiceEventHandler)

RegisterServiceEventHandler mocks base method

func (*MockCache) Run

func (m *MockCache) Run(ctx context.Context)

Run mocks base method

type MockCacheMockRecorder

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

MockCacheMockRecorder is the mock recorder for MockCache

func (*MockCacheMockRecorder) Exists

func (mr *MockCacheMockRecorder) Exists(name interface{}) *gomock.Call

Exists indicates an expected call of Exists

func (*MockCacheMockRecorder) Get

func (mr *MockCacheMockRecorder) Get(name interface{}) *gomock.Call

Get indicates an expected call of Get

func (*MockCacheMockRecorder) List

func (mr *MockCacheMockRecorder) List() *gomock.Call

List indicates an expected call of List

func (*MockCacheMockRecorder) RegisterInstanceEventHandler

func (mr *MockCacheMockRecorder) RegisterInstanceEventHandler(handler interface{}) *gomock.Call

RegisterInstanceEventHandler indicates an expected call of RegisterInstanceEventHandler

func (*MockCacheMockRecorder) RegisterServiceEventHandler

func (mr *MockCacheMockRecorder) RegisterServiceEventHandler(handler interface{}) *gomock.Call

RegisterServiceEventHandler indicates an expected call of RegisterServiceEventHandler

func (*MockCacheMockRecorder) Run

func (mr *MockCacheMockRecorder) Run(ctx interface{}) *gomock.Call

Run indicates an expected call of Run

type ServiceEvent

type ServiceEvent struct {
	Type    EventType
	Service *model.Service
}

ServiceEvent represents a service event.

type ServiceEventHandler

type ServiceEventHandler func(event *ServiceEvent)

ServiceEventHandler is used to handle the service event.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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