Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2021-04-25 11:58:24 +03:00
parent bae3b0ef94
commit 00a4785df3
8 changed files with 14 additions and 15 deletions

View File

@ -13,27 +13,27 @@ import (
) )
type memoryBroker struct { type memoryBroker struct {
opts Options
Subscribers map[string][]*memorySubscriber Subscribers map[string][]*memorySubscriber
addr string addr string
opts Options
sync.RWMutex sync.RWMutex
connected bool connected bool
} }
type memoryEvent struct { type memoryEvent struct {
opts Options
err error err error
message interface{} message interface{}
topic string topic string
opts Options
} }
type memorySubscriber struct { type memorySubscriber struct {
opts SubscribeOptions
ctx context.Context ctx context.Context
exit chan bool exit chan bool
handler Handler handler Handler
id string id string
topic string topic string
opts SubscribeOptions
} }
func (m *memoryBroker) Options() Options { func (m *memoryBroker) Options() Options {

View File

@ -5,13 +5,13 @@ import (
) )
type testRequest struct { type testRequest struct {
opts RequestOptions
codec codec.Codec codec codec.Codec
body interface{} body interface{}
service string
method string method string
endpoint string endpoint string
contentType string contentType string
service string opts RequestOptions
} }
func (r *testRequest) ContentType() string { func (r *testRequest) ContentType() string {

View File

@ -30,10 +30,9 @@ type record struct {
} }
type memory struct { type memory struct {
opts Options
// records is a KV map with domain name as the key and a services map as the value
records map[string]services records map[string]services
watchers map[string]*watcher watchers map[string]*watcher
opts Options
sync.RWMutex sync.RWMutex
} }

View File

@ -38,12 +38,12 @@ func (t EventType) String() string {
// Event is returned by a call to Next on the watcher. // Event is returned by a call to Next on the watcher.
type Event struct { type Event struct {
// Route is table route
Route Route
// Timestamp is event timestamp // Timestamp is event timestamp
Timestamp time.Time Timestamp time.Time
// Id of the event // Id of the event
Id string Id string
// Route is table route
Route Route
// Type defines type of event // Type defines type of event
Type EventType Type EventType
} }

View File

@ -23,10 +23,10 @@ type CheckFunc func(context.Context) error
type Option func(*Options) type Option func(*Options)
type Options struct { type Options struct {
LiveChecks []CheckFunc
ReadyChecks []CheckFunc
Version string Version string
Name string Name string
LiveChecks []CheckFunc
ReadyChecks []CheckFunc
} }
func LiveChecks(fns ...CheckFunc) Option { func LiveChecks(fns ...CheckFunc) Option {

View File

@ -32,13 +32,13 @@ const (
) )
type noopServer struct { type noopServer struct {
opts Options
h Handler h Handler
wg *sync.WaitGroup
rsvc *register.Service rsvc *register.Service
handlers map[string]Handler handlers map[string]Handler
subscribers map[*subscriber][]broker.Subscriber subscribers map[*subscriber][]broker.Subscriber
exit chan chan error exit chan chan error
wg *sync.WaitGroup opts Options
sync.RWMutex sync.RWMutex
registered bool registered bool
started bool started bool

View File

@ -28,8 +28,8 @@ func (m *memoryStore) Disconnect(ctx context.Context) error {
} }
type memoryStore struct { type memoryStore struct {
opts Options
store *cache.Cache store *cache.Cache
opts Options
} }
func (m *memoryStore) key(prefix, key string) string { func (m *memoryStore) key(prefix, key string) string {

View File

@ -6,8 +6,8 @@ import (
) )
type memorySync struct { type memorySync struct {
options Options
locks map[string]*memoryLock locks map[string]*memoryLock
options Options
mtx gosync.RWMutex mtx gosync.RWMutex
} }