-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added retry 'registry' chain element #1202
Conversation
Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com>
pkg/registry/common/retry/options.go
Outdated
|
||
// Option is NS/NSE retry client config option | ||
type Option interface { | ||
apply(configurable) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apply(configurable) | |
apply(*options) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
pkg/registry/common/retry/options.go
Outdated
type configurable interface { | ||
setInterval(time.Duration) | ||
setTryTimeout(time.Duration) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type configurable interface { | |
setInterval(time.Duration) | |
setTryTimeout(time.Duration) | |
} | |
type options interface { | |
internal time.Duration | |
timeout time.Duration | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
pkg/registry/common/retry/options.go
Outdated
type applier func(configurable) | ||
|
||
func (f applier) apply(c configurable) { | ||
f(c) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type applier func(configurable) | |
func (f applier) apply(c configurable) { | |
f(c) | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
registers, unregisters, finds map[string]int32 | ||
mu sync.Mutex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These fields are not used. Please don't add dead code.
registers, unregisters, finds map[string]int32 | |
mu sync.Mutex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
) | ||
|
||
// NSEClient is a client type for counting Register / Unregister / Find | ||
type NSEClient struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type NSEClient struct { | |
type countNSEClient struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be private.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
// NSEClient is a client type for counting Register / Unregister / Find | ||
type NSEClient struct { | ||
totalRegisterCalls, totalUnregisterCalls, totalFindCalls int32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
totalRegisterCalls, totalUnregisterCalls, totalFindCalls int32 | |
totalRegisterCalls, totalUnregisterCalls, totalFindCalls *int32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
// Registers returns Register call count | ||
func (c *NSEClient) Registers() int { | ||
return int(atomic.LoadInt32(&c.totalRegisterCalls)) | ||
} | ||
|
||
// Unregisters returns Unregister count | ||
func (c *NSEClient) Unregisters() int { | ||
return int(atomic.LoadInt32(&c.totalUnregisterCalls)) | ||
} | ||
|
||
// Finds returns Find count | ||
func (c *NSEClient) Finds() int { | ||
return int(atomic.LoadInt32(&c.totalFindCalls)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Registers returns Register call count | |
func (c *NSEClient) Registers() int { | |
return int(atomic.LoadInt32(&c.totalRegisterCalls)) | |
} | |
// Unregisters returns Unregister count | |
func (c *NSEClient) Unregisters() int { | |
return int(atomic.LoadInt32(&c.totalUnregisterCalls)) | |
} | |
// Finds returns Find count | |
func (c *NSEClient) Finds() int { | |
return int(atomic.LoadInt32(&c.totalFindCalls)) | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we assert Register
/Unregister
/Find
call count in tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sol-0 Does #1202 (comment) resolve your question?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@denis-tingaikin yes, thanks! Done
registers, unregisters, finds map[string]int32 | ||
mu sync.Mutex | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func NewNetworkServiceEndpointClinet(opts...options) registry.NetworkServiceEndpointClient { | |
var result = &countNSEClient{ | |
totalRegisterCalls: new(int32) | |
//TODO totalUnregisterCalls, totalFindCalls | |
} | |
for _, opt := range options { | |
opt(result) | |
} | |
return result | |
} |
where options
WithRegisters(r *int32) func(*options)
....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@sol-0 Please ping me when you've resolved all comments. |
Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com>
@denis-tingaikin, comments have been addressed - please, take a look. |
pkg/registry/utils/count/options.go
Outdated
type options struct { | ||
totalRegisterCalls, totalUnregisterCalls, totalFindCalls *int32 | ||
} | ||
|
||
// Option is an option pattern for NewNetworkServiceRegistryClient, NewNetworkServiceEndpointRegistryClient | ||
type Option func(*options) | ||
|
||
// WithTotalRegisterCalls sets pointer to number of Register calls | ||
func WithTotalRegisterCalls(registerCount *int32) func(*options) { | ||
return func(o *options) { | ||
o.totalRegisterCalls = registerCount | ||
} | ||
} | ||
|
||
// WithTotalUnregisterCalls sets pointer to number of Unregister calls | ||
func WithTotalUnregisterCalls(unregisterCount *int32) func(*options) { | ||
return func(o *options) { | ||
o.totalUnregisterCalls = unregisterCount | ||
} | ||
} | ||
|
||
// WithTotalFindCalls sets pointer to number of Find calls | ||
func WithTotalFindCalls(findCalls *int32) func(*options) { | ||
return func(o *options) { | ||
o.totalFindCalls = findCalls | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type options struct { | |
totalRegisterCalls, totalUnregisterCalls, totalFindCalls *int32 | |
} | |
// Option is an option pattern for NewNetworkServiceRegistryClient, NewNetworkServiceEndpointRegistryClient | |
type Option func(*options) | |
// WithTotalRegisterCalls sets pointer to number of Register calls | |
func WithTotalRegisterCalls(registerCount *int32) func(*options) { | |
return func(o *options) { | |
o.totalRegisterCalls = registerCount | |
} | |
} | |
// WithTotalUnregisterCalls sets pointer to number of Unregister calls | |
func WithTotalUnregisterCalls(unregisterCount *int32) func(*options) { | |
return func(o *options) { | |
o.totalUnregisterCalls = unregisterCount | |
} | |
} | |
// WithTotalFindCalls sets pointer to number of Find calls | |
func WithTotalFindCalls(findCalls *int32) func(*options) { | |
return func(o *options) { | |
o.totalFindCalls = findCalls | |
} | |
} | |
type Counter struct { | |
totalRegisterCalls int32 | |
totalUnregisterCalls int32 | |
totalFindCalls int32 | |
} | |
// Registers returns Register call count | |
func (c *Counter) Registers() int { | |
return int(atomic.LoadInt32(&c.totalRegisterCalls)) | |
} | |
// Unregisters returns Unregister count | |
func (c *Counter) Unregisters() int { | |
return int(atomic.LoadInt32(&c.totalUnregisterCalls)) | |
} | |
// Finds returns Find count | |
func (c *Counter) Finds() int { | |
return int(atomic.LoadInt32(&c.totalFindCalls)) | |
} | |
// TODO: add this to the constructor of count servers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com>
…k@main PR link: networkservicemesh/sdk#1202 Commit: 29ac91f Author: Sol-0 Date: 2021-12-24 20:21:38 +0700 Message: - Added retry 'registry' chain element (#1202) * Added retry registry client chain element Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
…k@main PR link: networkservicemesh/sdk#1202 Commit: 29ac91f Author: Sol-0 Date: 2021-12-24 20:21:38 +0700 Message: - Added retry 'registry' chain element (#1202) * Added retry registry client chain element Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
…k@main PR link: networkservicemesh/sdk#1202 Commit: 29ac91f Author: Sol-0 Date: 2021-12-24 20:21:38 +0700 Message: - Added retry 'registry' chain element (#1202) * Added retry registry client chain element Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
…k@main PR link: networkservicemesh/sdk#1202 Commit: 29ac91f Author: Sol-0 Date: 2021-12-24 20:21:38 +0700 Message: - Added retry 'registry' chain element (#1202) * Added retry registry client chain element Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
…k@main PR link: networkservicemesh/sdk#1202 Commit: 29ac91f Author: Sol-0 Date: 2021-12-24 20:21:38 +0700 Message: - Added retry 'registry' chain element (#1202) * Added retry registry client chain element Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
…k@main PR link: networkservicemesh/sdk#1202 Commit: 29ac91f Author: Sol-0 Date: 2021-12-24 20:21:38 +0700 Message: - Added retry 'registry' chain element (#1202) * Added retry registry client chain element Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
…k@main PR link: networkservicemesh/sdk#1202 Commit: 29ac91f Author: Sol-0 Date: 2021-12-24 20:21:38 +0700 Message: - Added retry 'registry' chain element (#1202) * Added retry registry client chain element Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
…k@main PR link: networkservicemesh/sdk#1202 Commit: 29ac91f Author: Sol-0 Date: 2021-12-24 20:21:38 +0700 Message: - Added retry 'registry' chain element (#1202) * Added retry registry client chain element Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
…k@main PR link: networkservicemesh/sdk#1202 Commit: 29ac91f Author: Sol-0 Date: 2021-12-24 20:21:38 +0700 Message: - Added retry 'registry' chain element (#1202) * Added retry registry client chain element Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com> * Addressed review comments Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
Signed-off-by: Oleg Solodkov oleg.solodkov@xored.com
Issue link
Fixes #1201
How Has This Been Tested?
Types of changes