Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions sdk-actors/src/main/java/io/dapr/actors/client/ActorProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public interface ActorProxy {
* @param <T> The type to be returned.
* @return Asynchronous result with the Actor's response.
*/
<T> Mono<T> invoke(String methodName, TypeRef<T> type);
<T> Mono<T> invokeMethod(String methodName, TypeRef<T> type);

/**
* Invokes an Actor method on Dapr.
Expand All @@ -46,7 +46,7 @@ public interface ActorProxy {
* @param <T> The type to be returned.
* @return Asynchronous result with the Actor's response.
*/
<T> Mono<T> invoke(String methodName, Class<T> clazz);
<T> Mono<T> invokeMethod(String methodName, Class<T> clazz);

/**
* Invokes an Actor method on Dapr.
Expand All @@ -57,7 +57,7 @@ public interface ActorProxy {
* @param <T> The type to be returned.
* @return Asynchronous result with the Actor's response.
*/
<T> Mono<T> invoke(String methodName, Object data, TypeRef<T> type);
<T> Mono<T> invokeMethod(String methodName, Object data, TypeRef<T> type);

/**
* Invokes an Actor method on Dapr.
Expand All @@ -68,15 +68,15 @@ public interface ActorProxy {
* @param <T> The type to be returned.
* @return Asynchronous result with the Actor's response.
*/
<T> Mono<T> invoke(String methodName, Object data, Class<T> clazz);
<T> Mono<T> invokeMethod(String methodName, Object data, Class<T> clazz);

/**
* Invokes an Actor method on Dapr.
*
* @param methodName Method name to invoke.
* @return Asynchronous result with the Actor's response.
*/
Mono<Void> invoke(String methodName);
Mono<Void> invokeMethod(String methodName);

/**
* Invokes an Actor method on Dapr.
Expand All @@ -85,6 +85,6 @@ public interface ActorProxy {
* @param data Object with the data.
* @return Asynchronous result with the Actor's response.
*/
Mono<Void> invoke(String methodName, Object data);
Mono<Void> invokeMethod(String methodName, Object data);

}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public String getActorType() {
* {@inheritDoc}
*/
@Override
public <T> Mono<T> invoke(String methodName, Object data, TypeRef<T> type) {
public <T> Mono<T> invokeMethod(String methodName, Object data, TypeRef<T> type) {
return this.daprClient.invoke(actorType, actorId.toString(), methodName, this.serialize(data))
.filter(s -> s.length > 0)
.map(s -> deserialize(s, type));
Expand All @@ -84,15 +84,15 @@ public <T> Mono<T> invoke(String methodName, Object data, TypeRef<T> type) {
* {@inheritDoc}
*/
@Override
public <T> Mono<T> invoke(String methodName, Object data, Class<T> clazz) {
return this.invoke(methodName, data, TypeRef.get(clazz));
public <T> Mono<T> invokeMethod(String methodName, Object data, Class<T> clazz) {
return this.invokeMethod(methodName, data, TypeRef.get(clazz));
}

/**
* {@inheritDoc}
*/
@Override
public <T> Mono<T> invoke(String methodName, TypeRef<T> type) {
public <T> Mono<T> invokeMethod(String methodName, TypeRef<T> type) {
return this.daprClient.invoke(actorType, actorId.toString(), methodName, null)
.filter(s -> s.length > 0)
.map(s -> deserialize(s, type));
Expand All @@ -102,23 +102,23 @@ public <T> Mono<T> invoke(String methodName, TypeRef<T> type) {
* {@inheritDoc}
*/
@Override
public <T> Mono<T> invoke(String methodName, Class<T> clazz) {
return this.invoke(methodName, TypeRef.get(clazz));
public <T> Mono<T> invokeMethod(String methodName, Class<T> clazz) {
return this.invokeMethod(methodName, TypeRef.get(clazz));
}

/**
* {@inheritDoc}
*/
@Override
public Mono<Void> invoke(String methodName) {
public Mono<Void> invokeMethod(String methodName) {
return this.daprClient.invoke(actorType, actorId.toString(), methodName, null).then();
}

/**
* {@inheritDoc}
*/
@Override
public Mono<Void> invoke(String methodName, Object data) {
public Mono<Void> invokeMethod(String methodName, Object data) {
return this.daprClient.invoke(actorType, actorId.toString(), methodName, this.serialize(data)).then();
}

Expand All @@ -140,25 +140,25 @@ public Object invoke(Object proxy, Method method, Object[] args) {
if (method.getReturnType().equals(Mono.class)) {
ActorMethod actorMethodAnnotation = method.getDeclaredAnnotation(ActorMethod.class);
if (actorMethodAnnotation == null) {
return invoke(method.getName());
return invokeMethod(method.getName());
}

return invoke(method.getName(), actorMethodAnnotation.returns());
return invokeMethod(method.getName(), actorMethodAnnotation.returns());
}

return invoke(method.getName(), method.getReturnType()).block();
return invokeMethod(method.getName(), method.getReturnType()).block();
}

if (method.getReturnType().equals(Mono.class)) {
ActorMethod actorMethodAnnotation = method.getDeclaredAnnotation(ActorMethod.class);
if (actorMethodAnnotation == null) {
return invoke(method.getName(), args[0]);
return invokeMethod(method.getName(), args[0]);
}

return invoke(method.getName(), args[0], actorMethodAnnotation.returns());
return invokeMethod(method.getName(), args[0], actorMethodAnnotation.returns());
}

return invoke(method.getName(), args[0], method.getReturnType()).block();
return invokeMethod(method.getName(), args[0], method.getReturnType()).block();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void invokeActorMethodWithoutDataWithReturnType() {
new DefaultObjectSerializer(),
daprClient);

Mono<MyData> result = actorProxy.invoke("getData", MyData.class);
Mono<MyData> result = actorProxy.invokeMethod("getData", MyData.class);
MyData myData = result.block();
Assert.assertNotNull(myData);
Assert.assertEquals("valueA", myData.getPropertyA());
Expand Down Expand Up @@ -260,7 +260,7 @@ public void invokeActorMethodWithoutDataWithEmptyReturnType() {
new DefaultObjectSerializer(),
daprClient);

Mono<MyData> result = actorProxy.invoke("getData", MyData.class);
Mono<MyData> result = actorProxy.invokeMethod("getData", MyData.class);
MyData myData = result.block();
Assert.assertNull(myData);
}
Expand All @@ -277,7 +277,7 @@ public void invokeActorMethodWithIncorrectReturnType() {
new DefaultObjectSerializer(),
daprClient);

Mono<MyData> result = actorProxy.invoke("getData", MyData.class);
Mono<MyData> result = actorProxy.invokeMethod("getData", MyData.class);

result.doOnSuccess(x ->
Assert.fail("Not exception was throw"))
Expand All @@ -302,7 +302,7 @@ public void invokeActorMethodSavingDataWithReturnType() {
saveData.setPropertyA("valueA");
saveData.setPropertyB("valueB");

Mono<MyData> result = actorProxy.invoke("getData", saveData, MyData.class);
Mono<MyData> result = actorProxy.invokeMethod("getData", saveData, MyData.class);
MyData myData = result.block();
Assert.assertNotNull(myData);
Assert.assertEquals("valueA", myData.getPropertyA());
Expand All @@ -326,7 +326,7 @@ public void invokeActorMethodSavingDataWithIncorrectReturnType() {
saveData.setPropertyA("valueA");
saveData.setPropertyB("valueB");

Mono<MyData> result = actorProxy.invoke("getData", saveData, MyData.class);
Mono<MyData> result = actorProxy.invokeMethod("getData", saveData, MyData.class);
result.doOnSuccess(x ->
Assert.fail("Not exception was throw"))
.doOnError(Throwable::printStackTrace
Expand All @@ -350,7 +350,7 @@ public void invokeActorMethodSavingDataWithEmptyReturnType() {
saveData.setPropertyA("valueA");
saveData.setPropertyB("valueB");

Mono<MyData> result = actorProxy.invoke("getData", saveData, MyData.class);
Mono<MyData> result = actorProxy.invokeMethod("getData", saveData, MyData.class);
MyData myData = result.block();
Assert.assertNull(myData);
}
Expand All @@ -373,7 +373,7 @@ public void invokeActorMethodSavingDataWithIncorrectInputType() {
saveData.setPropertyB("valueB");
saveData.setMyData(saveData);

Mono<MyData> result = actorProxy.invoke("getData", saveData, MyData.class);
Mono<MyData> result = actorProxy.invokeMethod("getData", saveData, MyData.class);
result.doOnSuccess(x ->
Assert.fail("Not exception was throw"))
.doOnError(Throwable::printStackTrace
Expand All @@ -397,7 +397,7 @@ public void invokeActorMethodWithDataWithVoidReturnType() {
new DefaultObjectSerializer(),
daprClient);

Mono<Void> result = actorProxy.invoke("getData", saveData);
Mono<Void> result = actorProxy.invokeMethod("getData", saveData);
Void emptyResponse = result.block();
Assert.assertNull(emptyResponse);
}
Expand All @@ -420,7 +420,7 @@ public void invokeActorMethodWithDataWithVoidIncorrectInputType() {
new DefaultObjectSerializer(),
daprClient);

Mono<Void> result = actorProxy.invoke("getData", saveData);
Mono<Void> result = actorProxy.invokeMethod("getData", saveData);
Void emptyResponse = result.doOnError(Throwable::printStackTrace).block();
Assert.assertNull(emptyResponse);
}
Expand All @@ -437,7 +437,7 @@ public void invokeActorMethodWithoutDataWithVoidReturnType() {
new DefaultObjectSerializer(),
daprClient);

Mono<Void> result = actorProxy.invoke("getData");
Mono<Void> result = actorProxy.invokeMethod("getData");
Void emptyResponse = result.block();
Assert.assertNull(emptyResponse);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void classInClassOut() {
ActorProxy actorProxy = createActorProxy();
MyData d = new MyData("hi", 3);

MyData response = actorProxy.invoke("classInClassOut", d, MyData.class).block();
MyData response = actorProxy.invokeMethod("classInClassOut", d, MyData.class).block();

Assert.assertEquals("hihi", response.getName());
Assert.assertEquals(6, response.getNum());
Expand All @@ -107,15 +107,15 @@ public void classInClassOut() {
@Test
public void stringInStringOut() {
ActorProxy actorProxy = createActorProxy();
String response = actorProxy.invoke("stringInStringOut", "oi", String.class).block();
String response = actorProxy.invokeMethod("stringInStringOut", "oi", String.class).block();

Assert.assertEquals("oioi", response);
}

@Test
public void intInIntOut() {
ActorProxy actorProxy = createActorProxy();
int response = actorProxy.invoke("intInIntOut", 2, int.class).block();
int response = actorProxy.invokeMethod("intInIntOut", 2, int.class).block();

Assert.assertEquals(4, response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public void actorId() {

Assert.assertEquals(
proxy.getActorId().toString(),
proxy.invoke("getMyId", String.class).block());
proxy.invokeMethod("getMyId", String.class).block());
}

@Test
Expand All @@ -149,7 +149,7 @@ public void stringInStringOut() {
// these should only call the actor methods for ActorChild. The implementations in ActorParent will throw.
Assert.assertEquals(
"abcabc",
proxy.invoke("stringInStringOut", "abc", String.class).block());
proxy.invokeMethod("stringInStringOut", "abc", String.class).block());
}

@Test
Expand All @@ -159,19 +159,19 @@ public void stringInBooleanOut() {
// these should only call the actor methods for ActorChild. The implementations in ActorParent will throw.
Assert.assertEquals(
false,
proxy.invoke("stringInBooleanOut", "hello world", Boolean.class).block());
proxy.invokeMethod("stringInBooleanOut", "hello world", Boolean.class).block());

Assert.assertEquals(
true,
proxy.invoke("stringInBooleanOut", "true", Boolean.class).block());
proxy.invokeMethod("stringInBooleanOut", "true", Boolean.class).block());
}

@Test(expected = IllegalMonitorStateException.class)
public void stringInVoidOutIntentionallyThrows() {
ActorProxy actorProxy = createActorProxy();

// these should only call the actor methods for ActorChild. The implementations in ActorParent will throw.
actorProxy.invoke("stringInVoidOutIntentionallyThrows", "hello world").block();
actorProxy.invokeMethod("stringInVoidOutIntentionallyThrows", "hello world").block();
}

@Test
Expand All @@ -180,7 +180,7 @@ public void classInClassOut() {
MyData d = new MyData("hi", 3);

// this should only call the actor methods for ActorChild. The implementations in ActorParent will throw.
MyData response = actorProxy.invoke("classInClassOut", d, MyData.class).block();
MyData response = actorProxy.invokeMethod("classInClassOut", d, MyData.class).block();

Assert.assertEquals(
"hihi",
Expand Down
Loading