Skip to content

Commit

Permalink
Rename IExecutor to Executor
Browse files Browse the repository at this point in the history
Signed-off-by: Vladimir Popov <[email protected]>
  • Loading branch information
Vladimir Popov committed Dec 1, 2020
1 parent f8a5f54 commit 3978cab
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions pkg/networkservice/common/serialize/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/networkservice/common/serialize/multi_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/networkservice/common/serialize/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/networkservice/common/timeout/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down

0 comments on commit 3978cab

Please sign in to comment.