Documentation ¶
Overview ¶
Package registry is a generated GoMock package.
Index ¶
- type Cache
- type CacheOption
- type EventType
- type InstanceEvent
- type InstanceEventHandler
- type MockCache
- func (m *MockCache) EXPECT() *MockCacheMockRecorder
- func (m *MockCache) Exists(name string) bool
- func (m *MockCache) Get(name string) (*model.Service, error)
- func (m *MockCache) List() ([]string, error)
- func (m *MockCache) RegisterInstanceEventHandler(handler InstanceEventHandler)
- func (m *MockCache) RegisterServiceEventHandler(handler ServiceEventHandler)
- func (m *MockCache) Run(ctx context.Context)
- type MockCacheMockRecorder
- func (mr *MockCacheMockRecorder) Exists(name interface{}) *gomock.Call
- func (mr *MockCacheMockRecorder) Get(name interface{}) *gomock.Call
- func (mr *MockCacheMockRecorder) List() *gomock.Call
- func (mr *MockCacheMockRecorder) RegisterInstanceEventHandler(handler interface{}) *gomock.Call
- func (mr *MockCacheMockRecorder) RegisterServiceEventHandler(handler interface{}) *gomock.Call
- func (mr *MockCacheMockRecorder) Run(ctx interface{}) *gomock.Call
- type ServiceEvent
- type ServiceEventHandler
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 SyncJitter ¶
func SyncJitter(jitter float64) CacheOption
SyncJitter sets the jitter for sync frequency.
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) RegisterInstanceEventHandler ¶
func (m *MockCache) RegisterInstanceEventHandler(handler InstanceEventHandler)
RegisterInstanceEventHandler mocks base method
func (*MockCache) RegisterServiceEventHandler ¶
func (m *MockCache) RegisterServiceEventHandler(handler ServiceEventHandler)
RegisterServiceEventHandler 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 ¶
ServiceEvent represents a service event.
type ServiceEventHandler ¶
type ServiceEventHandler func(event *ServiceEvent)
ServiceEventHandler is used to handle the service event.