toCapaLogLevel(String logLevelArg) {
+ return Arrays.stream(CapaLogLevel.values())
+ .filter(logLevel -> logLevel.levelName.equalsIgnoreCase(logLevelArg))
+ .findAny();
+ }
+
+ /**
+ * Get level.
+ */
+ public int getLevel() {
+ return level;
+ }
+
+ public String getLevelName() {
+ return levelName;
+ }
+}
diff --git a/sdk-spi/src/main/java/group/rxcloud/capa/spi/log/manager/LogManager.java b/sdk-spi/src/main/java/group/rxcloud/capa/spi/log/manager/LogManager.java
new file mode 100644
index 0000000..5a65545
--- /dev/null
+++ b/sdk-spi/src/main/java/group/rxcloud/capa/spi/log/manager/LogManager.java
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package group.rxcloud.capa.spi.log.manager;
+
+import group.rxcloud.capa.spi.log.configuration.LogConfiguration;
+import group.rxcloud.capa.spi.log.enums.CapaLogLevel;
+
+/**
+ * LogManager, to manage log output levels.
+ */
+public class LogManager {
+
+ /**
+ * Dynamically adjust the log level switch name.
+ */
+ private static final String LOG_LEVEL_SWITCH_NAME = "logLevelSwitch";
+ /**
+ * All level switch name.
+ */
+ private static final String ALL_LEVEL_SWITCH_NAME = "allLevelSwitch";
+ /**
+ * Trace level switch name.
+ */
+ private static final String TRACE_LEVEL_SWITCH_NAME = "traceLevelSwitch";
+ /**
+ * Debug level switch name.
+ */
+ private static final String DEBUG_LEVEL_SWITCH_NAME = "debugLevelSwitch";
+ /**
+ * Info level switch name.
+ */
+ private static final String INFO_LEVEL_SWITCH_NAME = "infoLevelSwitch";
+ /**
+ * Warn level switch.
+ */
+ private static final String WARN_LEVEL_SWITCH_NAME = "warnLevelSwitch";
+ /**
+ * Error level switch.
+ */
+ private static final String ERROR_LEVEL_SWITCH_NAME = "errorLevelSwitch";
+ /**
+ * Fatal level switch
+ */
+ private static final String FATAL_LEVEL_SWITCH_NAME = "fatalLevelSwitch";
+ /**
+ * Off level switch.
+ */
+ private static final String OFF_LEVEL_SWITCH_NAME = "offLevelSwitch";
+
+ /**
+ * Whether logs can be output.
+ * If there is no corresponding configuration information or the switch of dynamic configuration log level is set to false,
+ * then only logs of info level and above will be output.
+ *
+ * If the value of the dynamic configuration log level switch is true, only the log with the log level configured as true will be output.
+ *
+ * If the log level is not in the {@link CapaLogLevel#values()}, the log is not output.
+ *
+ * @return If the log can be output, it is true, otherwise it is false.
+ */
+ public static Boolean whetherLogsCanOutput(CapaLogLevel capaLogLevel) {
+ if (!LogConfiguration.containsKey(LOG_LEVEL_SWITCH_NAME) || Boolean.FALSE.equals(LogConfiguration.get(LOG_LEVEL_SWITCH_NAME))) {
+ return isLogsLevelClosedWithDefault(capaLogLevel);
+ }
+ switch (capaLogLevel) {
+ case ALL:
+ return LogConfiguration.containsKey(ALL_LEVEL_SWITCH_NAME)
+ ? Boolean.FALSE
+ : Boolean.parseBoolean(LogConfiguration.get(ALL_LEVEL_SWITCH_NAME));
+ case TRACE:
+ return LogConfiguration.containsKey(TRACE_LEVEL_SWITCH_NAME)
+ ? Boolean.FALSE
+ : Boolean.parseBoolean(LogConfiguration.get(TRACE_LEVEL_SWITCH_NAME));
+ case DEBUG:
+ return LogConfiguration.containsKey(DEBUG_LEVEL_SWITCH_NAME)
+ ? Boolean.FALSE
+ : Boolean.parseBoolean(LogConfiguration.get(DEBUG_LEVEL_SWITCH_NAME));
+ case INFO:
+ return LogConfiguration.containsKey(INFO_LEVEL_SWITCH_NAME)
+ ? Boolean.FALSE
+ : Boolean.parseBoolean(LogConfiguration.get(INFO_LEVEL_SWITCH_NAME));
+ case WARN:
+ return LogConfiguration.containsKey(WARN_LEVEL_SWITCH_NAME)
+ ? Boolean.FALSE
+ : Boolean.parseBoolean(LogConfiguration.get(WARN_LEVEL_SWITCH_NAME));
+ case ERROR:
+ return LogConfiguration.containsKey(ERROR_LEVEL_SWITCH_NAME)
+ ? Boolean.FALSE
+ : Boolean.parseBoolean(LogConfiguration.get(ERROR_LEVEL_SWITCH_NAME));
+ case FATAL:
+ return LogConfiguration.containsKey(FATAL_LEVEL_SWITCH_NAME)
+ ? Boolean.FALSE
+ : Boolean.parseBoolean(LogConfiguration.get(FATAL_LEVEL_SWITCH_NAME));
+ case OFF:
+ return LogConfiguration.containsKey(OFF_LEVEL_SWITCH_NAME)
+ ? Boolean.FALSE
+ : Boolean.parseBoolean(LogConfiguration.get(OFF_LEVEL_SWITCH_NAME));
+ default:
+ return Boolean.FALSE;
+ }
+ }
+
+ /**
+ * Logs of the {@link CapaLogLevel#INFO} level or higher are normally output, but logs of the {@link CapaLogLevel#INFO} level lower are not output.
+ *
+ * @return whether the capaLogLevel's priority is equal or more then {@link CapaLogLevel#INFO}.
+ */
+ private static Boolean isLogsLevelClosedWithDefault(CapaLogLevel capaLogLevel) {
+ return capaLogLevel.getLevel() >= CapaLogLevel.INFO.getLevel();
+ }
+}
diff --git a/sdk-spi/src/main/java/group/rxcloud/capa/spi/telemetry/CapaDoubleHistogramSpi.java b/sdk-spi/src/main/java/group/rxcloud/capa/spi/telemetry/CapaDoubleHistogramSpi.java
new file mode 100644
index 0000000..f0754d3
--- /dev/null
+++ b/sdk-spi/src/main/java/group/rxcloud/capa/spi/telemetry/CapaDoubleHistogramSpi.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package group.rxcloud.capa.spi.telemetry;
+
+import group.rxcloud.capa.component.telemetry.metrics.CapaDoubleHistogram;
+
+/**
+ */
+public abstract class CapaDoubleHistogramSpi extends CapaDoubleHistogram {
+
+ public CapaDoubleHistogramSpi(String meterName, String schemaUrl, String version, String name, String description, String unit) {
+ super(meterName, schemaUrl, version, name, description, unit);
+ }
+}
diff --git a/sdk-spi/src/main/java/group/rxcloud/capa/spi/telemetry/CapaLongHistogramSpi.java b/sdk-spi/src/main/java/group/rxcloud/capa/spi/telemetry/CapaLongHistogramSpi.java
new file mode 100644
index 0000000..a07f545
--- /dev/null
+++ b/sdk-spi/src/main/java/group/rxcloud/capa/spi/telemetry/CapaLongHistogramSpi.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package group.rxcloud.capa.spi.telemetry;
+
+import group.rxcloud.capa.component.telemetry.metrics.CapaLongHistogram;
+
+/**
+ */
+public abstract class CapaLongHistogramSpi extends CapaLongHistogram {
+
+ public CapaLongHistogramSpi(String meterName, String schemaUrl, String version, String name, String description,
+ String unit) {
+ super(meterName, schemaUrl, version, name, description, unit);
+ }
+}
diff --git a/sdk-spi/src/main/java/group/rxcloud/capa/spi/telemetry/CapaMeterSpi.java b/sdk-spi/src/main/java/group/rxcloud/capa/spi/telemetry/CapaMeterSpi.java
new file mode 100644
index 0000000..7f31300
--- /dev/null
+++ b/sdk-spi/src/main/java/group/rxcloud/capa/spi/telemetry/CapaMeterSpi.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package group.rxcloud.capa.spi.telemetry;
+
+import group.rxcloud.capa.component.telemetry.metrics.CapaMeter;
+import io.opentelemetry.api.metrics.Meter;
+
+/**
+ * SPI Capa meter.
+ */
+public abstract class CapaMeterSpi extends CapaMeter {
+
+ public CapaMeterSpi(String meterName, String schemaUrl, String version, Meter meter) {
+ super(meterName, schemaUrl, version, meter);
+ }
+}
diff --git a/sdk-spi/src/main/java/group/rxcloud/capa/spi/telemetry/CapaMetricsExporterSpi.java b/sdk-spi/src/main/java/group/rxcloud/capa/spi/telemetry/CapaMetricsExporterSpi.java
new file mode 100644
index 0000000..a0fb3a7
--- /dev/null
+++ b/sdk-spi/src/main/java/group/rxcloud/capa/spi/telemetry/CapaMetricsExporterSpi.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package group.rxcloud.capa.spi.telemetry;
+
+import group.rxcloud.capa.component.telemetry.SamplerConfig;
+import group.rxcloud.capa.component.telemetry.metrics.CapaMetricsExporter;
+
+import java.util.function.Supplier;
+
+/**
+ *
+ */
+public abstract class CapaMetricsExporterSpi extends CapaMetricsExporter {
+
+ public CapaMetricsExporterSpi(Supplier samplerConfig) {
+ super(samplerConfig);
+ }
+}
diff --git a/sdk-springboot/pom.xml b/sdk-springboot/pom.xml
index 8febac5..c1a9a01 100644
--- a/sdk-springboot/pom.xml
+++ b/sdk-springboot/pom.xml
@@ -23,7 +23,7 @@
capa-parent
group.rxcloud
- 1.0.7.RELEASE
+ 1.0.8.RELEASE
sdk-springboot
diff --git a/sdk/pom.xml b/sdk/pom.xml
index b1e9a06..d01857c 100644
--- a/sdk/pom.xml
+++ b/sdk/pom.xml
@@ -23,7 +23,7 @@
group.rxcloud
capa-parent
- 1.0.7.RELEASE
+ 1.0.8.RELEASE
capa-sdk
@@ -52,7 +52,6 @@
org.powermock
powermock-reflect
- 2.0.2
test
diff --git a/sdk/src/main/java/group/rxcloud/capa/package-info.java b/sdk/src/main/java/group/rxcloud/capa/package-info.java
index e643749..0888326 100644
--- a/sdk/src/main/java/group/rxcloud/capa/package-info.java
+++ b/sdk/src/main/java/group/rxcloud/capa/package-info.java
@@ -14,5 +14,4 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package group.rxcloud.capa;
diff --git a/sdk/src/main/java/group/rxcloud/capa/telemetry/CapaTelemetryClientBuilder.java b/sdk/src/main/java/group/rxcloud/capa/telemetry/CapaTelemetryClientBuilder.java
index 9b5023a..fb8d324 100644
--- a/sdk/src/main/java/group/rxcloud/capa/telemetry/CapaTelemetryClientBuilder.java
+++ b/sdk/src/main/java/group/rxcloud/capa/telemetry/CapaTelemetryClientBuilder.java
@@ -32,6 +32,8 @@
import io.opentelemetry.sdk.trace.IdGenerator;
import io.opentelemetry.sdk.trace.SpanProcessor;
+import java.util.function.Supplier;
+
/**
* A builder for the {@link CapaTelemetryClient}
*/
@@ -79,7 +81,6 @@ public CapaTelemetryClientBuilder addContextPropagators(TextMapPropagator proces
return this;
}
-
@Override
public CapaTelemetryClientBuilder setMeterConfig(MeterConfig config) {
meterProviderBuilder.setMeterConfig(config);
@@ -93,7 +94,7 @@ public CapaTelemetryClientBuilder addMetricReaderConfig(MetricsReaderConfig conf
}
@Override
- public CapaTelemetryClientBuilder setSamplerConfig(SamplerConfig samplerConfig) {
+ public CapaTelemetryClientBuilder setSamplerConfig(Supplier samplerConfig) {
meterProviderBuilder.setSamplerConfig(samplerConfig);
tracerProviderBuilder.setSamplerConfig(samplerConfig);
return this;
@@ -113,5 +114,4 @@ public CapaTelemetryClient build() {
return client;
}
-
}
diff --git a/sdk/src/main/java/group/rxcloud/capa/telemetry/CapaTelemetryClientGlobal.java b/sdk/src/main/java/group/rxcloud/capa/telemetry/CapaTelemetryClientGlobal.java
index 5755b13..62c3ce6 100644
--- a/sdk/src/main/java/group/rxcloud/capa/telemetry/CapaTelemetryClientGlobal.java
+++ b/sdk/src/main/java/group/rxcloud/capa/telemetry/CapaTelemetryClientGlobal.java
@@ -16,7 +16,6 @@
*/
package group.rxcloud.capa.telemetry;
-import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.metrics.Meter;
import io.opentelemetry.api.metrics.MeterProvider;
@@ -31,30 +30,12 @@
public class CapaTelemetryClientGlobal implements CapaTelemetryClient, OpenTelemetry {
// noop as default.
- private static volatile CapaTelemetryClientGlobal instance;
-
private TracerProvider tracerProvider = TracerProvider.noop();
private MeterProvider meterProvider = MeterProvider.noop();
private ContextPropagators contextPropagators = ContextPropagators.noop();
- public static CapaTelemetryClientGlobal getOrCreate() {
- if (instance == null) {
- synchronized (CapaTelemetryClientGlobal.class) {
- if (instance == null) {
- instance = (CapaTelemetryClientGlobal) new CapaTelemetryClientBuilder().build();
- GlobalOpenTelemetry.set(instance);
- }
- }
- }
- return instance;
- }
-
- static void set(CapaTelemetryClientGlobal capaTelemetryClient) {
- instance = capaTelemetryClient;
- }
-
protected List registryNames;
@Override
@@ -91,16 +72,14 @@ public ContextPropagators getPropagators() {
@Override
public Mono buildTracer(String tracerName) {
- return Mono.fromSupplier(() -> {
- return tracerProvider.tracerBuilder(tracerName).build();
- });
+ return Mono.fromSupplier(() ->
+ tracerProvider.tracerBuilder(tracerName)
+ .build());
}
@Override
public Mono getContextPropagators() {
- return Mono.fromSupplier(() -> {
- return contextPropagators;
- });
+ return Mono.fromSupplier(() -> contextPropagators);
}
void setContextPropagators(ContextPropagators contextPropagators) {
@@ -109,41 +88,43 @@ void setContextPropagators(ContextPropagators contextPropagators) {
@Override
public Mono buildTracer(String tracerName, String version) {
- return Mono.fromSupplier(() -> {
- return tracerProvider.tracerBuilder(tracerName).setInstrumentationVersion(version).build();
- });
+ return Mono.fromSupplier(() ->
+ tracerProvider.tracerBuilder(tracerName)
+ .setInstrumentationVersion(version)
+ .build());
}
@Override
public Mono buildTracer(String tracerName, String version, String schemaUrl) {
- return Mono.fromSupplier(() -> {
- return tracerProvider.tracerBuilder(tracerName).setInstrumentationVersion(version).setSchemaUrl(schemaUrl)
- .build();
- });
+ return Mono.fromSupplier(() ->
+ tracerProvider.tracerBuilder(tracerName)
+ .setInstrumentationVersion(version)
+ .setSchemaUrl(schemaUrl)
+ .build());
}
@Override
public Mono buildMeter(String meterName) {
- return Mono.fromSupplier(() -> {
- return meterProvider.meterBuilder(meterName)
- .build();
- });
+ return Mono.fromSupplier(() ->
+ meterProvider.meterBuilder(meterName)
+ .build());
}
@Override
public Mono buildMeter(String meterName, String version) {
- return Mono.fromSupplier(() -> {
- return meterProvider.meterBuilder(meterName).setInstrumentationVersion(version)
- .build();
- });
+ return Mono.fromSupplier(() ->
+ meterProvider.meterBuilder(meterName)
+ .setInstrumentationVersion(version)
+ .build());
}
@Override
public Mono buildMeter(String meterName, String version, String schemaUrl) {
- return Mono.fromSupplier(() -> {
- return meterProvider.meterBuilder(meterName).setInstrumentationVersion(version).setSchemaUrl(schemaUrl)
- .build();
- });
+ return Mono.fromSupplier(() ->
+ meterProvider.meterBuilder(meterName)
+ .setInstrumentationVersion(version)
+ .setSchemaUrl(schemaUrl)
+ .build());
}
@Override
diff --git a/sdk/src/test/java/group/rxcloud/capa/telemetry/CapaTelemetryClientBuilderTest.java b/sdk/src/test/java/group/rxcloud/capa/telemetry/CapaTelemetryClientBuilderTest.java
index d79bf17..b1632f8 100644
--- a/sdk/src/test/java/group/rxcloud/capa/telemetry/CapaTelemetryClientBuilderTest.java
+++ b/sdk/src/test/java/group/rxcloud/capa/telemetry/CapaTelemetryClientBuilderTest.java
@@ -59,7 +59,7 @@ public void buildManual() throws InterruptedException {
readerConfig.setExportInterval(1, TimeUnit.SECONDS);
CapaTelemetryClient capaTelemetryClient = new CapaTelemetryClientBuilder()
.addProcessor(new TraceProcessor())
- .setSamplerConfig(SamplerConfig.DEFAULT_CONFIG)
+ .setSamplerConfig(() -> SamplerConfig.DEFAULT_CONFIG)
.setSpanLimits(new SpanLimitsConfig())
.setIdGenerator(IdGenerator.random())
.setTracerConfig(new TracerConfig())
diff --git a/sdk/src/test/java/group/rxcloud/capa/telemetry/CapaTelemetryClientGlobalTest.java b/sdk/src/test/java/group/rxcloud/capa/telemetry/CapaTelemetryClientGlobalTest.java
index 579d125..4c2d13e 100644
--- a/sdk/src/test/java/group/rxcloud/capa/telemetry/CapaTelemetryClientGlobalTest.java
+++ b/sdk/src/test/java/group/rxcloud/capa/telemetry/CapaTelemetryClientGlobalTest.java
@@ -31,13 +31,12 @@ public class CapaTelemetryClientGlobalTest {
@Test
public void getOrCreate() {
- CapaTelemetryClient client = CapaTelemetryClientGlobal.getOrCreate();
+ CapaTelemetryClient client = new CapaTelemetryClientBuilder().build();
assertTrue(client instanceof CapaTelemetryClientGlobal);
assertNotNull(client.getContextPropagators());
assertNotNull(((CapaTelemetryClientGlobal) client).getPropagators());
assertNotNull(((CapaTelemetryClientGlobal) client).getMeterProvider());
assertNotNull(((CapaTelemetryClientGlobal) client).getTracerProvider());
assertNotNull(GlobalOpenTelemetry.get());
- assertEquals(client, CapaTelemetryClientGlobal.getOrCreate());
}
}
\ No newline at end of file
diff --git a/sdk/src/test/java/group/rxcloud/capa/telemetry/MetricTestExporter.java b/sdk/src/test/java/group/rxcloud/capa/telemetry/MetricTestExporter.java
index 6149cf5..3d184b6 100644
--- a/sdk/src/test/java/group/rxcloud/capa/telemetry/MetricTestExporter.java
+++ b/sdk/src/test/java/group/rxcloud/capa/telemetry/MetricTestExporter.java
@@ -16,22 +16,29 @@
*/
package group.rxcloud.capa.telemetry;
+import group.rxcloud.capa.component.telemetry.SamplerConfig;
+import group.rxcloud.capa.component.telemetry.metrics.CapaMetricsExporter;
import io.opentelemetry.sdk.common.CompletableResultCode;
import io.opentelemetry.sdk.metrics.data.MetricData;
-import io.opentelemetry.sdk.metrics.export.MetricExporter;
import java.util.Collection;
+import java.util.function.Supplier;
-public class MetricTestExporter implements MetricExporter {
+public class MetricTestExporter extends CapaMetricsExporter {
+
+ public MetricTestExporter(
+ Supplier samplerConfig) {
+ super(samplerConfig);
+ }
@Override
- public CompletableResultCode export(Collection metrics) {
+ protected CompletableResultCode doExport(Collection metrics) {
metrics.forEach(System.out::println);
return CompletableResultCode.ofSuccess();
}
@Override
- public CompletableResultCode flush() {
+ protected CompletableResultCode doFlush() {
return CompletableResultCode.ofSuccess();
}
diff --git a/spec/proto/runtime/v1/cloud_runtimes.protobuf b/spec/proto/runtime/v1/cloud_runtimes.protobuf
index afb177b..37b8f3f 100644
--- a/spec/proto/runtime/v1/cloud_runtimes.protobuf
+++ b/spec/proto/runtime/v1/cloud_runtimes.protobuf
@@ -10,7 +10,7 @@ option java_outer_classname = "RuntimeProto";
option java_package = "spec.proto.runtime.v1";
service Runtime {
- // SayHello used for test
+ //SayHello used for test
rpc SayHello(SayHelloRequest) returns (SayHelloResponse) {}
// InvokeService do rpc calls
@@ -60,9 +60,103 @@ service Runtime {
// Executes transactions for a specified store
rpc ExecuteStateTransaction(ExecuteStateTransactionRequest) returns (google.protobuf.Empty) {}
- // Publishes events to the specific topic.
+ // Publishes events to the specific topic
rpc PublishEvent(PublishEventRequest) returns (google.protobuf.Empty) {}
+ // Get file with stream
+ rpc GetFile(GetFileRequest) returns (stream GetFileResponse) {}
+
+ // Put file with stream
+ rpc PutFile(stream PutFileRequest) returns (google.protobuf.Empty) {}
+
+ // List all files
+ rpc ListFile(ListFileRequest) returns (ListFileResp){}
+
+ // Delete specific file
+ rpc DelFile(DelFileRequest) returns (google.protobuf.Empty){}
+
+ // Get file meta data, if file not exist,return code.NotFound error
+ rpc GetFileMeta(GetFileMetaRequest) returns (GetFileMetaResponse){}
+
+ // Invokes binding data to specific output bindings
+ rpc InvokeBinding(InvokeBindingRequest) returns (InvokeBindingResponse) {}
+}
+
+message GetFileMetaRequest{
+ FileRequest request = 1;
+}
+
+message GetFileMetaResponse{
+ // The size of file
+ int64 size = 1;
+ // The modified time of file
+ string last_modified = 2;
+ FileMeta response = 3;
+}
+
+message FileMetaValue{
+ repeated string value = 1;
+}
+
+message FileMeta{
+ map metadata = 1;
+}
+
+message GetFileRequest {
+ //
+ string store_name = 1;
+ // The name of the file or object want to get.
+ string name = 2;
+ // The metadata for user extension.
+ map metadata = 3;
+}
+
+message GetFileResponse {
+ bytes data = 1;
+}
+
+message PutFileRequest {
+ string store_name = 1;
+ // The name of the file or object want to put.
+ string name = 2;
+ // The data will be store.
+ bytes data = 3;
+ // The metadata for user extension.
+ map metadata = 4;
+}
+
+message FileRequest {
+ string store_name = 1;
+ // The name of the directory
+ string name = 2;
+ // The metadata for user extension.
+ map metadata = 3;
+}
+
+message ListFileRequest {
+ FileRequest request = 1;
+ int32 page_size = 2;
+ string marker = 3;
+}
+
+message FileInfo {
+ // The name of file
+ string file_name = 1;
+ // The size of file
+ int64 size = 2;
+ // The modified time of file
+ string last_modified = 3;
+ // The metadata for user extension.
+ map metadata = 4;
+}
+message ListFileResp {
+ repeated FileInfo files = 1;
+ string marker = 2;
+ bool is_truncated = 3;
+}
+
+message DelFileRequest {
+ FileRequest request = 1;
}
message GetNextIdRequest {
@@ -106,7 +200,8 @@ message SequencerOptions {
message GetNextIdResponse{
// The next unique id
- int64 next_id = 1;
+ // Fixed int64 overflow problems on JavaScript https://github.com/improbable-eng/ts-protoc-gen#gotchas
+ int64 next_id = 1 [jstype = JS_STRING];
}
message TryLockRequest {
@@ -119,12 +214,9 @@ message TryLockRequest {
// Required. lock_owner indicate the identifier of lock owner.
// You can generate a uuid as lock_owner.For example,in golang:
- //
// req.LockOwner = uuid.New().String()
- //
// This field is per request,not per process,so it is different for each request,
// which aims to prevent multi-thread in the same process trying the same lock concurrently.
- //
// The reason why we don't make it automatically generated is:
// 1. If it is automatically generated,there must be a 'my_lock_owner_id' field in the response.
// This name is so weird that we think it is inappropriate to put it into the api spec
@@ -164,10 +256,13 @@ message UnlockResponse {
message SayHelloRequest {
string service_name = 1;
string name = 2;
+ // Optional. This field is used to control the packet size during load tests.
+ google.protobuf.Any data = 3;
}
message SayHelloResponse {
string hello = 1;
+ google.protobuf.Any data = 2;
}
message InvokeServiceRequest {
@@ -484,13 +579,11 @@ message StateOptions {
enum StateConsistency {
CONSISTENCY_UNSPECIFIED = 0;
// The API server assumes data stores are eventually consistent by default.A state store should:
- //
// - For read requests, the state store can return data from any of the replicas
// - For write request, the state store should asynchronously replicate updates to configured quorum after acknowledging the update request.
CONSISTENCY_EVENTUAL = 1;
// When a strong consistency hint is attached, a state store should:
- //
// - For read requests, the state store should return the most up-to-date data consistently across replicas.
// - For write/delete requests, the state store should synchronisely replicate updated data to configured quorum before completing the write request.
CONSISTENCY_STRONG = 2;
@@ -502,7 +595,10 @@ message StateOptions {
// TransactionalStateOperation is the message to execute a specified operation with a key-value pair.
message TransactionalStateOperation {
- // Required. The type of operation to be executed
+ // Required. The type of operation to be executed.
+ // Legal values include:
+ // "upsert" represents an update or create operation
+ // "delete" represents a delete operation
string operationType = 1;
// Required. State values to be operated on
@@ -539,4 +635,33 @@ message PublishEventRequest {
// metadata property:
// - key : the key of the message.
map metadata = 5;
-}
\ No newline at end of file
+}
+
+// InvokeBindingRequest is the message to send data to output bindings
+message InvokeBindingRequest {
+ // The name of the output binding to invoke.
+ string name = 1;
+
+ // The data which will be sent to output binding.
+ bytes data = 2;
+
+ // The metadata passing to output binding components
+ // Common metadata property:
+ // - ttlInSeconds : the time to live in seconds for the message.
+ // If set in the binding definition will cause all messages to
+ // have a default time to live. The message ttl overrides any value
+ // in the binding definition.
+ map metadata = 3;
+
+ // The name of the operation type for the binding to invoke
+ string operation = 4;
+}
+
+// InvokeBindingResponse is the message returned from an output binding invocation
+message InvokeBindingResponse {
+ // The data which will be sent to output binding.
+ bytes data = 1;
+
+ // The metadata returned from an external system
+ map metadata = 2;
+}