Skip to content

Commit

Permalink
Fix misspelt activateActor name (dapr#253)
Browse files Browse the repository at this point in the history
* fix misspelt deactiveActor method

Signed-off-by: Joni Collinge <[email protected]>

* fix mocks and tests

Signed-off-by: Joni Collinge <[email protected]>
  • Loading branch information
jjcollinge authored Jan 31, 2022
1 parent e53d1d8 commit 8cc42bd
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions actor/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
type ActorManager interface {
RegisterActorImplFactory(f actor.Factory)
InvokeMethod(actorID, methodName string, request []byte) ([]byte, actorErr.ActorErr)
DetectiveActor(actorID string) actorErr.ActorErr
DeactivateActor(actorID string) actorErr.ActorErr
InvokeReminder(actorID, reminderName string, params []byte) actorErr.ActorErr
InvokeTimer(actorID, timerName string, params []byte) actorErr.ActorErr
}
Expand Down Expand Up @@ -120,8 +120,8 @@ func (m *DefaultActorManager) InvokeMethod(actorID, methodName string, request [
return rspData, actorErr.Success
}

// DetectiveActor removes actor from actor manager.
func (m *DefaultActorManager) DetectiveActor(actorID string) actorErr.ActorErr {
// DeactivateActor removes actor from actor manager.
func (m *DefaultActorManager) DeactivateActor(actorID string) actorErr.ActorErr {
_, ok := m.activeActors.Load(actorID)
if !ok {
return actorErr.ErrActorIDNotFound
Expand Down
6 changes: 3 additions & 3 deletions actor/manager/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,20 @@ func TestInvokeMethod(t *testing.T) {
assert.Equal(t, actorErr.Success, err)
}

func TestDetectiveActor(t *testing.T) {
func TestDeactivateActor(t *testing.T) {
mng, err := NewDefaultActorManager("json")
assert.NotNil(t, mng)
assert.Equal(t, actorErr.Success, err)
assert.Nil(t, mng.(*DefaultActorManager).factory)

err = mng.DetectiveActor("testActorID")
err = mng.DeactivateActor("testActorID")
assert.Equal(t, actorErr.ErrActorIDNotFound, err)

mng.RegisterActorImplFactory(mock.ActorImplFactory)
assert.NotNil(t, mng.(*DefaultActorManager).factory)
mng.InvokeMethod("testActorID", "Invoke", []byte(`"hello"`))

err = mng.DetectiveActor("testActorID")
err = mng.DeactivateActor("testActorID")
assert.Equal(t, actorErr.Success, err)
}

Expand Down
12 changes: 6 additions & 6 deletions actor/mock/mock_manager.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion actor/runtime/actor_runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (r *ActorRunTime) Deactivate(actorTypeName, actorID string) actorErr.ActorE
if !ok {
return actorErr.ErrActorTypeNotFound
}
return targetManager.(manager.ActorManager).DetectiveActor(actorID)
return targetManager.(manager.ActorManager).DeactivateActor(actorID)
}

func (r *ActorRunTime) InvokeReminder(actorTypeName, actorID, reminderName string, params []byte) actorErr.ActorErr {
Expand Down
2 changes: 1 addition & 1 deletion actor/runtime/actor_runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestDeactive(t *testing.T) {
mockServer.EXPECT().RegisterActorImplFactory(gomock.Any())
rt.RegisterActorFactory(actorMock.ActorImplFactory)

mockServer.EXPECT().DetectiveActor("mockActorID").Return(actorErr.Success)
mockServer.EXPECT().DeactivateActor("mockActorID").Return(actorErr.Success)
err = rt.Deactivate("testActorType", "mockActorID")

assert.Equal(t, actorErr.Success, err)
Expand Down
6 changes: 3 additions & 3 deletions client/actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ func (c *GRPCClient) implActor(actor actor.Client, serializer codec.Codec) {

// check incoming interface, the incoming interface's elem must be a struct.
if typeOfActor.Kind() != reflect.Struct {
fmt.Println("[Actor] ERROR: imple actor client stub failed, incoming interface is not struct")
fmt.Println("[Actor] ERROR: impl actor client stub failed, incoming interface is not struct")
return
}

Expand All @@ -335,14 +335,14 @@ func (c *GRPCClient) implActor(actor actor.Client, serializer codec.Codec) {
outNum := t.Type.NumOut()

if outNum != 1 && outNum != 2 {
fmt.Printf("[Actor] ERRROR: method %s of mtype %v has wrong number of in out parameters %d; needs exactly 1/2\n",
fmt.Printf("[Actor] ERROR: method %s of mtype %v has wrong number of in out parameters %d; needs exactly 1/2\n",
t.Name, t.Type.String(), outNum)
continue
}

// The latest return type of the method must be error.
if returnType := t.Type.Out(outNum - 1); returnType != reflect.Zero(reflect.TypeOf((*error)(nil)).Elem()).Type() {
fmt.Printf("[Actor] ERRROR: the latest return type %s of method %q is not error\n", returnType, t.Name)
fmt.Printf("[Actor] ERROR: the latest return type %s of method %q is not error\n", returnType, t.Name)
continue
}

Expand Down

0 comments on commit 8cc42bd

Please sign in to comment.