From 3978cab3b85452f1837439267d17b60921a19688 Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Tue, 1 Dec 2020 17:23:59 +0700 Subject: [PATCH] Rename `IExecutor` to `Executor` Signed-off-by: Vladimir Popov --- pkg/networkservice/common/serialize/context.go | 14 +++++++------- .../common/serialize/multi_executor.go | 2 +- pkg/networkservice/common/serialize/server_test.go | 2 +- pkg/networkservice/common/timeout/server.go | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/networkservice/common/serialize/context.go b/pkg/networkservice/common/serialize/context.go index 0e6a0c79d..39c879587 100644 --- a/pkg/networkservice/common/serialize/context.go +++ b/pkg/networkservice/common/serialize/context.go @@ -26,22 +26,22 @@ const ( type contextKeyType string -// IExecutor is a serialize.Executor interface type -type IExecutor interface { +// Executor is a serialize.Executor interface type +type Executor interface { AsyncExec(f func()) <-chan struct{} } -// WithExecutor wraps `parent` in a new context with IExecutor -func WithExecutor(parent context.Context, executor IExecutor) context.Context { +// WithExecutor wraps `parent` in a new context with Executor +func WithExecutor(parent context.Context, executor Executor) context.Context { if parent == nil { panic("cannot create context from nil parent") } return context.WithValue(parent, executorKey, executor) } -// Executor returns IExecutor -func Executor(ctx context.Context) IExecutor { - if executor, ok := ctx.Value(executorKey).(IExecutor); ok { +// GetExecutor returns Executor +func GetExecutor(ctx context.Context) Executor { + if executor, ok := ctx.Value(executorKey).(Executor); ok { return executor } return nil diff --git a/pkg/networkservice/common/serialize/multi_executor.go b/pkg/networkservice/common/serialize/multi_executor.go index 676caa713..0ed85ae79 100644 --- a/pkg/networkservice/common/serialize/multi_executor.go +++ b/pkg/networkservice/common/serialize/multi_executor.go @@ -59,7 +59,7 @@ func (e *multiExecutor) AsyncExec(id string, f func()) (ch <-chan struct{}) { return ch } -func (e *multiExecutor) Executor(id string) IExecutor { +func (e *multiExecutor) Executor(id string) Executor { return executorFunc(func(f func()) <-chan struct{} { return e.AsyncExec(id, f) }) diff --git a/pkg/networkservice/common/serialize/server_test.go b/pkg/networkservice/common/serialize/server_test.go index b21b8189b..442f15a73 100644 --- a/pkg/networkservice/common/serialize/server_test.go +++ b/pkg/networkservice/common/serialize/server_test.go @@ -80,7 +80,7 @@ func TestSerializeServer_StressTest(t *testing.T) { type eventServer struct{} func (s *eventServer) Request(ctx context.Context, request *networkservice.NetworkServiceRequest) (*networkservice.Connection, error) { - executor := serialize.Executor(ctx) + executor := serialize.GetExecutor(ctx) go func() { executor.AsyncExec(func() { _, _ = next.Server(ctx).Request(serialize.WithExecutor(context.TODO(), executor), request) diff --git a/pkg/networkservice/common/timeout/server.go b/pkg/networkservice/common/timeout/server.go index c94092fb2..cd541f339 100644 --- a/pkg/networkservice/common/timeout/server.go +++ b/pkg/networkservice/common/timeout/server.go @@ -86,7 +86,7 @@ func (t *timeoutServer) Request(ctx context.Context, request *networkservice.Net func (t *timeoutServer) createTimer(ctx context.Context, conn *networkservice.Connection) (*time.Timer, error) { logEntry := log.Entry(ctx).WithField("timeoutServer", "createTimer") - executor := serialize.Executor(ctx) + executor := serialize.GetExecutor(ctx) if executor == nil { return nil, errors.New("no executor provided") }