Merge branch 'master' into release-1.0

This commit is contained in:
Artur Souza 2021-02-10 21:11:44 -08:00
commit 6b9a0e1bce
237 changed files with 1077 additions and 897 deletions

View File

@ -26,7 +26,7 @@ jobs:
DAPR_RUNTIME_VER: 1.0.0-rc.3 DAPR_RUNTIME_VER: 1.0.0-rc.3
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/3dacfb672d55f1436c249057aaebbe597e1066f3/install/install.sh DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/3dacfb672d55f1436c249057aaebbe597e1066f3/install/install.sh
DAPR_CLI_REF: DAPR_CLI_REF:
DAPR_REF: DAPR_REF: 4899aa8fb8f7537fb10432e6cc0cfc09c572cb54
OSSRH_USER_TOKEN: ${{ secrets.OSSRH_USER_TOKEN }} OSSRH_USER_TOKEN: ${{ secrets.OSSRH_USER_TOKEN }}
OSSRH_PWD_TOKEN: ${{ secrets.OSSRH_PWD_TOKEN }} OSSRH_PWD_TOKEN: ${{ secrets.OSSRH_PWD_TOKEN }}
GPG_KEY: ${{ secrets.GPG_KEY }} GPG_KEY: ${{ secrets.GPG_KEY }}

View File

@ -1,5 +1,5 @@
# ------------------------------------------------------------ # ------------------------------------------------------------
# Copyright (c) Microsoft Corporation. # Copyright (c) Microsoft Corporation and Dapr Contributors.
# Licensed under the MIT License. # Licensed under the MIT License.
# ------------------------------------------------------------ # ------------------------------------------------------------

View File

@ -1,7 +1,7 @@
## Dapr SDK for Java ## Dapr SDK for Java
[![Build Status](https://github.com/dapr/java-sdk/workflows/Build/badge.svg?event=push&branch=master)](https://github.com/dapr/java-sdk/actions?workflow=Build) [![Build Status](https://github.com/dapr/java-sdk/workflows/Build/badge.svg?event=push&branch=master)](https://github.com/dapr/java-sdk/actions?workflow=Build)
[![Gitter](https://badges.gitter.im/Dapr/java-sdk.svg)](https://gitter.im/Dapr/java-sdk?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![Discord](https://img.shields.io/discord/778680217417809931)](https://discord.com/channels/778680217417809931/778749797242765342)
[![codecov](https://codecov.io/gh/dapr/java-sdk/branch/master/graph/badge.svg)](https://codecov.io/gh/dapr/java-sdk) [![codecov](https://codecov.io/gh/dapr/java-sdk/branch/master/graph/badge.svg)](https://codecov.io/gh/dapr/java-sdk)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Maven Central](https://img.shields.io/maven-central/v/io.dapr/dapr-sdk.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22io.dapr%22%20AND%20a:%22dapr-sdk%22) [![Maven Central](https://img.shields.io/maven-central/v/io.dapr/dapr-sdk.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22io.dapr%22%20AND%20a:%22dapr-sdk%22)

View File

@ -1,6 +1,6 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!-- <!--
~ Copyright (c) Microsoft Corporation. ~ Copyright (c) Microsoft Corporation and Dapr Contributors.
~ Licensed under the MIT License. ~ Licensed under the MIT License.
--> -->
@ -45,7 +45,7 @@
<module name="Header"> <module name="Header">
<property name="fileExtensions" value="java"/> <property name="fileExtensions" value="java"/>
<property name="header" value="/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n */"/> <property name="header" value="/*\n * Copyright (c) Microsoft Corporation and Dapr Contributors.\n * Licensed under the MIT License.\n */"/>
</module> </module>
<module name="TreeWalker"> <module name="TreeWalker">

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */
@ -52,18 +52,18 @@ public class InvokeClient {
InvokeMethodRequest request = builder InvokeMethodRequest request = builder
.withBody(message) .withBody(message)
.withHttpExtension(HttpExtension.POST) .withHttpExtension(HttpExtension.POST)
.withContext(getReactorContext()).build(); .build();
client.invokeMethod(request, TypeRef.get(byte[].class)) client.invokeMethod(request, TypeRef.get(byte[].class))
.map(r -> { .map(r -> {
System.out.println(new String(r.getObject())); System.out.println(new String(r));
return r; return r;
}) })
.flatMap(r -> { .flatMap(r -> {
InvokeMethodRequest sleepRequest = new InvokeMethodRequestBuilder(SERVICE_APP_ID, "proxy_sleep") InvokeMethodRequest sleepRequest = new InvokeMethodRequestBuilder(SERVICE_APP_ID, "proxy_sleep")
.withHttpExtension(HttpExtension.POST) .withHttpExtension(HttpExtension.POST)
.withContext(r.getContext()).build(); .build();
return client.invokeMethod(sleepRequest, TypeRef.get(Void.class)); return client.invokeMethod(sleepRequest, TypeRef.get(Void.class));
}).block(); }).subscriberContext(getReactorContext()).block();
} }
} }

View File

@ -147,19 +147,19 @@ public class TracingDemoMiddleServiceController {
@RequestBody(required = false) String body) { @RequestBody(required = false) String body) {
InvokeMethodRequestBuilder builder = new InvokeMethodRequestBuilder(INVOKE_APP_ID, "echo"); InvokeMethodRequestBuilder builder = new InvokeMethodRequestBuilder(INVOKE_APP_ID, "echo");
InvokeMethodRequest request = builder InvokeMethodRequest request = builder
.withBody(body) .withBody(body)
.withHttpExtension(HttpExtension.POST) .withHttpExtension(HttpExtension.POST)
.withContext(getReactorContext(context)).build(); .build();
return client.invokeMethod(request, TypeRef.get(byte[].class)).map(r -> r.getObject()); return client.invokeMethod(request, TypeRef.get(byte[].class)).subscriberContext(getReactorContext(context));
} }
// ... // ...
@PostMapping(path = "/proxy_sleep") @PostMapping(path = "/proxy_sleep")
public Mono<Void> sleep(@RequestAttribute(name = "opentelemetry-context") Context context) { public Mono<Void> sleep(@RequestAttribute(name = "opentelemetry-context") Context context) {
InvokeMethodRequestBuilder builder = new InvokeMethodRequestBuilder(INVOKE_APP_ID, "sleep"); InvokeMethodRequestBuilder builder = new InvokeMethodRequestBuilder(INVOKE_APP_ID, "sleep");
InvokeMethodRequest request = builder InvokeMethodRequest request = builder
.withHttpExtension(HttpExtension.POST) .withHttpExtension(HttpExtension.POST)
.withContext(getReactorContext(context)).build(); .build();
return client.invokeMethod(request, TypeRef.get(byte[].class)).then(); return client.invokeMethod(request, TypeRef.get(byte[].class)).subscriberContext(getReactorContext(context)).then();
} }
} }
``` ```
@ -222,26 +222,29 @@ public class InvokeClient {
private static final String SERVICE_APP_ID = "tracingdemoproxy"; private static final String SERVICE_APP_ID = "tracingdemoproxy";
///... ///...
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
Tracer tracer = OpenTelemetryConfig.createTracer(InvokeClient.class.getCanonicalName()); final OpenTelemetry openTelemetry = OpenTelemetryConfig.createOpenTelemetry();
final Tracer tracer = openTelemetry.getTracer(InvokeClient.class.getCanonicalName());
Span span = tracer.spanBuilder("Example's Main").setSpanKind(Span.Kind.CLIENT).startSpan(); Span span = tracer.spanBuilder("Example's Main").setSpanKind(Span.Kind.CLIENT).startSpan();
try (DaprClient client = (new DaprClientBuilder()).build()) { try (DaprClient client = (new DaprClientBuilder()).build()) {
for (String message : args) { for (String message : args) {
try (Scope scope = tracer.withSpan(span)) { try (Scope scope = span.makeCurrent()) {
InvokeServiceRequestBuilder builder = new InvokeServiceRequestBuilder(SERVICE_APP_ID, "proxy_echo"); InvokeMethodRequestBuilder builder = new InvokeMethodRequestBuilder(SERVICE_APP_ID, "proxy_echo");
InvokeServiceRequest request InvokeMethodRequest request = builder
= builder.withBody(message).withHttpExtension(HttpExtension.POST).withContext(Context.current()).build(); .withBody(message)
client.invokeService(request, TypeRef.get(byte[].class)) .withHttpExtension(HttpExtension.POST)
.map(r -> { .build();
System.out.println(new String(r.getObject())); client.invokeMethod(request, TypeRef.get(byte[].class))
return r; .map(r -> {
}) System.out.println(new String(r));
.flatMap(r -> { return r;
InvokeServiceRequest sleepRequest = new InvokeServiceRequestBuilder(SERVICE_APP_ID, "proxy_sleep") })
.withHttpExtension(HttpExtension.POST) .flatMap(r -> {
.withContext(r.getContext()).build(); InvokeMethodRequest sleepRequest = new InvokeMethodRequestBuilder(SERVICE_APP_ID, "proxy_sleep")
return client.invokeMethod(sleepRequest, TypeRef.get(Void.class)); .withHttpExtension(HttpExtension.POST)
}).block(); .build();
return client.invokeMethod(sleepRequest, TypeRef.get(Void.class));
}).subscriberContext(getReactorContext()).block();
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */
@ -52,8 +52,8 @@ public class TracingDemoMiddleServiceController {
InvokeMethodRequest request = builder InvokeMethodRequest request = builder
.withBody(body) .withBody(body)
.withHttpExtension(HttpExtension.POST) .withHttpExtension(HttpExtension.POST)
.withContext(getReactorContext(context)).build(); .build();
return client.invokeMethod(request, TypeRef.get(byte[].class)).map(r -> r.getObject()); return client.invokeMethod(request, TypeRef.get(byte[].class)).subscriberContext(getReactorContext(context));
} }
/** /**
@ -67,8 +67,8 @@ public class TracingDemoMiddleServiceController {
InvokeMethodRequestBuilder builder = new InvokeMethodRequestBuilder(INVOKE_APP_ID, "sleep"); InvokeMethodRequestBuilder builder = new InvokeMethodRequestBuilder(INVOKE_APP_ID, "sleep");
InvokeMethodRequest request = builder InvokeMethodRequest request = builder
.withHttpExtension(HttpExtension.POST) .withHttpExtension(HttpExtension.POST)
.withContext(getReactorContext(context)).build(); .build();
return client.invokeMethod(request, TypeRef.get(byte[].class)).then(); return client.invokeMethod(request, TypeRef.get(byte[].class)).subscriberContext(getReactorContext(context)).then();
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -16,7 +16,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<grpc.version>1.33.1</grpc.version> <grpc.version>1.33.1</grpc.version>
<protobuf.version>3.13.0</protobuf.version> <protobuf.version>3.13.0</protobuf.version>
<dapr.proto.baseurl>https://raw.githubusercontent.com/dapr/dapr/4a6369caaba9cf46eae9bfa4fa6e76b474854c89/dapr/proto</dapr.proto.baseurl> <dapr.proto.baseurl>https://raw.githubusercontent.com/dapr/dapr/4899aa8fb8f7537fb10432e6cc0cfc09c572cb54/dapr/proto</dapr.proto.baseurl>
<os-maven-plugin.version>1.6.2</os-maven-plugin.version> <os-maven-plugin.version>1.6.2</os-maven-plugin.version>
<maven-dependency-plugin.version>3.1.1</maven-dependency-plugin.version> <maven-dependency-plugin.version>3.1.1</maven-dependency-plugin.version>
<maven-antrun-plugin.version>1.8</maven-antrun-plugin.version> <maven-antrun-plugin.version>1.8</maven-antrun-plugin.version>

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */
@ -18,9 +18,8 @@ import reactor.core.publisher.Mono;
import java.io.Closeable; import java.io.Closeable;
import java.io.IOException; import java.io.IOException;
import java.util.Collections; import java.util.concurrent.ConcurrentHashMap;
import java.util.HashMap; import java.util.concurrent.ConcurrentMap;
import java.util.Map;
/** /**
* Contains methods to register actor types. Registering the types allows the * Contains methods to register actor types. Registering the types allows the
@ -66,7 +65,7 @@ public class ActorRuntime implements Closeable {
/** /**
* Map of ActorType --> ActorManager. * Map of ActorType --> ActorManager.
*/ */
private final Map<String, ActorManager> actorManagers; private final ConcurrentMap<String, ActorManager> actorManagers;
/** /**
* The default constructor. This should not be called directly. * The default constructor. This should not be called directly.
@ -100,7 +99,7 @@ public class ActorRuntime implements Closeable {
} }
this.config = new ActorRuntimeConfig(); this.config = new ActorRuntimeConfig();
this.actorManagers = Collections.synchronizedMap(new HashMap<>()); this.actorManagers = new ConcurrentHashMap<>();
this.daprClient = daprClient; this.daprClient = daprClient;
this.channel = channel; this.channel = channel;
} }
@ -138,7 +137,7 @@ public class ActorRuntime implements Closeable {
* @throws IOException If cannot serialize config. * @throws IOException If cannot serialize config.
*/ */
public byte[] serializeConfig() throws IOException { public byte[] serializeConfig() throws IOException {
return this.INTERNAL_SERIALIZER.serialize(this.config); return INTERNAL_SERIALIZER.serialize(this.config);
} }
/** /**
@ -207,17 +206,18 @@ public class ActorRuntime implements Closeable {
ActorTypeInformation<T> actorTypeInfo = ActorTypeInformation.create(clazz); ActorTypeInformation<T> actorTypeInfo = ActorTypeInformation.create(clazz);
ActorRuntimeContext<T> context = new ActorRuntimeContext<>( // Create ActorManager, if not yet registered.
this, this.actorManagers.computeIfAbsent(actorTypeInfo.getName(), (k) -> {
objectSerializer, ActorRuntimeContext<T> context = new ActorRuntimeContext<>(
actorFactory, this,
actorTypeInfo, objectSerializer,
this.daprClient, actorFactory,
new DaprStateAsyncProvider(this.daprClient, stateSerializer)); actorTypeInfo,
this.daprClient,
// Create ActorManagers, override existing entry if registered again. new DaprStateAsyncProvider(this.daprClient, stateSerializer));
this.actorManagers.put(actorTypeInfo.getName(), new ActorManager<T>(context)); this.config.addRegisteredActorType(actorTypeInfo.getName());
this.config.addRegisteredActorType(actorTypeInfo.getName()); return new ActorManager<T>(context);
});
} }
/** /**
@ -342,4 +342,4 @@ public class ActorRuntime implements Closeable {
channel.shutdown(); channel.shutdown();
} }
} }
} }

View File

@ -1,29 +1,30 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */
package io.dapr.actors.runtime; package io.dapr.actors.runtime;
import java.time.Duration; import java.time.Duration;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
/** /**
* Represents the configuration for the Actor Runtime. * Represents the configuration for the Actor Runtime.
*/ */
public class ActorRuntimeConfig { public class ActorRuntimeConfig {
private Collection<String> registeredActorTypes = new ArrayList<>(); private List<String> registeredActorTypes = new CopyOnWriteArrayList<>();
private Duration actorIdleTimeout; private volatile Duration actorIdleTimeout;
private Duration actorScanInterval; private volatile Duration actorScanInterval;
private Duration drainOngoingCallTimeout; private volatile Duration drainOngoingCallTimeout;
private Boolean drainBalancedActors; private volatile Boolean drainBalancedActors;
/** /**
* Instantiates a new config for the Actor Runtime. * Instantiates a new config for the Actor Runtime.

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */
@ -67,4 +67,4 @@ final class ActorStateOperation {
public Object getValue() { public Object getValue() {
return value; return value;
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */
@ -87,4 +87,4 @@ final class ActorTimerParams {
return this.data; return this.data;
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */
package io.dapr.actors; package io.dapr.actors;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */
package io.dapr.actors.client; package io.dapr.actors.client;
@ -66,4 +66,4 @@ public class DaprHttpClientTest {
() -> mono.block()); () -> mono.block());
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */
package io.dapr.actors.runtime; package io.dapr.actors.runtime;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */
package io.dapr.actors.runtime; package io.dapr.actors.runtime;
@ -149,4 +149,4 @@ public class DaprHttpClientTest {
Mono<Void> mono = DaprHttpClient.unregisterTimer("DemoActor", "1", "timer"); Mono<Void> mono = DaprHttpClient.unregisterTimer("DemoActor", "1", "timer");
assertNull(mono.block()); assertNull(mono.block());
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) Microsoft Corporation. * Copyright (c) Microsoft Corporation and Dapr Contributors.
* Licensed under the MIT License. * Licensed under the MIT License.
*/ */

View File

@ -1 +1 @@
mock-maker-inline mock-maker-inline

Some files were not shown because too many files have changed in this diff Show More