code
stringlengths
0
56.1M
repo_name
stringclasses
515 values
path
stringlengths
2
147
language
stringclasses
447 values
license
stringclasses
7 values
size
int64
0
56.8M
data*.db*
mikeee/dapr
tests/apps/actorinvocationapp/.gitignore
Git
mit
9
/* Copyright 2021 The Dapr Authors Licensed 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 main import ( "bytes" "encoding/json" "fmt" "io" "log" "net/http" "os" "strconv" "strings" "github.com/dapr/dapr/tests/apps/utils" "github.com/gorilla/mux" ) const ( daprBaseURL = "http://localhost:%d//v1.0" // Using "//" to repro regression. daprActorMethodURL = daprBaseURL + "/actors/%s/%s/method/%s" defaultActorTypes = "actor1,actor2" // Actor type must be unique per test app. actorTypesEnvName = "TEST_APP_ACTOR_TYPES" // To set to change actor types. actorIdleTimeout = "5s" // Short idle timeout. drainOngoingCallTimeout = "1s" drainRebalancedActors = true ) var ( appPort = 3000 daprHTTPPort = 3500 ) func init() { p := os.Getenv("DAPR_HTTP_PORT") if p != "" && p != "0" { daprHTTPPort, _ = strconv.Atoi(p) } p = os.Getenv("PORT") if p != "" && p != "0" { appPort, _ = strconv.Atoi(p) } } type callRequest struct { ActorType string `json:"actorType"` ActorID string `json:"actorId"` Method string `json:"method"` RemoteActorID string `json:"remoteId,omitempty"` RemoteActorType string `json:"remoteType,omitempty"` } type daprConfig struct { Entities []string `json:"entities,omitempty"` ActorIdleTimeout string `json:"actorIdleTimeout,omitempty"` DrainOngoingCallTimeout string `json:"drainOngoingCallTimeout,omitempty"` DrainRebalancedActors bool `json:"drainRebalancedActors,omitempty"` } var daprConfigResponse = daprConfig{ getActorTypes(), actorIdleTimeout, drainOngoingCallTimeout, drainRebalancedActors, } func getActorTypes() []string { actorTypes := os.Getenv(actorTypesEnvName) if actorTypes == "" { return strings.Split(defaultActorTypes, ",") } return strings.Split(actorTypes, ",") } func parseCallRequest(r *http.Request) (callRequest, []byte, error) { defer r.Body.Close() body, err := io.ReadAll(r.Body) if err != nil { log.Printf("Could not read request body: %v", err) return callRequest{}, body, err } var request callRequest json.Unmarshal(body, &request) return request, body, nil } func healthzHandler(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) w.Write([]byte("")) } // This method is required for actor registration (provides supported types). func configHandler(w http.ResponseWriter, r *http.Request) { log.Printf("Processing dapr request for %s", r.URL.RequestURI()) w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusOK) json.NewEncoder(w).Encode(daprConfigResponse) } func callActorMethod(w http.ResponseWriter, r *http.Request) { log.Println("callActorMethod is called") request, body, err := parseCallRequest(r) if err != nil { log.Printf("Could not parse request body: %v", err) w.WriteHeader(http.StatusInternalServerError) return } invokeURL := fmt.Sprintf(daprActorMethodURL, daprHTTPPort, request.ActorType, request.ActorID, request.Method) log.Printf("Calling actor with: %s", invokeURL) resp, err := http.Post(invokeURL, "application/json", bytes.NewBuffer(body)) //nolint:gosec if resp != nil { defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) log.Printf("Resp: %s", string(respBody)) w.WriteHeader(resp.StatusCode) w.Write(respBody) } if err != nil { log.Printf("Failed to call actor: %s\n", err.Error()) w.WriteHeader(http.StatusInternalServerError) return } } func logCall(w http.ResponseWriter, r *http.Request) { log.Printf("logCall is called") actorType := mux.Vars(r)["actorType"] actorID := mux.Vars(r)["actorId"] resp := fmt.Sprintf("Log call with - actorType: %s, actorId: %s", actorType, actorID) log.Println(resp) w.Write([]byte(resp)) } func xDaprErrorResponseHeader(w http.ResponseWriter, r *http.Request) { log.Printf("xDaprErrorResponseHeader is called") actorType := mux.Vars(r)["actorType"] actorID := mux.Vars(r)["actorId"] resp := fmt.Sprintf("x-DaprErrorResponseHeader call with - actorType: %s, actorId: %s", actorType, actorID) log.Println(resp) w.Header().Add("x-DaprErrorResponseHeader", "Simulated error") w.Write([]byte(resp)) } func callDifferentActor(w http.ResponseWriter, r *http.Request) { log.Println("callDifferentActor is called") request, _, err := parseCallRequest(r) if err != nil { log.Printf("Could not parse request body: %s\n", err.Error()) w.WriteHeader(http.StatusInternalServerError) return } invokeURL := fmt.Sprintf(daprActorMethodURL, daprHTTPPort, request.RemoteActorType, request.RemoteActorID, "logCall") log.Printf("Calling remote actor with: %s", invokeURL) resp, err := http.Post(invokeURL, "application/json", bytes.NewBuffer([]byte{})) //nolint:gosec if resp != nil { defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) log.Printf("Resp: %s", string(respBody)) w.WriteHeader(resp.StatusCode) w.Write(respBody) } if err != nil { log.Printf("Failed to call remote actor: %s\n", err.Error()) w.WriteHeader(http.StatusInternalServerError) return } } func deactivateActorHandler(w http.ResponseWriter, r *http.Request) { log.Printf("Deactivated actor: %s", r.URL.RequestURI()) w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusOK) } // indexHandler is the handler for root path. func indexHandler(w http.ResponseWriter, r *http.Request) { log.Println("indexHandler is called") w.WriteHeader(http.StatusOK) } // appRouter initializes restful api router. func appRouter() http.Handler { router := mux.NewRouter().StrictSlash(true) // Log requests and their processing time router.Use(utils.LoggerMiddleware) router.HandleFunc("/", indexHandler).Methods("GET") // Actor methods are individually bound so we can experiment with missing messages router.HandleFunc("/actors/{actorType}/{actorId}/method/logCall", logCall).Methods("POST", "PUT") router.HandleFunc("/actors/{actorType}/{actorId}/method/xDaprErrorResponseHeader", xDaprErrorResponseHeader).Methods("POST", "PUT") router.HandleFunc("/actors/{actorType}/{actorId}/method/callDifferentActor", callDifferentActor).Methods("POST", "PUT") router.HandleFunc("/actors/{actorType}/{id}", deactivateActorHandler).Methods("POST", "DELETE") router.HandleFunc("/dapr/config", configHandler).Methods("GET") router.HandleFunc("/healthz", healthzHandler).Methods("GET") router.HandleFunc("/test/callActorMethod", callActorMethod).Methods("POST") router.Use(mux.CORSMethodMiddleware(router)) return router } func main() { log.Printf("Actor Invocation App - listening on http://localhost:%d", appPort) utils.StartServer(appPort, appRouter, true, false) }
mikeee/dapr
tests/apps/actorinvocationapp/app.go
GO
mit
7,157
apiVersion: dapr.io/v1alpha1 kind: Component metadata: name: statestore1 spec: type: state.sqlite version: v1 metadata: - name: actorStateStore value: "true" - name: connectionString value: "data1.db" scopes: - actor1
mikeee/dapr
tests/apps/actorinvocationapp/resources/sqlite1.yaml
YAML
mit
247
apiVersion: dapr.io/v1alpha1 kind: Component metadata: name: statestore2 spec: type: state.sqlite version: v1 metadata: - name: actorStateStore value: "true" - name: connectionString value: "data2.db" scopes: - actor2
mikeee/dapr
tests/apps/actorinvocationapp/resources/sqlite2.yaml
YAML
mit
247
# In e2e test, this will not be used to deploy the app to test cluster. # This is created for testing purpose in order to deploy this app using kubectl # before writing e2e test. kind: Service apiVersion: v1 metadata: name: actorinvocationapp labels: testapp: actorinvocationapp spec: selector: testapp: actorinvocationapp ports: - protocol: TCP port: 80 targetPort: 3000 type: LoadBalancer --- apiVersion: apps/v1 kind: Deployment metadata: name: stateapp labels: testapp: actorinvocationapp spec: replicas: 1 selector: matchLabels: testapp: actorinvocationapp template: metadata: labels: testapp: actorinvocationapp annotations: dapr.io/enabled: "true" dapr.io/app-id: "actorinvocationapp" dapr.io/app-port: "3000" spec: containers: - name: actorinvocationapp image: docker.io/YOUR_ALIAS/e2e-actorinvocationapp:dev ports: - containerPort: 3000 imagePullPolicy: Always
mikeee/dapr
tests/apps/actorinvocationapp/service.yaml
YAML
mit
1,020
.project .classpath .settings /server.restapi/gitignore /server.restapi/*.log /server.restapi/.settings/* /adminInterface/node_modules /server.restapi.dynamic/target/classes/com/bosch/iot/dashboard/api/adapter/*.class /server.restapi.dynamic/target /webhooks/target /.metadata/ .idea */**/*.iml *.iml /bin/ */**/target/ target/ *.log *.swp */**/lombok*.jar lombok*.jar *private.env.json */**/node_modules/
mikeee/dapr
tests/apps/actorjava/.gitignore
Git
mit
406
# build stage build the jar with all our resources FROM maven:3-eclipse-temurin-11 as build VOLUME /tmp WORKDIR /build COPY pom.xml . RUN mvn dependency:go-offline ADD src/ /build/src/ RUN mvn package # package stage FROM eclipse-temurin:11-jre ARG JAR_FILE COPY --from=build /build/target/app.jar /opt/app.jar WORKDIR /opt/ EXPOSE 3000 ENTRYPOINT java -jar app.jar --server.port=3000
mikeee/dapr
tests/apps/actorjava/Dockerfile
Dockerfile
mit
390
ARG WINDOWS_VERSION=ltsc2022 # We are adding a Dockerfile because the building tools expect one, but we do not test this app on Windows FROM mcr.microsoft.com/windows/nanoserver:$WINDOWS_VERSION
mikeee/dapr
tests/apps/actorjava/Dockerfile-windows
none
mit
195
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.3.0.RELEASE</version> </parent> <groupId>io.dapr.apps.actor</groupId> <artifactId>actorjava</artifactId> <version>0.0.0-SNAPSHOT</version> <packaging>jar</packaging> <name>actorjava</name> <description>Module for polling against adapters</description> <properties> <dapr-sdk.version>1.0.0-rc-2</dapr-sdk.version> </properties> <repositories> <repository> <id>oss-snapshots</id> <url>https://oss.sonatype.org/content/repositories/snapshots</url> </repository> <repository> <id>oss-release</id> <url>https://oss.sonatype.org/content/repositories/releases/</url> </repository> </repositories> <distributionManagement> <!-- BEGIN: Dapr's repositories --> <!-- END: Dapr's repositories --> </distributionManagement> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>io.dapr</groupId> <artifactId>dapr-sdk</artifactId> <version>${dapr-sdk.version}</version> </dependency> <dependency> <groupId>io.dapr</groupId> <artifactId>dapr-sdk-springboot</artifactId> <version>${dapr-sdk.version}</version> </dependency> <dependency> <groupId>io.dapr</groupId> <artifactId>dapr-sdk-actors</artifactId> <version>${dapr-sdk.version}</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> </dependency> <dependency> <groupId>com.fasterxml.jackson.module</groupId> <artifactId>jackson-module-kotlin</artifactId> </dependency> <dependency> <groupId>com.squareup.okhttp3</groupId> <artifactId>okhttp</artifactId> <version>4.2.1</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-autoconfigure</artifactId> </dependency> <dependency> <groupId>com.fasterxml.jackson.datatype</groupId> <artifactId>jackson-datatype-jsr310</artifactId> <version>2.11.0</version> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </dependency> </dependencies> <build> <finalName>app</finalName> <resources> <resource> <directory>src/main/resources</directory> </resource> </resources> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> </plugin> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
mikeee/dapr
tests/apps/actorjava/pom.xml
XML
mit
3,721
/* Copyright 2021 The Dapr Authors Licensed 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 io.dapr.apps.actor; import java.util.HashMap; import java.util.Map; import java.util.function.Function; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import io.dapr.actors.client.ActorProxy; import io.dapr.actors.client.ActorProxyBuilder; @Configuration public class ActorConfig { private static final Map<String, ActorProxyBuilder<ActorProxy>> BUILDERS = new HashMap<>(); @Bean(name = "actorProxyBuilderFunction") public Function<String, ActorProxyBuilder<ActorProxy>> actorProxyBuilderFunction() { return actorType -> { synchronized(BUILDERS) { ActorProxyBuilder<ActorProxy> builder = BUILDERS.get(actorType); if (builder != null) { return builder; } builder = new ActorProxyBuilder<>(actorType, ActorProxy.class); BUILDERS.put(actorType, builder); return builder; } }; } }
mikeee/dapr
tests/apps/actorjava/src/main/java/io/dapr/apps/actor/ActorConfig.java
Java
mit
1,591
/* Copyright 2021 The Dapr Authors Licensed 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 io.dapr.apps.actor; import java.time.Duration; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import io.dapr.actors.runtime.ActorRuntime; import io.dapr.apps.actor.actors.CarActorImpl; @SpringBootApplication(scanBasePackages = { "io.dapr.apps.actor", "io.dapr.springboot"}) public class Application { public static void main(String[] args) { ActorRuntime.getInstance().getConfig().setActorIdleTimeout(Duration.ofSeconds(1)); ActorRuntime.getInstance().registerActor(CarActorImpl.class); SpringApplication.run(Application.class, args); } }
mikeee/dapr
tests/apps/actorjava/src/main/java/io/dapr/apps/actor/Application.java
Java
mit
1,219
/* Copyright 2021 The Dapr Authors Licensed 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 io.dapr.apps.actor; import java.util.function.Function; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; import io.dapr.actors.ActorId; import io.dapr.actors.client.ActorProxy; import io.dapr.actors.client.ActorProxyBuilder; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import reactor.core.publisher.Mono; @RestController @Slf4j @RequiredArgsConstructor public class ApplicationController { @Autowired @Qualifier("actorProxyBuilderFunction") private final Function<String, ActorProxyBuilder<ActorProxy>> actorProxyBuilderGetter; @RequestMapping( value="/incrementAndGet/{actorType}/{actorId}", method = RequestMethod.POST, consumes = "*") @ResponseStatus(HttpStatus.OK) @ResponseBody public Mono<Integer> incrementAndGet( @PathVariable String actorType, @PathVariable String actorId) { log.info(String.format("/incrementAndGet/%s/%s", actorType, actorId)); ActorId id = new ActorId(actorId); ActorProxy proxy = this.actorProxyBuilderGetter.apply(actorType).build(id); return proxy.invokeActorMethod("IncrementAndGetAsync", 1, int.class); } @RequestMapping( value="/carFromJSON/{actorType}/{actorId}", method = RequestMethod.POST, consumes = "*") @ResponseStatus(HttpStatus.OK) @ResponseBody public Mono<Car> carFromJSON( @PathVariable String actorType, @PathVariable String actorId, @RequestBody String json) { log.info(String.format("/carFromJSON/%s/%s", actorType, actorId)); ActorId id = new ActorId(actorId); ActorProxy proxy = this.actorProxyBuilderGetter.apply(actorType).build(id); return proxy.invokeActorMethod("CarFromJSONAsync", json, Car.class); } @RequestMapping( value="/carToJSON/{actorType}/{actorId}", method = RequestMethod.POST, consumes = "*") @ResponseStatus(HttpStatus.OK) @ResponseBody public Mono<String> carToJSON( @PathVariable String actorType, @PathVariable String actorId, @RequestBody Car car) { log.info(String.format("/carToJSON/%s/%s", actorType, actorId)); ActorId id = new ActorId(actorId); ActorProxy proxy = this.actorProxyBuilderGetter.apply(actorType).build(id); return proxy.invokeActorMethod("CarToJSONAsync", car, String.class); } }
mikeee/dapr
tests/apps/actorjava/src/main/java/io/dapr/apps/actor/ApplicationController.java
Java
mit
3,901
package io.dapr.apps.actor; /* Copyright 2021 The Dapr Authors Licensed 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. */ import lombok.Data; import lombok.NoArgsConstructor; @Data @NoArgsConstructor public class Car { private String vin; private String maker; private String model; private String trim; private int modelYear; private int buildYear; byte[] photo; }
mikeee/dapr
tests/apps/actorjava/src/main/java/io/dapr/apps/actor/Car.java
Java
mit
848
/* Copyright 2021 The Dapr Authors Licensed 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 io.dapr.apps.actor.actors; import java.io.IOException; import io.dapr.actors.ActorType; import io.dapr.apps.actor.Car; /** * Example of implementation of an Actor. */ @ActorType(name = "JavaCarActor") public interface CarActor { int IncrementAndGetAsync(int delta); String CarToJSONAsync(Car car) throws IOException; Car CarFromJSONAsync(String content) throws IOException; }
mikeee/dapr
tests/apps/actorjava/src/main/java/io/dapr/apps/actor/actors/CarActor.java
Java
mit
959
/* Copyright 2021 The Dapr Authors Licensed 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 io.dapr.apps.actor.actors; import java.io.IOException; import java.util.concurrent.atomic.AtomicInteger; import com.fasterxml.jackson.databind.ObjectMapper; import io.dapr.actors.ActorId; import io.dapr.actors.runtime.AbstractActor; import io.dapr.actors.runtime.ActorRuntimeContext; import io.dapr.apps.actor.Car; public class CarActorImpl extends AbstractActor implements CarActor { private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); private final AtomicInteger counter = new AtomicInteger(); /** * This is the constructor of an actor implementation. * * @param runtimeContext The runtime context object which contains objects such * as the state provider. * @param id The id of this actor. */ public CarActorImpl(ActorRuntimeContext<?> runtimeContext, ActorId id) { super(runtimeContext, id); } @Override public int IncrementAndGetAsync(int delta) { return this.counter.addAndGet(delta); } @Override public String CarToJSONAsync(Car car) throws IOException { if (car == null) { return ""; } return OBJECT_MAPPER.writeValueAsString(car); } @Override public Car CarFromJSONAsync(String content) throws IOException { return OBJECT_MAPPER.readValue(content, Car.class); } }
mikeee/dapr
tests/apps/actorjava/src/main/java/io/dapr/apps/actor/actors/CarActorImpl.java
Java
mit
1,951
logging.level.root=INFO # Specify the instrumentation key of your Application Insights resource. #azure.application-insights.instrumentation-key=b52f9846-b1c7-40dc-84d8-9c486a676147 # Specify the name of your spring boot application. This can be any logical name you would like to give to your app. spring.application.name=ActorJava
mikeee/dapr
tests/apps/actorjava/src/main/resources/application.properties
Properties
mit
332
dist .vscode
mikeee/dapr
tests/apps/actorload/.dockerignore
Dockerfile
mit
12
dist .vscode
mikeee/dapr
tests/apps/actorload/.gitignore
Git
mit
12
FROM golang:1.22.3 WORKDIR /actorload/ COPY . . RUN make build FROM alpine:latest RUN apk --no-cache add ca-certificates WORKDIR /root/ COPY --from=0 /actorload/dist/ . CMD ["./stateactor"]
mikeee/dapr
tests/apps/actorload/Dockerfile
Dockerfile
mit
191
export GO111MODULE ?= on export GOPROXY ?= https://proxy.golang.org export GOSUMDB ?= sum.golang.org BINARIES ?= stateactor testclient OUT_DIR = ./dist .PHONY: build TEST_BINS:=$(foreach ITEM,$(BINARIES),$(OUT_DIR)/$(ITEM)) build: $(TEST_BINS) define genBinariesForTarget .PHONY: $(3)/$(1) $(3)/$(1): CGO_ENABLED=0 go build -o $(3)/$(1) $(2)/main.go; endef # Generate binary targets $(foreach ITEM,$(BINARIES),$(eval $(call genBinariesForTarget,$(ITEM),./cmd/$(ITEM),$(OUT_DIR))))
mikeee/dapr
tests/apps/actorload/Makefile
Makefile
mit
486
# Actor Load Test This includes actor test application and load test driver client. ### Build ``` make build ``` > Note: stateactor and testclient will be generated under ./dist ### Build Docker image ``` docker build -t [your registry]/actorload . ``` ### Run test locally 1. Run StateActor Service ``` % dapr run --app-id stateactor --app-port 3000 -- ./dist/stateactor -p 3000 % ./stateactor --help Usage of ./stateactor: -actors string Actor types array separated by comma. e.g. StateActor,SaveActor (default "StateActor") -p int StateActor service app port. (default 3000) ``` 2. Start load test client ``` # Target QPS: 1000 qps, Number of test actors: 200, Duration: 30 mins % dapr run --app-id testclient -- ./dist/testclient -qps 1000 -numactors 200 -t 30m % ./testclient --help Usage of ./testclient: -a string Actor Type (default "StateActor") -c int Number of parallel simultaneous connections. (default 10) -logcaller Logs filename and line number of callers to log (default true) -loglevel value loglevel, one of [Debug Verbose Info Warning Error Critical Fatal] (default Info) -logprefix string Prefix to log lines before logged messages (default "> ") -m string test actor method that will be called during test. e.g. nop, setActorState, getActorState (default "setActorState") -numactors int Number of randomly generated actors. (default 10) -qps float QPS per thread. (default 100) -s int The size of save state value. (default 1024) -t duration How long to run the test. (default 1m0s) ```
mikeee/dapr
tests/apps/actorload/README.md
Markdown
mit
1,642
/* Copyright 2021 The Dapr Authors Licensed 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 main import ( "encoding/json" "flag" "log" "os" "strings" serve "github.com/dapr/dapr/tests/apps/actorload/cmd/stateactor/service" cl "github.com/dapr/dapr/tests/apps/actorload/pkg/actor/client" httpClient "github.com/dapr/dapr/tests/apps/actorload/pkg/actor/client/http" rt "github.com/dapr/dapr/tests/apps/actorload/pkg/actor/runtime" ) const ( // actorType is Actor Type Name for test. actorType = "StateActor" // actorStateName is Actor State name. actorStateName = "state" daprAppPort = 3000 ) var ( actors = flag.String("actors", actorType, "Actor types array separated by comma. e.g. StateActor,SaveActor") appPort = flag.Int("p", daprAppPort, "StateActor service app port.") ) type stateActor struct { actorClient cl.ActorClient } func newStateActor() *stateActor { return &stateActor{ actorClient: httpClient.NewClient(), } } func (s *stateActor) setActorState(actorType, actorID string, data []byte, metadata map[string]string) ([]byte, error) { upsertReq := httpClient.TransactionalStateOperation{ Operation: "upsert", Request: httpClient.TransactionalRequest{ Key: actorStateName, Value: string(data), }, } operations := []httpClient.TransactionalStateOperation{upsertReq} serialized, err := json.Marshal(operations) if err != nil { return nil, err } if err := s.actorClient.SaveStateTransactionally(actorType, actorID, serialized); err != nil { return nil, err } return []byte(""), nil } func (s *stateActor) nopMethod(actorType, actorID string, data []byte, metadata map[string]string) ([]byte, error) { return []byte("nop"), nil } func (s *stateActor) getActorState(actorType, actorID string, data []byte, metadata map[string]string) ([]byte, error) { data, err := s.actorClient.GetState(actorType, actorID, actorStateName) if err != nil { return nil, err } return data, nil } func (s *stateActor) onActivated(actorType, actorID string) error { hostname, _ := os.Hostname() log.Printf("%s.%s, %s, %s", actorType, actorID, hostname, "Activated") return nil } func (s *stateActor) onDeactivated(actorType, actorID string) error { hostname, _ := os.Hostname() log.Printf("%s.%s, %s, %s", actorType, actorID, hostname, "Deactivated") return nil } func main() { flag.Parse() actorTypes := strings.Split(*actors, ",") service := serve.NewActorService(*appPort, &rt.DaprConfig{ Entities: actorTypes, ActorIdleTimeout: "5m", DrainOngoingCallTimeout: "10s", DrainRebalancedActors: true, }) actor := newStateActor() service.SetActivationHandler(actor.onActivated) service.SetDeactivationHandler(actor.onDeactivated) service.AddActorMethod("getActorState", actor.getActorState) service.AddActorMethod("setActorState", actor.setActorState) service.AddActorMethod("nop", actor.nopMethod) service.StartServer() }
mikeee/dapr
tests/apps/actorload/cmd/stateactor/main.go
GO
mit
3,412
/* Copyright 2021 The Dapr Authors Licensed 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 service import ( "encoding/json" "io" ) // ActorResponse is the default response body contract. type ActorResponse struct { Message string `json:"message"` } // NewActorResponse creates ActorResponse with the given message. func NewActorResponse(msg string) ActorResponse { return ActorResponse{Message: msg} } // Encode serializes ActorResponse to write buffer. func (e ActorResponse) Encode(w io.Writer) { json.NewEncoder(w).Encode(e) }
mikeee/dapr
tests/apps/actorload/cmd/stateactor/service/response.go
GO
mit
1,017
/* Copyright 2021 The Dapr Authors Licensed 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 service import ( "context" "encoding/json" "errors" "fmt" "io" "log" "net/http" "strings" "sync" cl "github.com/dapr/dapr/tests/apps/actorload/pkg/actor/client" httpClient "github.com/dapr/dapr/tests/apps/actorload/pkg/actor/client/http" rt "github.com/dapr/dapr/tests/apps/actorload/pkg/actor/runtime" "github.com/go-chi/chi/v5" ) type ActorActivationHandler func(actorType, actorID string) error type ActorInvokeFn func(actorType, actorID string, data []byte, metadata map[string]string) ([]byte, error) type ActorService struct { address string server *http.Server activeActors sync.Map actorClient cl.ActorClient config rt.DaprConfig activationHandler ActorActivationHandler deactivationHandler ActorActivationHandler invocationMap map[string]ActorInvokeFn } func NewActorService(port int, config *rt.DaprConfig) *ActorService { var daprConfig rt.DaprConfig if config == nil { daprConfig = rt.DaprConfig{ Entities: []string{}, ActorIdleTimeout: "60m", DrainOngoingCallTimeout: "10s", DrainRebalancedActors: true, } } else { daprConfig = *config } return &ActorService{ address: fmt.Sprintf("127.0.0.1:%d", port), server: nil, actorClient: httpClient.NewClient(), invocationMap: map[string]ActorInvokeFn{}, config: daprConfig, activationHandler: nil, deactivationHandler: nil, } } func (s *ActorService) setActorTypes(actorTypes []string) { s.config.Entities = actorTypes } func (s *ActorService) SetActivationHandler(handler ActorActivationHandler) { s.activationHandler = handler } func (s *ActorService) SetDeactivationHandler(handler ActorActivationHandler) { s.deactivationHandler = handler } func (s *ActorService) onConfig(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) json.NewEncoder(w).Encode(s.config) } func (s *ActorService) onHealthz(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) w.Write([]byte("")) } func (s *ActorService) router() http.Handler { r := chi.NewRouter() r.Get("/dapr/config", s.onConfig) r.Get("/healthz", s.onHealthz) r.Route("/actors/{actorType}/{actorID}", func(r chi.Router) { r.Use(actorMiddleware) r.Delete("/", func(w http.ResponseWriter, r *http.Request) { actorType := r.Context().Value("actorType").(string) actorID := r.Context().Value("actorID").(string) s.activeActors.Delete(fmt.Sprintf("%s", actorID)) if s.deactivationHandler != nil { s.deactivationHandler(actorType, actorID) } w.WriteHeader(http.StatusOK) NewActorResponse("deactivated").Encode(w) }) r.Put("/method/{method}", func(w http.ResponseWriter, r *http.Request) { method := chi.URLParam(r, "method") actorType := r.Context().Value("actorType").(string) actorID := r.Context().Value("actorID").(string) if method == "" { w.WriteHeader(http.StatusBadRequest) NewActorResponse("method is not given").Encode(w) return } if actorType == "" || actorID == "" { w.WriteHeader(http.StatusBadRequest) NewActorResponse("actorType or actorID is not given").Encode(w) return } // is this first call? then try to activate actor. _, loaded := s.activeActors.LoadOrStore(actorID, actorType) if !loaded { if s.activationHandler != nil { s.activationHandler(actorType, actorID) } } fn, ok := s.invocationMap[method] if !ok { w.WriteHeader(http.StatusNotImplemented) NewActorResponse(fmt.Sprintf("%s method is not implemented", method)).Encode(w) return } data, err := io.ReadAll(r.Body) if err != nil { w.WriteHeader(http.StatusBadRequest) NewActorResponse(err.Error()).Encode(w) return } resp, err := fn(actorType, actorID, data, map[string]string{}) if err != nil { w.WriteHeader(http.StatusInternalServerError) NewActorResponse(err.Error()).Encode(w) return } w.WriteHeader(http.StatusOK) w.Write(resp) }) }) return r } func (s *ActorService) AddActorMethod(name string, fn ActorInvokeFn) error { if _, ok := s.invocationMap[name]; ok { return errors.New("method exists") } s.invocationMap[name] = fn return nil } func (s *ActorService) StartServer() { s.server = &http.Server{ Addr: s.address, Handler: s.router(), } actorTypes := strings.Join(s.config.Entities, ", ") log.Printf("Listening to %s, Actor Types: %s", s.address, actorTypes) if err := s.server.ListenAndServe(); err != nil { log.Fatal(err) } } func actorMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { actorType := chi.URLParam(r, "actorType") actorID := chi.URLParam(r, "actorID") ctx := context.WithValue(r.Context(), "actorType", actorType) ctx = context.WithValue(ctx, "actorID", actorID) w.Header().Add("Content-Type", "application/json") next.ServeHTTP(w, r.WithContext(ctx)) }) }
mikeee/dapr
tests/apps/actorload/cmd/stateactor/service/server.go
GO
mit
5,543
/* Copyright 2021 The Dapr Authors Licensed 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 main import ( "errors" "flag" "fmt" "math/rand" "sort" "strings" "time" "fortio.org/fortio/log" "fortio.org/fortio/periodic" "fortio.org/fortio/stats" "github.com/google/uuid" actorClient "github.com/dapr/dapr/tests/apps/actorload/pkg/actor/client" httpClient "github.com/dapr/dapr/tests/apps/actorload/pkg/actor/client/http" telemetry "github.com/dapr/dapr/tests/apps/actorload/pkg/telemetry" ) const ( // defaultActorType is Actor Type Name for test. defaultActorType = "StateActor" initialStateValue = "state" ) // actorLoadTestRunnable has test execution code and test result stats. type actorLoadTestRunnable struct { periodic.RunnerResults client actorClient.ActorClient currentActorIndex int payload []byte actors []string testActorType string testActorMethod string RetCodes map[int]int64 // internal type/data sizes *stats.Histogram // exported result Sizes *stats.HistogramData aborter *periodic.Aborter telemetryClient *telemetry.TelemetryClient } // Run is the runnable function executed by one thread. // This iterates the preactivated actors to call each activated actor in a round-robin manner. func (lt *actorLoadTestRunnable) Run(t int) { log.Debugf("Calling in %d", t) size := len(lt.payload) code := 200 start := time.Now() actorID := lt.actors[lt.currentActorIndex] _, err := lt.client.InvokeMethod( lt.testActorType, actorID, lt.testActorMethod, "application/json", lt.payload) if err != nil { if actorErr, ok := err.(*httpClient.DaprActorClientError); ok { code = actorErr.Code } else { code = 500 } } log.Debugf("got, code: %3d, size: %d", code, size) elapsed := time.Since(start) lt.telemetryClient.RecordLoadRequestCount(lt.testActorType, actorID, elapsed, code) lt.RetCodes[code]++ lt.sizes.Record(float64(size)) // Invoke each actor in a round-robin manner lt.currentActorIndex = (lt.currentActorIndex + 1) % len(lt.actors) } type actorLoadTestOptions struct { periodic.RunnerOptions // Number of actors used for test NumActors int // The size of payload that test runner calls actor method with this payload WritePayloadSize int TestActorType string // actor method that will be called during the test ActorMethod string } func generatePayload(length int) []byte { chs := []byte("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") payload := make([]byte, length) for i := range payload { payload[i] = chs[rand.Intn(len(chs))] } return payload } func activateRandomActors(client actorClient.ActorClient, actorType string, maxActor int) []string { activatedActors := []string{} for i := 0; i < maxActor; i++ { actorID := strings.Replace(uuid.New().String(), "-", "", -1) log.Infof("Request to activate %s.%s actor", actorType, actorID) _, err := client.InvokeMethod( actorType, actorID, "setActorState", "application/json", []byte(initialStateValue)) if err != nil { log.Infof("failed to activate actor - %s.%s: %q", actorType, actorID, err) continue } log.Infof("Completed to activate %s.%s actor", actorType, actorID) activatedActors = append(activatedActors, actorID) } return activatedActors } func startLoadTest(opt *actorLoadTestOptions, telemetryClient *telemetry.TelemetryClient) (*actorLoadTestRunnable, error) { client := httpClient.NewClient() defer client.Close() // Wait until Dapr runtime endpoint is available. if err := client.WaitUntilDaprIsReady(); err != nil { return nil, err } // Test prep: Activate randomly generated test actors. // Each test runnable will invoke actor method by iterating generated // test actors in a round-robin manner. activatedActors := activateRandomActors(client, opt.TestActorType, opt.NumActors) activatedActorsLen := len(activatedActors) if activatedActorsLen == 0 { return nil, errors.New("no actor is activated") } log.Infof("Activated actors: %d", activatedActorsLen) // Generate randome payload by the given payload size. payload := generatePayload(opt.WritePayloadSize) log.Infof("Random payload: %s", payload) // Set up Fortio load test runner r := periodic.NewPeriodicRunner(&opt.RunnerOptions) defer r.Options().Abort() testRunnable := make([]actorLoadTestRunnable, opt.NumThreads) // Create Test runnable to store the aggregated test results from each test thread aggResult := actorLoadTestRunnable{ RetCodes: map[int]int64{}, sizes: stats.NewHistogram(0, 100), } // Set up parallel test threads. for i := 0; i < opt.NumThreads; i++ { r.Options().Runners[i] = &testRunnable[i] testRunnable[i].client = httpClient.NewClient() testRunnable[i].actors = activatedActors testRunnable[i].testActorType = opt.TestActorType testRunnable[i].testActorMethod = opt.ActorMethod testRunnable[i].telemetryClient = telemetryClient testRunnable[i].currentActorIndex = rand.Intn(activatedActorsLen) testRunnable[i].payload = payload testRunnable[i].sizes = aggResult.sizes.Clone() testRunnable[i].RetCodes = map[int]int64{} } // Start test aggResult.RunnerResults = r.Run() // Aggregate results from each test statusCodes := []int{} for i := 0; i < opt.NumThreads; i++ { testRunnable[i].client.Close() for k := range testRunnable[i].RetCodes { if _, exists := aggResult.RetCodes[k]; !exists { statusCodes = append(statusCodes, k) } aggResult.RetCodes[k] += testRunnable[i].RetCodes[k] } aggResult.sizes.Transfer(testRunnable[i].sizes) } // Stop test r.Options().ReleaseRunners() // Export test result sort.Ints(statusCodes) aggResultCount := float64(aggResult.DurationHistogram.Count) out := r.Options().Out fmt.Fprintf(out, "Jitter: %t\n", aggResult.Jitter) for _, k := range statusCodes { fmt.Fprintf(out, "Code %3d : %d (%.1f %%)\n", k, aggResult.RetCodes[k], 100.*float64(aggResult.RetCodes[k])/aggResultCount) } aggResult.Sizes = aggResult.sizes.Export() if log.LogVerbose() { aggResult.Sizes.Print(out, "Response Body/Total Sizes Histogram") } else if log.Log(log.Warning) { aggResult.sizes.Counter.Print(out, "Response Body/Total Sizes") } return &aggResult, nil } func getFlagOptions() *actorLoadTestOptions { qps := flag.Float64("qps", 100.0, "QPS per thread.") numThreads := flag.Int("c", 10, "Number of parallel simultaneous connections.") duration := flag.Duration("t", time.Minute*1, "How long to run the test.") actorType := flag.String("a", defaultActorType, "Target test actor type") numActors := flag.Int("numactors", 10, "Number of randomly generated actors.") writePayloadSize := flag.Int("s", 1024, "The size of save state value.") actorMethod := flag.String("m", "setActorState", "test actor method that will be called during test. e.g. nop, setActorState, getActorState") flag.Parse() return &actorLoadTestOptions{ RunnerOptions: periodic.RunnerOptions{ RunType: "actor", QPS: *qps, Duration: *duration, NumThreads: *numThreads, }, NumActors: *numActors, WritePayloadSize: *writePayloadSize, TestActorType: *actorType, ActorMethod: *actorMethod, } } func main() { telemetry := telemetry.NewTelemetryClient() telemetry.Init() rand.Seed(time.Now().UnixNano()) testOptions := getFlagOptions() log.Infof("Starting Dapr Actor Load Test.") log.Infof("QPS: %f, Number of Threads: %d, Number of test actors: %d", testOptions.RunnerOptions.QPS, testOptions.RunnerOptions.NumThreads, testOptions.NumActors) log.Infof("Actor type: %s", testOptions.TestActorType) log.Infof("Actor method: %s", testOptions.ActorMethod) log.Infof("Write Payload Size: %d Bytes", testOptions.WritePayloadSize) if _, err := startLoadTest(testOptions, telemetry); err != nil { log.Fatalf("Dapr Actor Load Test is failed: %q", err) } log.Infof("Dapr Actor Load Test is done") }
mikeee/dapr
tests/apps/actorload/cmd/testclient/main.go
GO
mit
8,382
apiVersion: dapr.io/v1alpha1 kind: Configuration metadata: name: testappconfig namespace: loadtest spec: tracing: samplingRate: "0"
mikeee/dapr
tests/apps/actorload/deploy/notrace.yaml
YAML
mit
141
cluster: enabled: false usePassword: false master: persistence: enabled: false affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: agentpool operator: In values: - loadgen
mikeee/dapr
tests/apps/actorload/deploy/redis-override.yml
YAML
mit
331
# # Copyright 2021 The Dapr Authors # Licensed 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. # apiVersion: dapr.io/v1alpha1 kind: Component metadata: name: statestore namespace: loadtest spec: type: state.redis version: v1 metadata: - name: redisHost value: redis-master.components.svc.cluster.local:6379 - name: redisPassword value: "" - name: actorStateStore value: "true"
mikeee/dapr
tests/apps/actorload/deploy/redis-state.yml
YAML
mit
886
# # Copyright 2021 The Dapr Authors # Licensed 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. # apiVersion: apps/v1 kind: Deployment metadata: name: stateactor namespace: loadtest labels: app: stateactor spec: replicas: 50 selector: matchLabels: app: stateactor template: metadata: labels: app: stateactor annotations: dapr.io/config: "testappconfig" dapr.io/enabled: "true" dapr.io/app-id: "stateactor" dapr.io/app-port: "3000" dapr.io/log-as-json: "true" dapr.io/log-level: "debug" spec: affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: agentpool operator: In values: - testapp containers: - name: stateactor image: youngp/actorloadtest:dev command: ["./stateactor"] args: ["-actors", "StateActor", "-p", "3000"] ports: - containerPort: 3000 imagePullPolicy: Always
mikeee/dapr
tests/apps/actorload/deploy/stateactor.yml
YAML
mit
1,601
# # Copyright 2021 The Dapr Authors # Licensed 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. # apiVersion: apps/v1 kind: Deployment metadata: name: loadtestclient namespace: loadtest labels: app: loadtestclient spec: replicas: 60 selector: matchLabels: app: loadtestclient template: metadata: labels: app: loadtestclient annotations: dapr.io/config: "testappconfig" dapr.io/enabled: "true" dapr.io/app-id: "loadtestclient" dapr.io/log-as-json: "true" dapr.io/enable-profiling: "true" spec: affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: agentpool operator: In values: - loadgen containers: - name: loadtestclient image: youngp/actorloadtest:dev command: ["./testclient"] args: ["-a", "StateActor", "-c", "10", "-numactors", "2048", "-s", "1024", "-t", "120m0s", "-m", "nop"] ports: - containerPort: 3000 imagePullPolicy: Always
mikeee/dapr
tests/apps/actorload/deploy/testclient.yml
YAML
mit
1,656
module github.com/dapr/dapr/tests/apps/actorload go 1.22.3 require ( fortio.org/fortio v1.6.8 github.com/go-chi/chi/v5 v5.0.8 github.com/google/uuid v1.2.0 go.opentelemetry.io/otel v1.7.0 go.opentelemetry.io/otel/exporters/prometheus v0.30.0 go.opentelemetry.io/otel/metric v0.30.0 go.opentelemetry.io/otel/sdk/metric v0.30.0 ) require ( github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/go-logr/logr v1.2.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/prometheus/client_golang v1.12.1 // indirect github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/common v0.32.1 // indirect github.com/prometheus/procfs v0.7.3 // indirect go.opentelemetry.io/otel/sdk v1.7.0 // indirect go.opentelemetry.io/otel/trace v1.7.0 // indirect golang.org/x/sys v0.10.0 // indirect google.golang.org/protobuf v1.26.0 // indirect )
mikeee/dapr
tests/apps/actorload/go.mod
mod
mit
1,044
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= fortio.org/fortio v1.6.8 h1:YTV+6ydEyfn+bdTAYBofWg+VsOPRS5Q6fPI0cmjsmGE= fortio.org/fortio v1.6.8/go.mod h1:sbKl3MB8+XZTZ4HvLcBPUvFYPmMKG5zKsoCmgbo/YR8= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/go-chi/chi/v5 v5.0.8 h1:lD+NLqFcAi1ovnVZpsnObHGW4xb4J8lNmoYVfECH1Y0= github.com/go-chi/chi/v5 v5.0.8/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs= github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= github.com/prometheus/client_golang v1.12.1 h1:ZiaPsmm9uiBeaSMRznKsCDNtPCS0T3JVDGF+06gjBzk= github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4= github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opentelemetry.io/otel v1.7.0 h1:Z2lA3Tdch0iDcrhJXDIlC94XE+bxok1F9B+4Lz/lGsM= go.opentelemetry.io/otel v1.7.0/go.mod h1:5BdUoMIz5WEs0vt0CUEMtSSaTSHBBVwrhnz7+nrD5xk= go.opentelemetry.io/otel/exporters/prometheus v0.30.0 h1:YXo5ZY5nofaEYMCMTTMaRH2cLDZB8+0UGuk5RwMfIo0= go.opentelemetry.io/otel/exporters/prometheus v0.30.0/go.mod h1:qN5feW+0/d661KDtJuATEmHtw5bKBK7NSvNEP927zSs= go.opentelemetry.io/otel/metric v0.30.0 h1:Hs8eQZ8aQgs0U49diZoaS6Uaxw3+bBE3lcMUKBFIk3c= go.opentelemetry.io/otel/metric v0.30.0/go.mod h1:/ShZ7+TS4dHzDFmfi1kSXMhMVubNoP0oIaBp70J6UXU= go.opentelemetry.io/otel/sdk v1.7.0 h1:4OmStpcKVOfvDOgCt7UriAPtKolwIhxpnSNI/yK+1B0= go.opentelemetry.io/otel/sdk v1.7.0/go.mod h1:uTEOTwaqIVuTGiJN7ii13Ibp75wJmYUDe374q6cZwUU= go.opentelemetry.io/otel/sdk/metric v0.30.0 h1:XTqQ4y3erR2Oj8xSAOL5ovO5011ch2ELg51z4fVkpME= go.opentelemetry.io/otel/sdk/metric v0.30.0/go.mod h1:8AKFRi5HyvTR0RRty3paN1aMC9HMT+NzcEhw/BLkLX8= go.opentelemetry.io/otel/trace v1.7.0 h1:O37Iogk1lEkMRXewVtZ1BBTVn5JEp8GrJvP92bJqC6o= go.opentelemetry.io/otel/trace v1.7.0/go.mod h1:fzLSB9nqR2eXzxPXb2JW9IKE+ScyXA48yyE4TNvoHqU= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= google.golang.org/genproto v0.0.0-20200619004808-3e7fca5c55db/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
mikeee/dapr
tests/apps/actorload/go.sum
sum
mit
49,858
/* Copyright 2021 The Dapr Authors Licensed 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 client type ActorClient interface { InvokeMethod(actorType, actorID, method string, contentType string, data []byte) ([]byte, error) SaveStateTransactionally(actorType, actorID string, data []byte) error GetState(actorType, actorID, name string) ([]byte, error) WaitUntilDaprIsReady() error Close() }
mikeee/dapr
tests/apps/actorload/pkg/actor/client/actor_client.go
GO
mit
876
/* Copyright 2021 The Dapr Authors Licensed 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 http import ( "bytes" "errors" "fmt" "io" "net/http" "os" "time" cl "github.com/dapr/dapr/tests/apps/actorload/pkg/actor/client" ) const ( apiVersion = "v1.0" defaultHTTPPort = "3500" defaultHost = "127.0.0.1" ) type DaprActorClientError struct { Code int Message string } func (e *DaprActorClientError) Error() string { return fmt.Sprintf("%d %s", e.Code, e.Message) } type httpClient struct { address string client http.Client } type TransactionalRequest struct { Key string `json:"key"` Value string `json:"value"` } type TransactionalStateOperation struct { Operation string `json:"operation"` Request TransactionalRequest `json:"request"` } func NewClient() cl.ActorClient { port := os.Getenv("DAPR_HTTP_PORT") if port == "" { port = defaultHTTPPort } return &httpClient{ address: fmt.Sprintf("http://%s:%s", defaultHost, port), client: http.Client{}, } } func (c *httpClient) defaultURL(actorType, actorID string) string { return fmt.Sprintf("%s/%s/actors/%s/%s", c.address, apiVersion, actorType, actorID) } func (c *httpClient) InvokeMethod(actorType, actorID, method string, contentType string, data []byte) ([]byte, error) { url := fmt.Sprintf("%s/method/%s", c.defaultURL(actorType, actorID), method) req, err := http.NewRequest(http.MethodPost, url, bytes.NewBuffer(data)) if err != nil { return nil, err } req.Header.Set("Content-Type", contentType) resp, err := c.client.Do(req) if err != nil { return nil, err } defer resp.Body.Close() body, err := io.ReadAll(resp.Body) if err != nil { return nil, err } if resp.StatusCode >= 300 { return nil, &DaprActorClientError{Code: resp.StatusCode, Message: string(body)} } return body, nil } func (c *httpClient) SaveStateTransactionally(actorType, actorID string, data []byte) error { url := fmt.Sprintf("%s/state", c.defaultURL(actorType, actorID)) req, err := http.NewRequest(http.MethodPost, url, bytes.NewBuffer(data)) if err != nil { return err } req.Header.Set("Content-Type", "application/json; utf-8") resp, err := c.client.Do(req) if err != nil { return err } defer resp.Body.Close() body, err := io.ReadAll(resp.Body) if err != nil { return err } if resp.StatusCode >= 300 { return &DaprActorClientError{Code: resp.StatusCode, Message: string(body)} } return nil } func (c *httpClient) GetState(actorType, actorID, name string) ([]byte, error) { url := fmt.Sprintf("%s/state/%s", c.defaultURL(actorType, actorID), name) req, err := http.NewRequest(http.MethodGet, url, nil) if err != nil { return nil, err } resp, err := c.client.Do(req) if err != nil { return nil, err } defer resp.Body.Close() body, err := io.ReadAll(resp.Body) if err != nil { return nil, err } if resp.StatusCode >= 300 { return nil, &DaprActorClientError{Code: resp.StatusCode, Message: string(body)} } return body, nil } func (c *httpClient) WaitUntilDaprIsReady() error { for i := 0; i < 10; i++ { resp, err := c.client.Get(fmt.Sprintf("%s/%s", c.address, "v1.0/healthz")) if err == nil && resp.StatusCode == 204 { return nil } time.Sleep(time.Millisecond * 500) } return errors.New("dapr is unavailable") } func (c *httpClient) Close() { c.client.CloseIdleConnections() }
mikeee/dapr
tests/apps/actorload/pkg/actor/client/http/client.go
GO
mit
3,857
/* Copyright 2021 The Dapr Authors Licensed 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 runtime // DaprConfig configures Dapr Actor configuration. type DaprConfig struct { Entities []string `json:"entities,omitempty"` ActorIdleTimeout string `json:"actorIdleTimeout,omitempty"` DrainOngoingCallTimeout string `json:"drainOngoingCallTimeout,omitempty"` DrainRebalancedActors bool `json:"drainRebalancedActors,omitempty"` }
mikeee/dapr
tests/apps/actorload/pkg/actor/runtime/config.go
GO
mit
940
/* Copyright 2021 The Dapr Authors Licensed 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 telemetry import ( "context" "fmt" "log" "net/http" "os" "time" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/exporters/prometheus" "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/metric/global" "go.opentelemetry.io/otel/metric/instrument/syncint64" controller "go.opentelemetry.io/otel/sdk/metric/controller/basic" "go.opentelemetry.io/otel/sdk/metric/export/aggregation" processor "go.opentelemetry.io/otel/sdk/metric/processor/basic" selector "go.opentelemetry.io/otel/sdk/metric/selector/simple" ) const ( metricsPort = 9988 ) // TelemetryClient is the client to record metrics of the test. type TelemetryClient struct { meter metric.Meter reqCounter syncint64.Counter reqLatency syncint64.Histogram hostname string } // NewTelemetryClient creates new telemetry client. func NewTelemetryClient() *TelemetryClient { meter := global.MeterProvider().Meter("dapr.io/actorload") reqCounter, _ := meter.SyncInt64().Counter("actorload.runner.reqcount") reqLatency, _ := meter.SyncInt64().Histogram("actorload.runner.reqlatency") hostname, _ := os.Hostname() return &TelemetryClient{ meter: meter, reqCounter: reqCounter, reqLatency: reqLatency, hostname: hostname, } } // Init initializes metrics pipeline and starts metrics http endpoint. func (t *TelemetryClient) Init() { ctl := controller.New(processor.NewFactory( selector.NewWithHistogramDistribution(), aggregation.CumulativeTemporalitySelector(), processor.WithMemory(true), )) exporter, err := prometheus.New(prometheus.Config{}, ctl) if err != nil { log.Fatalf("failed to initialize prometheus exporter %v", err) } http.HandleFunc("/metrics", exporter.ServeHTTP) go func() { _ = http.ListenAndServe(fmt.Sprintf("127.0.0.1:%d", metricsPort), nil) }() fmt.Printf("Prometheus server running on :%d", metricsPort) } // RecordLoadRequestCount records request count and latency. func (t *TelemetryClient) RecordLoadRequestCount(actorType, actorID string, elapsed time.Duration, code int) { t.reqCounter.Add( context.Background(), 1, attribute.String("hostname", t.hostname), attribute.Int("code", code), attribute.Bool("success", code == 200), attribute.String("actor", fmt.Sprintf("%s.%s", actorType, actorID)), ) t.reqLatency.Record( context.Background(), elapsed.Milliseconds(), attribute.String("hostname", t.hostname), attribute.Int("code", code), attribute.Bool("success", code == 200), attribute.String("actor", fmt.Sprintf("%s.%s", actorType, actorID)), ) }
mikeee/dapr
tests/apps/actorload/pkg/telemetry/telemetry.go
GO
mit
3,121
vendor
mikeee/dapr
tests/apps/actorphp/.gitignore
Git
mit
6
FROM php:8.0-cli COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/ RUN apt-get update && apt-get install -y wget git unzip && apt-get clean RUN install-php-extensions curl zip EXPOSE 3000 RUN mkdir -p /app WORKDIR /app COPY --from=composer:latest /usr/bin/composer /usr/bin/composer COPY composer.json /app/composer.json COPY composer.lock /app/composer.lock RUN composer install --no-dev -o -n RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" ENTRYPOINT ["php"] CMD ["-S", "0.0.0.0:3000", "-t", "/app/src"] ENV PHP_CLI_SERVER_WORKERS=50 COPY src/ src/
mikeee/dapr
tests/apps/actorphp/Dockerfile
Dockerfile
mit
612
ARG WINDOWS_VERSION=ltsc2022 FROM ghcr.io/dapr/windows-php-base:$WINDOWS_VERSION WORKDIR /inetpub ADD https://getcomposer.org/composer-stable.phar composer.phar COPY composer.json composer.json COPY composer.lock composer.lock RUN php composer.phar install --no-dev -o -n --prefer-dist WORKDIR /inetpub/wwwroot COPY src .
mikeee/dapr
tests/apps/actorphp/Dockerfile-windows
none
mit
323
{ "name": "dapr/actorphp", "description": "A simple e2e test actor", "type": "project", "license": "MIT", "authors": [ { "name": "Rob Landers", "email": "landers.robert@gmail.com" } ], "minimum-stability": "dev", "require": { "dapr/php-sdk": "1.*" }, "autoload": { "psr-4": { "Test\\": "src" } }, "scripts": { "start-env": [ "docker build -t php-sdk-test .", "docker run --rm --name=phpsdktest -v $(pwd):/app -p 3000:3000 php-sdk-test" ] } }
mikeee/dapr
tests/apps/actorphp/composer.json
JSON
mit
610
{ "_readme": [ "This file locks the dependencies of your project to a known state", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], "content-hash": "e0045cb2b9b6963d12b1bfb645b3081f", "packages": [ { "name": "dapr/php-sdk", "version": "v1.0.0-rc.4", "source": { "type": "git", "url": "https://github.com/dapr/php-sdk.git", "reference": "8d7d78713b9cfdee938d1a9566ef4ed9ca35416d" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/dapr/php-sdk/zipball/8d7d78713b9cfdee938d1a9566ef4ed9ca35416d", "reference": "8d7d78713b9cfdee938d1a9566ef4ed9ca35416d", "shasum": "" }, "require": { "ext-curl": "*", "ext-json": "*", "ext-mbstring": "*", "laminas/laminas-httphandlerrunner": "^1.3", "monolog/monolog": "^2.2", "nette/php-generator": "^3.5", "nikic/fast-route": "^1.3", "nyholm/psr7": "^1.3", "nyholm/psr7-server": "^1.0", "php": "^8.0", "php-di/invoker": "^2.3", "php-di/php-di": "^6.3", "psr/log": "^1.1" }, "require-dev": { "ext-xdebug": "*", "phpunit/phpunit": "^9", "vimeo/psalm": "^4.3" }, "type": "library", "autoload": { "psr-4": { "Dapr\\": "src/lib", "Dapr\\TestActors\\": "test/actors" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "Rob Landers", "email": "landers.robert@gmail.com" } ], "description": "Dapr Implementation in PHP", "support": { "issues": "https://github.com/dapr/php-sdk/issues", "source": "https://github.com/dapr/php-sdk/tree/v1.0.0-rc.4" }, "time": "2021-02-12T12:13:32+00:00" }, { "name": "laminas/laminas-httphandlerrunner", "version": "1.4.x-dev", "source": { "type": "git", "url": "https://github.com/laminas/laminas-httphandlerrunner.git", "reference": "eeee0dcc7b2fb2114772f77519d8bc67c9d4db4b" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/laminas/laminas-httphandlerrunner/zipball/eeee0dcc7b2fb2114772f77519d8bc67c9d4db4b", "reference": "eeee0dcc7b2fb2114772f77519d8bc67c9d4db4b", "shasum": "" }, "require": { "laminas/laminas-zendframework-bridge": "^1.0", "php": "^7.3 || ~8.0.0", "psr/http-message": "^1.0", "psr/http-message-implementation": "^1.0", "psr/http-server-handler": "^1.0" }, "replace": { "zendframework/zend-httphandlerrunner": "^1.1.0" }, "require-dev": { "laminas/laminas-coding-standard": "~1.0.0", "laminas/laminas-diactoros": "^2.1.1", "phpunit/phpunit": "^9.3" }, "default-branch": true, "type": "library", "extra": { "laminas": { "config-provider": "Laminas\\HttpHandlerRunner\\ConfigProvider" } }, "autoload": { "psr-4": { "Laminas\\HttpHandlerRunner\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], "description": "Execute PSR-15 RequestHandlerInterface instances and emit responses they generate.", "homepage": "https://laminas.dev", "keywords": [ "components", "laminas", "mezzio", "psr-15", "psr-7" ], "support": { "chat": "https://laminas.dev/chat", "docs": "https://docs.laminas.dev/laminas-httphandlerrunner/", "forum": "https://discourse.laminas.dev", "issues": "https://github.com/laminas/laminas-httphandlerrunner/issues", "rss": "https://github.com/laminas/laminas-httphandlerrunner/releases.atom", "source": "https://github.com/laminas/laminas-httphandlerrunner" }, "funding": [ { "url": "https://funding.communitybridge.org/projects/laminas-project", "type": "community_bridge" } ], "time": "2020-11-19T17:13:12+00:00" }, { "name": "laminas/laminas-zendframework-bridge", "version": "1.2.x-dev", "source": { "type": "git", "url": "https://github.com/laminas/laminas-zendframework-bridge.git", "reference": "466d07d5a476e974c17fc327c807ce3b7e2ce4cb" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/laminas/laminas-zendframework-bridge/zipball/466d07d5a476e974c17fc327c807ce3b7e2ce4cb", "reference": "466d07d5a476e974c17fc327c807ce3b7e2ce4cb", "shasum": "" }, "require": { "php": "^5.6 || ^7.0 || ^8.0" }, "require-dev": { "phpunit/phpunit": "^5.7 || ^6.5 || ^7.5 || ^8.1 || ^9.3", "squizlabs/php_codesniffer": "^3.5" }, "default-branch": true, "type": "library", "extra": { "laminas": { "module": "Laminas\\ZendFrameworkBridge" } }, "autoload": { "files": [ "src/autoload.php" ], "psr-4": { "Laminas\\ZendFrameworkBridge\\": "src//" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], "description": "Alias legacy ZF class names to Laminas Project equivalents.", "keywords": [ "ZendFramework", "autoloading", "laminas", "zf" ], "support": { "forum": "https://discourse.laminas.dev/", "issues": "https://github.com/laminas/laminas-zendframework-bridge/issues", "rss": "https://github.com/laminas/laminas-zendframework-bridge/releases.atom", "source": "https://github.com/laminas/laminas-zendframework-bridge" }, "funding": [ { "url": "https://funding.communitybridge.org/projects/laminas-project", "type": "community_bridge" } ], "time": "2020-09-14T14:29:05+00:00" }, { "name": "monolog/monolog", "version": "dev-main", "source": { "type": "git", "url": "https://github.com/Seldaek/monolog.git", "reference": "c1971982c3b792e488726468046b1ef977934c6a" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/Seldaek/monolog/zipball/c1971982c3b792e488726468046b1ef977934c6a", "reference": "c1971982c3b792e488726468046b1ef977934c6a", "shasum": "" }, "require": { "php": ">=7.2", "psr/log": "^1.0.1" }, "provide": { "psr/log-implementation": "1.0.0" }, "require-dev": { "aws/aws-sdk-php": "^2.4.9 || ^3.0", "doctrine/couchdb": "~1.0@dev", "elasticsearch/elasticsearch": "^7", "graylog2/gelf-php": "^1.4.2", "mongodb/mongodb": "^1.8", "php-amqplib/php-amqplib": "~2.4", "php-console/php-console": "^3.1.3", "phpspec/prophecy": "^1.6.1", "phpstan/phpstan": "^0.12.59", "phpunit/phpunit": "^8.5", "predis/predis": "^1.1", "rollbar/rollbar": "^1.3", "ruflin/elastica": ">=0.90 <7.0.1", "swiftmailer/swiftmailer": "^5.3|^6.0" }, "suggest": { "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB", "doctrine/couchdb": "Allow sending log messages to a CouchDB server", "elasticsearch/elasticsearch": "Allow sending log messages to an Elasticsearch server via official client", "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)", "ext-mbstring": "Allow to work properly with unicode symbols", "ext-mongodb": "Allow sending log messages to a MongoDB server (via driver)", "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server", "mongodb/mongodb": "Allow sending log messages to a MongoDB server (via library)", "php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib", "php-console/php-console": "Allow sending log messages to Google Chrome", "rollbar/rollbar": "Allow sending log messages to Rollbar", "ruflin/elastica": "Allow sending log messages to an Elastic Search server" }, "default-branch": true, "type": "library", "extra": { "branch-alias": { "dev-main": "2.x-dev" } }, "autoload": { "psr-4": { "Monolog\\": "src/Monolog" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "Jordi Boggiano", "email": "j.boggiano@seld.be", "homepage": "https://seld.be" } ], "description": "Sends your logs to files, sockets, inboxes, databases and various web services", "homepage": "https://github.com/Seldaek/monolog", "keywords": [ "log", "logging", "psr-3" ], "support": { "issues": "https://github.com/Seldaek/monolog/issues", "source": "https://github.com/Seldaek/monolog/tree/main" }, "funding": [ { "url": "https://github.com/Seldaek", "type": "github" }, { "url": "https://tidelift.com/funding/github/packagist/monolog/monolog", "type": "tidelift" } ], "time": "2021-02-09T13:27:42+00:00" }, { "name": "nette/php-generator", "version": "dev-master", "source": { "type": "git", "url": "https://github.com/nette/php-generator.git", "reference": "f662444430fa6933eb3e753167f8d66dd695829f" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/nette/php-generator/zipball/f662444430fa6933eb3e753167f8d66dd695829f", "reference": "f662444430fa6933eb3e753167f8d66dd695829f", "shasum": "" }, "require": { "nette/utils": "^3.1.2", "php": ">=7.1" }, "require-dev": { "nette/tester": "^2.0", "nikic/php-parser": "^4.4", "phpstan/phpstan": "^0.12", "tracy/tracy": "^2.3" }, "suggest": { "nikic/php-parser": "to use ClassType::withBodiesFrom() & GlobalFunction::withBodyFrom()" }, "default-branch": true, "type": "library", "extra": { "branch-alias": { "dev-master": "3.5-dev" } }, "autoload": { "classmap": [ "src/" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause", "GPL-2.0-only", "GPL-3.0-only" ], "authors": [ { "name": "David Grudl", "homepage": "https://davidgrudl.com" }, { "name": "Nette Community", "homepage": "https://nette.org/contributors" } ], "description": "🐘 Nette PHP Generator: generates neat PHP code for you. Supports new PHP 7.4 features.", "homepage": "https://nette.org", "keywords": [ "code", "nette", "php", "scaffolding" ], "support": { "issues": "https://github.com/nette/php-generator/issues", "source": "https://github.com/nette/php-generator/tree/master" }, "time": "2021-02-08T08:34:42+00:00" }, { "name": "nette/utils", "version": "dev-master", "source": { "type": "git", "url": "https://github.com/nette/utils.git", "reference": "dc14007cff180d237c517cdf188fb69d3083ded9" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/nette/utils/zipball/dc14007cff180d237c517cdf188fb69d3083ded9", "reference": "dc14007cff180d237c517cdf188fb69d3083ded9", "shasum": "" }, "require": { "php": ">=7.2 <8.1" }, "conflict": { "nette/di": "<3.0.6" }, "require-dev": { "nette/tester": "~2.0", "phpstan/phpstan": "^0.12", "tracy/tracy": "^2.3" }, "suggest": { "ext-gd": "to use Image", "ext-iconv": "to use Strings::webalize(), toAscii(), chr() and reverse()", "ext-intl": "to use Strings::webalize(), toAscii(), normalize() and compare()", "ext-json": "to use Nette\\Utils\\Json", "ext-mbstring": "to use Strings::lower() etc...", "ext-tokenizer": "to use Nette\\Utils\\Reflection::getUseStatements()", "ext-xml": "to use Strings::length() etc. when mbstring is not available" }, "default-branch": true, "type": "library", "extra": { "branch-alias": { "dev-master": "3.2-dev" } }, "autoload": { "classmap": [ "src/" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause", "GPL-2.0-only", "GPL-3.0-only" ], "authors": [ { "name": "David Grudl", "homepage": "https://davidgrudl.com" }, { "name": "Nette Community", "homepage": "https://nette.org/contributors" } ], "description": "🛠 Nette Utils: lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.", "homepage": "https://nette.org", "keywords": [ "array", "core", "datetime", "images", "json", "nette", "paginator", "password", "slugify", "string", "unicode", "utf-8", "utility", "validation" ], "support": { "issues": "https://github.com/nette/utils/issues", "source": "https://github.com/nette/utils/tree/master" }, "time": "2021-02-07T23:53:15+00:00" }, { "name": "nikic/fast-route", "version": "v1.x-dev", "source": { "type": "git", "url": "https://github.com/nikic/FastRoute.git", "reference": "4012884e0b916e1bd895a5061d4abc3c99e283a4" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/nikic/FastRoute/zipball/4012884e0b916e1bd895a5061d4abc3c99e283a4", "reference": "4012884e0b916e1bd895a5061d4abc3c99e283a4", "shasum": "" }, "require": { "php": ">=5.4.0" }, "require-dev": { "phpunit/phpunit": "^4.8.35|~5.7" }, "type": "library", "autoload": { "psr-4": { "FastRoute\\": "src/" }, "files": [ "src/functions.php" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], "authors": [ { "name": "Nikita Popov", "email": "nikic@php.net" } ], "description": "Fast request router for PHP", "keywords": [ "router", "routing" ], "support": { "issues": "https://github.com/nikic/FastRoute/issues", "source": "https://github.com/nikic/FastRoute/tree/v1.x" }, "time": "2019-12-20T12:15:33+00:00" }, { "name": "nyholm/psr7", "version": "dev-master", "source": { "type": "git", "url": "https://github.com/Nyholm/psr7.git", "reference": "a36fb363bc9f478733bb98e0d42f91a68ad9a274" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/Nyholm/psr7/zipball/a36fb363bc9f478733bb98e0d42f91a68ad9a274", "reference": "a36fb363bc9f478733bb98e0d42f91a68ad9a274", "shasum": "" }, "require": { "php": ">=7.1", "php-http/message-factory": "^1.0", "psr/http-factory": "^1.0", "psr/http-message": "^1.0" }, "provide": { "psr/http-factory-implementation": "1.0", "psr/http-message-implementation": "1.0" }, "require-dev": { "http-interop/http-factory-tests": "^0.8", "php-http/psr7-integration-tests": "^1.0", "phpunit/phpunit": "^7.5 || 8.5 || 9.4", "symfony/error-handler": "^4.4" }, "default-branch": true, "type": "library", "extra": { "branch-alias": { "dev-master": "1.4-dev" } }, "autoload": { "psr-4": { "Nyholm\\Psr7\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "Tobias Nyholm", "email": "tobias.nyholm@gmail.com" }, { "name": "Martijn van der Ven", "email": "martijn@vanderven.se" } ], "description": "A fast PHP7 implementation of PSR-7", "homepage": "https://tnyholm.se", "keywords": [ "psr-17", "psr-7" ], "support": { "issues": "https://github.com/Nyholm/psr7/issues", "source": "https://github.com/Nyholm/psr7/tree/master" }, "funding": [ { "url": "https://github.com/Zegnat", "type": "github" }, { "url": "https://github.com/nyholm", "type": "github" } ], "time": "2021-02-10T11:06:11+00:00" }, { "name": "nyholm/psr7-server", "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/Nyholm/psr7-server.git", "reference": "5c134aeb5dd6521c7978798663470dabf0528c96" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/Nyholm/psr7-server/zipball/5c134aeb5dd6521c7978798663470dabf0528c96", "reference": "5c134aeb5dd6521c7978798663470dabf0528c96", "shasum": "" }, "require": { "php": "^7.1 || ^8.0", "psr/http-factory": "^1.0", "psr/http-message": "^1.0" }, "require-dev": { "nyholm/nsa": "^1.1", "nyholm/psr7": "^1.3", "phpunit/phpunit": "^7.0 || ^8.5 || ^9.3" }, "type": "library", "autoload": { "psr-4": { "Nyholm\\Psr7Server\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "Tobias Nyholm", "email": "tobias.nyholm@gmail.com" }, { "name": "Martijn van der Ven", "email": "martijn@vanderven.se" } ], "description": "Helper classes to handle PSR-7 server requests", "homepage": "http://tnyholm.se", "keywords": [ "psr-17", "psr-7" ], "support": { "issues": "https://github.com/Nyholm/psr7-server/issues", "source": "https://github.com/Nyholm/psr7-server/tree/1.0.1" }, "funding": [ { "url": "https://github.com/Zegnat", "type": "github" }, { "url": "https://github.com/nyholm", "type": "github" } ], "time": "2020-11-15T15:26:20+00:00" }, { "name": "opis/closure", "version": "dev-master", "source": { "type": "git", "url": "https://github.com/opis/closure.git", "reference": "06b4961aabf900c72a20b7000bfa10fd7ae3035e" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/opis/closure/zipball/06b4961aabf900c72a20b7000bfa10fd7ae3035e", "reference": "06b4961aabf900c72a20b7000bfa10fd7ae3035e", "shasum": "" }, "require": { "php": "^5.4 || ^7.0 || ^8.0" }, "require-dev": { "jeremeamia/superclosure": "^2.0", "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0" }, "default-branch": true, "type": "library", "extra": { "branch-alias": { "dev-master": "3.6.x-dev" } }, "autoload": { "psr-4": { "Opis\\Closure\\": "src/" }, "files": [ "functions.php" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "Marius Sarca", "email": "marius.sarca@gmail.com" }, { "name": "Sorin Sarca", "email": "sarca_sorin@hotmail.com" } ], "description": "A library that can be used to serialize closures (anonymous functions) and arbitrary objects.", "homepage": "https://opis.io/closure", "keywords": [ "anonymous functions", "closure", "function", "serializable", "serialization", "serialize" ], "support": { "issues": "https://github.com/opis/closure/issues", "source": "https://github.com/opis/closure/tree/master" }, "time": "2020-12-05T19:20:15+00:00" }, { "name": "php-di/invoker", "version": "2.3.0", "source": { "type": "git", "url": "https://github.com/PHP-DI/Invoker.git", "reference": "992fec6c56f2d1ad1ad5fee28267867c85bfb8f9" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/PHP-DI/Invoker/zipball/992fec6c56f2d1ad1ad5fee28267867c85bfb8f9", "reference": "992fec6c56f2d1ad1ad5fee28267867c85bfb8f9", "shasum": "" }, "require": { "php": ">=7.3", "psr/container": "~1.0" }, "require-dev": { "athletic/athletic": "~0.1.8", "mnapoli/hard-mode": "~0.3.0", "phpunit/phpunit": "^9.0" }, "type": "library", "autoload": { "psr-4": { "Invoker\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "description": "Generic and extensible callable invoker", "homepage": "https://github.com/PHP-DI/Invoker", "keywords": [ "callable", "dependency", "dependency-injection", "injection", "invoke", "invoker" ], "support": { "issues": "https://github.com/PHP-DI/Invoker/issues", "source": "https://github.com/PHP-DI/Invoker/tree/2.3.0" }, "funding": [ { "url": "https://github.com/mnapoli", "type": "github" } ], "time": "2021-01-15T10:25:40+00:00" }, { "name": "php-di/php-di", "version": "6.3.0", "source": { "type": "git", "url": "https://github.com/PHP-DI/PHP-DI.git", "reference": "955cacea6b0beaba07e8c11b8367f5b3d5abe89f" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/PHP-DI/PHP-DI/zipball/955cacea6b0beaba07e8c11b8367f5b3d5abe89f", "reference": "955cacea6b0beaba07e8c11b8367f5b3d5abe89f", "shasum": "" }, "require": { "opis/closure": "^3.5.5", "php": ">=7.2.0", "php-di/invoker": "^2.0", "php-di/phpdoc-reader": "^2.0.1", "psr/container": "^1.0" }, "provide": { "psr/container-implementation": "^1.0" }, "require-dev": { "doctrine/annotations": "~1.2", "friendsofphp/php-cs-fixer": "^2.4", "mnapoli/phpunit-easymock": "^1.2", "ocramius/proxy-manager": "~2.0.2", "phpstan/phpstan": "^0.12", "phpunit/phpunit": "^8.5|^9.0" }, "suggest": { "doctrine/annotations": "Install it if you want to use annotations (version ~1.2)", "ocramius/proxy-manager": "Install it if you want to use lazy injection (version ~2.0)" }, "type": "library", "autoload": { "psr-4": { "DI\\": "src/" }, "files": [ "src/functions.php" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "description": "The dependency injection container for humans", "homepage": "https://php-di.org/", "keywords": [ "PSR-11", "container", "container-interop", "dependency injection", "di", "ioc", "psr11" ], "support": { "issues": "https://github.com/PHP-DI/PHP-DI/issues", "source": "https://github.com/PHP-DI/PHP-DI/tree/6.3.0" }, "funding": [ { "url": "https://github.com/mnapoli", "type": "github" }, { "url": "https://tidelift.com/funding/github/packagist/php-di/php-di", "type": "tidelift" } ], "time": "2020-10-12T14:39:15+00:00" }, { "name": "php-di/phpdoc-reader", "version": "2.2.1", "source": { "type": "git", "url": "https://github.com/PHP-DI/PhpDocReader.git", "reference": "66daff34cbd2627740ffec9469ffbac9f8c8185c" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/PHP-DI/PhpDocReader/zipball/66daff34cbd2627740ffec9469ffbac9f8c8185c", "reference": "66daff34cbd2627740ffec9469ffbac9f8c8185c", "shasum": "" }, "require": { "php": ">=7.2.0" }, "require-dev": { "mnapoli/hard-mode": "~0.3.0", "phpunit/phpunit": "^8.5|^9.0" }, "type": "library", "autoload": { "psr-4": { "PhpDocReader\\": "src/PhpDocReader" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "description": "PhpDocReader parses @var and @param values in PHP docblocks (supports namespaced class names with the same resolution rules as PHP)", "keywords": [ "phpdoc", "reflection" ], "support": { "issues": "https://github.com/PHP-DI/PhpDocReader/issues", "source": "https://github.com/PHP-DI/PhpDocReader/tree/2.2.1" }, "time": "2020-10-12T12:39:22+00:00" }, { "name": "php-http/message-factory", "version": "dev-master", "source": { "type": "git", "url": "https://github.com/php-http/message-factory.git", "reference": "597f30e6dfd32a85fd7dbe58cb47554b5bad910e" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/php-http/message-factory/zipball/597f30e6dfd32a85fd7dbe58cb47554b5bad910e", "reference": "597f30e6dfd32a85fd7dbe58cb47554b5bad910e", "shasum": "" }, "require": { "php": ">=5.4", "psr/http-message": "^1.0" }, "default-branch": true, "type": "library", "extra": { "branch-alias": { "dev-master": "1.0-dev" } }, "autoload": { "psr-4": { "Http\\Message\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "Márk Sági-Kazár", "email": "mark.sagikazar@gmail.com" } ], "description": "Factory interfaces for PSR-7 HTTP Message", "homepage": "http://php-http.org", "keywords": [ "factory", "http", "message", "stream", "uri" ], "support": { "issues": "https://github.com/php-http/message-factory/issues", "source": "https://github.com/php-http/message-factory/tree/master" }, "time": "2018-12-06T18:41:41+00:00" }, { "name": "psr/container", "version": "dev-master", "source": { "type": "git", "url": "https://github.com/php-fig/container.git", "reference": "381524e8568e07f31d504a945b88556548c8c42e" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/php-fig/container/zipball/381524e8568e07f31d504a945b88556548c8c42e", "reference": "381524e8568e07f31d504a945b88556548c8c42e", "shasum": "" }, "require": { "php": ">=7.2.0" }, "default-branch": true, "type": "library", "extra": { "branch-alias": { "dev-master": "1.1.x-dev" } }, "autoload": { "psr-4": { "Psr\\Container\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "PHP-FIG", "homepage": "https://www.php-fig.org/" } ], "description": "Common Container Interface (PHP FIG PSR-11)", "homepage": "https://github.com/php-fig/container", "keywords": [ "PSR-11", "container", "container-interface", "container-interop", "psr" ], "support": { "issues": "https://github.com/php-fig/container/issues", "source": "https://github.com/php-fig/container/tree/master" }, "time": "2020-10-13T07:07:53+00:00" }, { "name": "psr/http-factory", "version": "dev-master", "source": { "type": "git", "url": "https://github.com/php-fig/http-factory.git", "reference": "36fa03d50ff82abcae81860bdaf4ed9a1510c7cd" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/php-fig/http-factory/zipball/36fa03d50ff82abcae81860bdaf4ed9a1510c7cd", "reference": "36fa03d50ff82abcae81860bdaf4ed9a1510c7cd", "shasum": "" }, "require": { "php": ">=7.0.0", "psr/http-message": "^1.0" }, "default-branch": true, "type": "library", "extra": { "branch-alias": { "dev-master": "1.0.x-dev" } }, "autoload": { "psr-4": { "Psr\\Http\\Message\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "PHP-FIG", "homepage": "https://www.php-fig.org/" } ], "description": "Common interfaces for PSR-7 HTTP message factories", "keywords": [ "factory", "http", "message", "psr", "psr-17", "psr-7", "request", "response" ], "support": { "source": "https://github.com/php-fig/http-factory/tree/master" }, "time": "2020-09-17T16:52:55+00:00" }, { "name": "psr/http-message", "version": "dev-master", "source": { "type": "git", "url": "https://github.com/php-fig/http-message.git", "reference": "efd67d1dc14a7ef4fc4e518e7dee91c271d524e4" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/php-fig/http-message/zipball/efd67d1dc14a7ef4fc4e518e7dee91c271d524e4", "reference": "efd67d1dc14a7ef4fc4e518e7dee91c271d524e4", "shasum": "" }, "require": { "php": ">=5.3.0" }, "default-branch": true, "type": "library", "extra": { "branch-alias": { "dev-master": "1.0.x-dev" } }, "autoload": { "psr-4": { "Psr\\Http\\Message\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "PHP-FIG", "homepage": "http://www.php-fig.org/" } ], "description": "Common interface for HTTP messages", "homepage": "https://github.com/php-fig/http-message", "keywords": [ "http", "http-message", "psr", "psr-7", "request", "response" ], "support": { "source": "https://github.com/php-fig/http-message/tree/master" }, "time": "2019-08-29T13:16:46+00:00" }, { "name": "psr/http-server-handler", "version": "dev-master", "source": { "type": "git", "url": "https://github.com/php-fig/http-server-handler.git", "reference": "cada5cd1c6a9871031e07f26d0f7b08c9de19039" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/php-fig/http-server-handler/zipball/cada5cd1c6a9871031e07f26d0f7b08c9de19039", "reference": "cada5cd1c6a9871031e07f26d0f7b08c9de19039", "shasum": "" }, "require": { "php": ">=7.0", "psr/http-message": "^1.0" }, "default-branch": true, "type": "library", "extra": { "branch-alias": { "dev-master": "1.0.x-dev" } }, "autoload": { "psr-4": { "Psr\\Http\\Server\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "PHP-FIG", "homepage": "https://www.php-fig.org/" } ], "description": "Common interface for HTTP server-side request handler", "keywords": [ "handler", "http", "http-interop", "psr", "psr-15", "psr-7", "request", "response", "server" ], "support": { "source": "https://github.com/php-fig/http-server-handler/tree/master" }, "time": "2020-09-17T16:52:43+00:00" }, { "name": "psr/log", "version": "dev-master", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", "reference": "dd738d0b4491f32725492cf345f6b501f5922fec" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/php-fig/log/zipball/dd738d0b4491f32725492cf345f6b501f5922fec", "reference": "dd738d0b4491f32725492cf345f6b501f5922fec", "shasum": "" }, "require": { "php": ">=5.3.0" }, "default-branch": true, "type": "library", "extra": { "branch-alias": { "dev-master": "1.1.x-dev" } }, "autoload": { "psr-4": { "Psr\\Log\\": "Psr/Log/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "PHP-FIG", "homepage": "https://www.php-fig.org/" } ], "description": "Common interface for logging libraries", "homepage": "https://github.com/php-fig/log", "keywords": [ "log", "psr", "psr-3" ], "support": { "source": "https://github.com/php-fig/log/tree/master" }, "time": "2020-09-18T06:44:51+00:00" } ], "packages-dev": [], "aliases": [], "minimum-stability": "dev", "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": [], "platform-dev": [], "plugin-api-version": "2.0.0" }
mikeee/dapr
tests/apps/actorphp/composer.lock
lock
mit
44,297
<?php namespace Test; class Car { public string $vin; public string $maker; public string $model; public string $trim; public int $modelYear; public int $buildYear; public string $photo; }
mikeee/dapr
tests/apps/actorphp/src/Car.php
PHP
mit
219
<?php namespace Test; use Dapr\Actors\Actor; use Dapr\Actors\Attributes\DaprType; use Dapr\Deserialization\IDeserializer; use Dapr\Serialization\ISerializer; use Dapr\Serialization\Serializer; #[DaprType('PHPCarActor')] class CarActor extends Actor implements ICarActor { private int $count = 0; public function __construct( public string $id, protected ISerializer $serializer, protected IDeserializer $deserializer ) { parent::__construct($id); } public function IncrementAndGetAsync(int|null $delta): int { $this->count += $delta; return $this->count; } public function CarFromJSONAsync(string $content): Car { return $this->deserializer->from_json(Car::class, $content); } public function CarToJSONAsync(Car $car): string { return $this->serializer->as_json($car); } }
mikeee/dapr
tests/apps/actorphp/src/CarActor.php
PHP
mit
898
<?php namespace Test; use Dapr\Actors\Attributes\DaprType; #[DaprType('PHPCarActor')] interface ICarActor { public function IncrementAndGetAsync(int $delta): int; public function CarToJSONAsync(Car $car): string; public function CarFromJSONAsync(string $content): Car; }
mikeee/dapr
tests/apps/actorphp/src/ICarActor.php
PHP
mit
288
<?php use Dapr\Actors\ActorProxy; use Dapr\App; use Dapr\Attributes\FromBody; use DI\ContainerBuilder; use Test\Car; use Test\CarActor; use Test\ICarActor; require_once __DIR__.'/../vendor/autoload.php'; $app = App::create( configure: fn(ContainerBuilder $builder) => $builder->addDefinitions(['dapr.log.level' => \Psr\Log\LogLevel::DEBUG, 'dapr.actors' => fn() => [CarActor::class]]) ); $app->post( '/incrementAndGet/{actor_name}/{id}', fn(string $actor_name, string $id, ActorProxy $actorProxy) => $actorProxy->get( ICarActor::class, $id, $actor_name )->IncrementAndGetAsync(1) ); $app->post( '/carFromJSON/{actor_name}/{id}', fn(string $actor_name, string $id, ActorProxy $actorProxy, #[FromBody] array $json) => $actorProxy->get( ICarActor::class, $id, $actor_name )->CarFromJSONAsync(json_encode($json)) ); $app->post( '/carToJSON/{actor_name}/{id}', fn(string $actor_name, string $id, #[FromBody] Car $car, ActorProxy $actorProxy) => json_decode( $actorProxy->get( ICarActor::class, $id, $actor_name )->CarToJSONAsync($car) ) ); $app->start();
mikeee/dapr
tests/apps/actorphp/src/index.php
PHP
mit
1,195
__pycache__/
mikeee/dapr
tests/apps/actorpython/.gitignore
Git
mit
13
# # Copyright 2021 The Dapr Authors # Licensed 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. # FROM python:3.9-slim-buster WORKDIR /app COPY . . RUN pip install -r requirements.txt EXPOSE 3000 ENTRYPOINT ["python"] CMD ["flask_service.py"]
mikeee/dapr
tests/apps/actorpython/Dockerfile
Dockerfile
mit
728
ARG WINDOWS_VERSION=ltsc2022 FROM ghcr.io/dapr/windows-python-base:$WINDOWS_VERSION WORKDIR /app ADD . /app RUN pip install -r requirements.txt EXPOSE 3000 ENTRYPOINT ["python"] CMD ["flask_service.py"]
mikeee/dapr
tests/apps/actorpython/Dockerfile-windows
none
mit
205
# -*- coding: utf-8 -*- # # Copyright 2021 The Dapr Authors # Licensed 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. # import json from dapr.actor import Actor from car_actor_interface import CarActorInterface class PythonCarActor(Actor, CarActorInterface): def __init__(self, ctx, actor_id): super(PythonCarActor, self).__init__(ctx, actor_id) self._counter = 0 async def increment_and_get(self, delta) -> int: self._counter = self._counter + delta return self._counter async def car_from_json(self, json_content) -> object: return json.loads(json_content) async def car_to_json(self, car) -> str: return json.dumps(car)
mikeee/dapr
tests/apps/actorpython/car_actor.py
Python
mit
1,177
# -*- coding: utf-8 -*- # # Copyright 2021 The Dapr Authors # Licensed 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. # from dapr.actor import ActorInterface, actormethod class CarActorInterface(ActorInterface): @actormethod(name="IncrementAndGetAsync") async def increment_and_get(self, delta: int) -> int: ... @actormethod(name="CarFromJSONAsync") async def car_from_json(self, json_content: str) -> object: ... @actormethod(name="CarToJSONAsync") async def car_to_json(self, car: object) -> str: ...
mikeee/dapr
tests/apps/actorpython/car_actor_interface.py
Python
mit
1,038
# -*- coding: utf-8 -*- # # Copyright 2021 The Dapr Authors # Licensed 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. # import asyncio from flask import Flask, jsonify, request from flask_dapr.actor import DaprActor from dapr.conf import settings from dapr.actor import ActorProxy, ActorId from car_actor_interface import CarActorInterface from car_actor import PythonCarActor app = Flask(f'{PythonCarActor.__name__}Service') # Enable DaprActor Flask extension actor = DaprActor(app) # Register DemoActor actor.register_actor(PythonCarActor) @app.route('/incrementAndGet/<actorType>/<actorId>', methods=['POST']) def increment_and_get(actorType: str, actorId: str): print('/incrementAndGet/{0}/{1}'.format(actorType, actorId), flush=True) proxy = ActorProxy.create(actorType, ActorId(actorId), CarActorInterface) result = asyncio.run(proxy.IncrementAndGetAsync(1)) return jsonify(result), 200 @app.route('/carFromJSON/<actorType>/<actorId>', methods=['POST']) def car_from_json(actorType: str, actorId: str): print('/carFromJSON/{0}/{1}'.format(actorType, actorId), flush=True) proxy = ActorProxy.create(actorType, ActorId(actorId), CarActorInterface) body = request.get_data().decode('utf-8') result = asyncio.run(proxy.CarFromJSONAsync(body)) return jsonify(result), 200 @app.route('/carToJSON/<actorType>/<actorId>', methods=['POST']) def car_to_json(actorType: str, actorId: str): print('/carToJSON/{0}/{1}'.format(actorType, actorId), flush=True) proxy = ActorProxy.create(actorType, ActorId(actorId), CarActorInterface) car = request.get_json() result = asyncio.run(proxy.CarToJSONAsync(car)) return result, 200 if __name__ == '__main__': app.run(host='0.0.0.0', port=settings.HTTP_APP_PORT)
mikeee/dapr
tests/apps/actorpython/flask_service.py
Python
mit
2,249
flask-dapr>=1.9.0 typing-extensions
mikeee/dapr
tests/apps/actorpython/requirements.txt
Text
mit
35
../utils/*.go ../../../pkg/config/*.go
mikeee/dapr
tests/apps/actorreentrancy/.cache-include
none
mit
38
data*.db*
mikeee/dapr
tests/apps/actorreentrancy/.gitignore
Git
mit
9
/* Copyright 2021 The Dapr Authors Licensed 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 main import ( "bytes" "encoding/json" "fmt" "io" "log" "net/http" "os" "strconv" "sync" "github.com/gorilla/mux" "github.com/dapr/dapr/pkg/config" "github.com/dapr/dapr/tests/apps/utils" ) const ( actorMethodURLFormat = "http://localhost:%d/v1.0/actors/%s/%s/method/%s" defaultActorType = "reentrantActor" actorIdleTimeout = "1h" drainOngoingCallTimeout = "30s" drainRebalancedActors = true ) var ( appPort = 22222 daprHTTPPort = 3500 ) func init() { p := os.Getenv("DAPR_HTTP_PORT") if p != "" && p != "0" { daprHTTPPort, _ = strconv.Atoi(p) } p = os.Getenv("PORT") if p != "" && p != "0" { appPort, _ = strconv.Atoi(p) } } // represents a response for the APIs in this app. type actorLogEntry struct { Action string `json:"action,omitempty"` ActorType string `json:"actorType,omitempty"` ActorID string `json:"actorId,omitempty"` } func (e actorLogEntry) String() string { return fmt.Sprintf("action='%s' actorType='%s' actorID='%s'", e.Action, e.ActorType, e.ActorID) } type daprConfig struct { Entities []string `json:"entities,omitempty"` ActorIdleTimeout string `json:"actorIdleTimeout,omitempty"` DrainOngoingCallTimeout string `json:"drainOngoingCallTimeout,omitempty"` DrainRebalancedActors bool `json:"drainRebalancedActors,omitempty"` Reentrancy config.ReentrancyConfig `json:"reentrancy,omitempty"` EntitiesConfig []config.EntityConfig `json:"entitiesConfig,omitempty"` } type reentrantRequest struct { Calls []actorCall `json:"calls,omitempty"` } type actorCall struct { ActorID string `json:"id"` ActorType string `json:"type"` Method string `json:"method"` } var httpClient = utils.NewHTTPClient() var ( actorLogs = []actorLogEntry{} actorLogsMutex = &sync.Mutex{} maxStackDepth = 5 ) var daprConfigResponse = daprConfig{ Entities: []string{defaultActorType}, ActorIdleTimeout: actorIdleTimeout, DrainOngoingCallTimeout: drainOngoingCallTimeout, DrainRebalancedActors: drainRebalancedActors, Reentrancy: config.ReentrancyConfig{Enabled: false}, EntitiesConfig: []config.EntityConfig{ { Entities: []string{defaultActorType}, Reentrancy: config.ReentrancyConfig{ Enabled: true, MaxStackDepth: &maxStackDepth, }, }, }, } func resetLogs() { actorLogsMutex.Lock() defer actorLogsMutex.Unlock() log.Print("Reset actorLogs") actorLogs = actorLogs[:0] } func appendLog(actorType string, actorID string, action string) { logEntry := actorLogEntry{ Action: action, ActorType: actorType, ActorID: actorID, } actorLogsMutex.Lock() defer actorLogsMutex.Unlock() log.Printf("Append to actorLogs: %s", logEntry) actorLogs = append(actorLogs, logEntry) } // indexHandler is the handler for root path. func indexHandler(w http.ResponseWriter, r *http.Request) { log.Println("indexHandler is called") w.WriteHeader(http.StatusOK) } func logsHandler(w http.ResponseWriter, r *http.Request) { log.Printf("Processing dapr %s request for %s", r.Method, r.URL.RequestURI()) if r.Method == http.MethodDelete { resetLogs() } actorLogsMutex.Lock() entries, _ := json.Marshal(actorLogs) actorLogsMutex.Unlock() log.Printf("Sending actorLogs: %s", string(entries)) w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusOK) w.Write(entries) } func configHandler(w http.ResponseWriter, r *http.Request) { log.Printf("Processing dapr request for %s, responding with %v", r.URL.RequestURI(), daprConfigResponse) w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusOK) json.NewEncoder(w).Encode(daprConfigResponse) } func healthzHandler(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) w.Write([]byte("")) } func actorTestCallHandler(w http.ResponseWriter, r *http.Request) { log.Print("Handling actor test call") body, err := io.ReadAll(r.Body) defer r.Body.Close() if err != nil { w.WriteHeader(http.StatusInternalServerError) return } var reentrantReq reentrantRequest json.Unmarshal(body, &reentrantReq) if len(reentrantReq.Calls) == 0 { log.Print("No calls in test chain") return } nextCall, nextBody := advanceCallStackForNextRequest(reentrantReq) req, _ := http.NewRequest(http.MethodPut, fmt.Sprintf(actorMethodURLFormat, daprHTTPPort, nextCall.ActorType, nextCall.ActorID, nextCall.Method), bytes.NewReader(nextBody)) res, err := httpClient.Do(req) if err != nil { w.Write([]byte(err.Error())) w.WriteHeader(http.StatusInternalServerError) return } respBody, err := io.ReadAll(res.Body) defer res.Body.Close() if err != nil { w.Write([]byte(err.Error())) w.WriteHeader(http.StatusInternalServerError) return } w.Write(respBody) } func actorMethodHandler(w http.ResponseWriter, r *http.Request) { method := mux.Vars(r)["method"] log.Printf("Handling actor method call %s", method) switch method { case "helloMethod": // No-op case "reentrantMethod": reentrantCallHandler(w, r) case "standardMethod": fallthrough default: standardHandler(w, r) } } func reentrantCallHandler(w http.ResponseWriter, r *http.Request) { log.Print("Handling reentrant call") appendLog(mux.Vars(r)["actorType"], mux.Vars(r)["id"], fmt.Sprintf("Enter %s", mux.Vars(r)["method"])) body, err := io.ReadAll(r.Body) defer r.Body.Close() if err != nil { w.WriteHeader(http.StatusInternalServerError) return } var reentrantReq reentrantRequest json.Unmarshal(body, &reentrantReq) if len(reentrantReq.Calls) == 0 { log.Print("End of call chain") return } nextCall, nextBody := advanceCallStackForNextRequest(reentrantReq) log.Printf("Next call: %s on %s.%s", nextCall.Method, nextCall.ActorType, nextCall.ActorID) url := fmt.Sprintf(actorMethodURLFormat, daprHTTPPort, nextCall.ActorType, nextCall.ActorID, nextCall.Method) req, _ := http.NewRequest(http.MethodPut, url, bytes.NewReader(nextBody)) reentrancyID := r.Header.Get("Dapr-Reentrancy-Id") req.Header.Add("Dapr-Reentrancy-Id", reentrancyID) resp, err := httpClient.Do(req) log.Printf("Call status: %d", resp.StatusCode) if err != nil || resp.StatusCode == http.StatusInternalServerError { w.WriteHeader(http.StatusInternalServerError) appendLog(mux.Vars(r)["actorType"], mux.Vars(r)["id"], fmt.Sprintf("Error %s", mux.Vars(r)["method"])) } else { appendLog(mux.Vars(r)["actorType"], mux.Vars(r)["id"], fmt.Sprintf("Exit %s", mux.Vars(r)["method"])) } defer resp.Body.Close() } func standardHandler(w http.ResponseWriter, r *http.Request) { log.Print("Handling standard call") appendLog(mux.Vars(r)["actorType"], mux.Vars(r)["id"], fmt.Sprintf("Enter %s", mux.Vars(r)["method"])) appendLog(mux.Vars(r)["actorType"], mux.Vars(r)["id"], fmt.Sprintf("Exit %s", mux.Vars(r)["method"])) } func advanceCallStackForNextRequest(req reentrantRequest) (actorCall, []byte) { nextCall := req.Calls[0] log.Printf("Current call: %v", nextCall) nextReq := req nextReq.Calls = nextReq.Calls[1:] log.Printf("Next req: %v", nextReq) nextBody, _ := json.Marshal(nextReq) return nextCall, nextBody } // appRouter initializes restful api router. func appRouter() http.Handler { router := mux.NewRouter().StrictSlash(true) // Log requests and their processing time router.Use(utils.LoggerMiddleware) router.HandleFunc("/", indexHandler).Methods("GET") router.HandleFunc("/dapr/config", configHandler).Methods("GET") router.HandleFunc("/actors/{actorType}/{id}/method/{method}", actorMethodHandler).Methods("PUT") router.HandleFunc("/test/actors/{actorType}/{id}/method/{method}", actorTestCallHandler).Methods("POST") router.HandleFunc("/test/logs", logsHandler).Methods("GET", "DELETE") router.HandleFunc("/healthz", healthzHandler).Methods("GET") router.Use(mux.CORSMethodMiddleware(router)) return router } func main() { log.Printf("Actor App - listening on http://localhost:%d", appPort) utils.StartServer(appPort, appRouter, true, false) }
mikeee/dapr
tests/apps/actorreentrancy/app.go
GO
mit
8,662
apiVersion: dapr.io/v1alpha1 kind: Component metadata: name: statestore spec: type: state.sqlite version: v1 metadata: - name: actorStateStore value: "true" - name: connectionString value: "data.db"
mikeee/dapr
tests/apps/actorreentrancy/resources/sqlite.yaml
YAML
mit
227
# In e2e test, this will not be used to deploy the app to test cluster. # This is created for testing purpose in order to deploy this app using kubectl # before writing e2e test. kind: Service apiVersion: v1 metadata: name: reentrantactor labels: testapp: reentrantactor spec: selector: testapp: reentrantactor ports: - protocol: TCP port: 80 targetPort: 3000 type: LoadBalancer --- apiVersion: apps/v1 kind: Deployment metadata: name: reentrantactor labels: testapp: reentrantactor spec: replicas: 1 selector: matchLabels: testapp: reentrantactor template: metadata: labels: testapp: reentrantactor annotations: dapr.io/enabled: "true" dapr.io/app-id: "reentrantactor" dapr.io/app-port: "3000" spec: containers: - name: actorreentrancy image: halspang/e2e-actorreentrancy:dev ports: - containerPort: 3000 imagePullPolicy: Always
mikeee/dapr
tests/apps/actorreentrancy/service.yaml
YAML
mit
980
../utils/*.go
mikeee/dapr
tests/apps/actorstate/.cache-include
none
mit
13
/* Copyright 2021 The Dapr Authors Licensed 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 main import ( "bytes" "encoding/json" "fmt" "io" "log" "net/http" "os" "strconv" "github.com/gorilla/mux" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" runtimev1 "github.com/dapr/dapr/pkg/proto/runtime/v1" "github.com/dapr/dapr/tests/apps/utils" ) const ( daprBaseURLFormat = "http://localhost:%d/v1.0" actorInvokeURLFormat = daprBaseURLFormat + "/actors/%s/%s/method/test" actorSaveStateURLFormat = daprBaseURLFormat + "/actors/%s/%s/state" actorGetStateURLFormat = daprBaseURLFormat + "/actors/%s/%s/state/%s" actorTypeEnvName = "TEST_APP_ACTOR_TYPE" // To set to change actor type. actorRemindersPartitionsEnvName = "TEST_APP_ACTOR_REMINDERS_PARTITIONS" // To set actor type partition count. ) var ( appPort = 3000 daprHTTPPort = 3500 daprGRPCPort = 50001 httpClient = utils.NewHTTPClient() ) func init() { p := os.Getenv("DAPR_HTTP_PORT") if p != "" && p != "0" { daprHTTPPort, _ = strconv.Atoi(p) } p = os.Getenv("PORT") if p != "" && p != "0" { appPort, _ = strconv.Atoi(p) } p = os.Getenv("DAPR_GRPC_PORT") if p != "" && p != "0" { daprGRPCPort, _ = strconv.Atoi(p) } } // indexHandler is the handler for root path func indexHandler(w http.ResponseWriter, r *http.Request) { log.Println("indexHandler is called") w.WriteHeader(http.StatusOK) } func actorStateHandlerGRPC(w http.ResponseWriter, r *http.Request) { daprAddress := fmt.Sprintf("localhost:%d", daprGRPCPort) conn, err := grpc.DialContext(r.Context(), daprAddress, grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { log.Printf("gRPC dapr connection failed %s", err.Error()) w.WriteHeader(http.StatusInternalServerError) return } defer conn.Close() client := runtimev1.NewDaprClient(conn) switch r.Method { case http.MethodGet: var req runtimev1.GetActorStateRequest if err = json.NewDecoder(r.Body).Decode(&req); err != nil { log.Printf("actor state call failed: %s", err.Error()) w.WriteHeader(http.StatusInternalServerError) return } var resp *runtimev1.GetActorStateResponse resp, err = client.GetActorState(r.Context(), &req) if err != nil { w.WriteHeader(http.StatusInternalServerError) w.Write([]byte(err.Error())) } else { b, _ := json.Marshal(resp) w.Write(b) w.WriteHeader(http.StatusOK) } default: var op runtimev1.ExecuteActorStateTransactionRequest if err = json.NewDecoder(r.Body).Decode(&op); err != nil { log.Printf("actor state call failed: %s", err.Error()) w.WriteHeader(http.StatusInternalServerError) return } _, err := client.ExecuteActorStateTransaction(r.Context(), &op) if err != nil { w.WriteHeader(http.StatusInternalServerError) w.Write([]byte(err.Error())) } else { w.WriteHeader(http.StatusOK) } } } func actorStateHandlerHTTP(w http.ResponseWriter, r *http.Request) { actorType := mux.Vars(r)["actorType"] id := mux.Vars(r)["id"] var url string switch r.Method { case http.MethodGet, http.MethodDelete: url = fmt.Sprintf(actorGetStateURLFormat, daprHTTPPort, actorType, id, mux.Vars(r)["key"]) default: url = fmt.Sprintf(actorSaveStateURLFormat, daprHTTPPort, actorType, id) } resp, status, header, err := httpCall(r.Method, url, r.Body) if err != nil { log.Printf("actor state call failed: %s", err.Error()) w.WriteHeader(http.StatusInternalServerError) return } for k, v := range header { w.Header().Set(k, v[0]) } w.WriteHeader(status) w.Write(resp) } func initActor(w http.ResponseWriter, r *http.Request) { actorType := mux.Vars(r)["actorType"] id := mux.Vars(r)["id"] reqURL := fmt.Sprintf(actorInvokeURLFormat, daprHTTPPort, actorType, id) req, err := http.NewRequest(http.MethodPost, reqURL, bytes.NewReader(nil)) if err != nil { log.Printf("actor init call failed: %s", err.Error()) w.WriteHeader(http.StatusInternalServerError) return } resp, err := httpClient.Do(req) if err != nil { log.Printf("actor init call failed: %s", err.Error()) w.WriteHeader(http.StatusInternalServerError) return } defer resp.Body.Close() b, err := io.ReadAll(resp.Body) if err != nil { log.Printf("actor init call failed: %s", err.Error()) w.WriteHeader(http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) w.Write(b) } func actorMethodHandler(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) } func healthzHandler(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) w.Write([]byte("")) } func configHandler(w http.ResponseWriter, r *http.Request) { log.Printf("Processing dapr request for %s", r.URL.RequestURI()) w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusOK) json.NewEncoder(w).Encode(struct { Entities []string `json:"entities,omitempty"` ActorIdleTimeout string `json:"actorIdleTimeout,omitempty"` DrainOngoingCallTimeout string `json:"drainOngoingCallTimeout,omitempty"` DrainRebalancedActors bool `json:"drainRebalancedActors,omitempty"` }{ Entities: []string{"httpMyActorType", "grpcMyActorType"}, ActorIdleTimeout: "30s", DrainOngoingCallTimeout: "20s", DrainRebalancedActors: true, }) } func httpCall(method string, url string, body io.ReadCloser) ([]byte, int, http.Header, error) { req, err := http.NewRequest(method, url, body) if err != nil { return nil, -1, nil, err } req.Header.Set("Content-Type", "application/json; utf-8") resp, err := httpClient.Do(req) if err != nil { return nil, -1, nil, err } defer resp.Body.Close() respBody, err := io.ReadAll(resp.Body) if err != nil { return nil, -1, nil, err } return respBody, resp.StatusCode, resp.Header, nil } // appRouter initializes restful api router func appRouter() http.Handler { router := mux.NewRouter().StrictSlash(true) // Log requests and their processing time router.Use(utils.LoggerMiddleware) router.HandleFunc("/", indexHandler).Methods("GET") router.HandleFunc("/dapr/config", configHandler).Methods("GET") router.HandleFunc("/healthz", healthzHandler).Methods("GET") router.HandleFunc("/test/initactor/{actorType}/{id}", initActor).Methods("GET") router.HandleFunc("/test/actor_state_http/{actorType}/{id}/{key}", actorStateHandlerHTTP).Methods("GET", "DELETE") router.HandleFunc("/test/actor_state_http/{actorType}/{id}", actorStateHandlerHTTP).Methods("PUT", "POST", "PATCH") router.HandleFunc("/test/actor_state_grpc", actorStateHandlerGRPC).Methods("GET", "POST", "DELETE", "PATCH") router.HandleFunc("/actors/{actorType}/{id}/method/{method}", actorMethodHandler).Methods("PUT", "POST") router.HandleFunc("/actors/{actorType}/{id}", actorMethodHandler).Methods("POST", "DELETE") router.Use(mux.CORSMethodMiddleware(router)) return router } func main() { log.Printf("Actor App - listening on http://localhost:%d", appPort) utils.StartServer(appPort, appRouter, true, false) }
mikeee/dapr
tests/apps/actorstate/app.go
GO
mit
7,574
# In e2e test, this will not be used to deploy the app to test cluster. # This is created for testing purpose in order to deploy this app using kubectl # before writing e2e test. kind: Service apiVersion: v1 metadata: name: actorstate labels: testapp: actorstate spec: selector: testapp: actorstate ports: - protocol: TCP port: 80 targetPort: 3000 type: LoadBalancer --- apiVersion: apps/v1 kind: Deployment metadata: name: stateapp labels: testapp: actorstate spec: replicas: 1 selector: matchLabels: testapp: actorstate template: metadata: labels: testapp: actorstate annotations: dapr.io/enabled: "true" dapr.io/app-id: "actorstate" dapr.io/app-port: "3000" spec: containers: - name: actorstate image: docker.io/YOUR_ALIAS/e2e-actorstate:dev ports: - containerPort: 3000 imagePullPolicy: Always
mikeee/dapr
tests/apps/actorstate/service.yaml
YAML
mit
948
../utils/*.go
mikeee/dapr
tests/apps/binding_input/.cache-include
none
mit
13
/* Copyright 2021 The Dapr Authors Licensed 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 main import ( "encoding/json" "fmt" "log" "net/http" "os" "sync" "github.com/gorilla/mux" "github.com/dapr/dapr/tests/apps/utils" ) const ( appPort = 3000 DaprTestTopicEnvVar = "DAPR_TEST_TOPIC_NAME" DaprTestCustomPathRouteEnvVar = "DAPR_TEST_CUSTOM_PATH_ROUTE" ) var ( topicName = "test-topic" topicCustomPath = "custom-path" ) func init() { if envTopicName := os.Getenv(DaprTestTopicEnvVar); len(envTopicName) != 0 { topicName = envTopicName } if envCustomPath := os.Getenv(DaprTestCustomPathRouteEnvVar); len(envCustomPath) != 0 { topicCustomPath = envCustomPath } } type messageBuffer struct { lock *sync.RWMutex successMessages []string routedMessages []string // errorOnce is used to make sure that message is failed only once. errorOnce bool failedMessage string } func (m *messageBuffer) addRouted(message string) { m.lock.Lock() defer m.lock.Unlock() m.routedMessages = append(m.routedMessages, message) } func (m *messageBuffer) add(message string) { m.lock.Lock() defer m.lock.Unlock() m.successMessages = append(m.successMessages, message) } func (m *messageBuffer) getAllRouted() []string { m.lock.RLock() defer m.lock.RUnlock() return m.routedMessages } func (m *messageBuffer) getAllSuccessful() []string { m.lock.RLock() defer m.lock.RUnlock() return m.successMessages } func (m *messageBuffer) getFailed() string { m.lock.RLock() defer m.lock.RUnlock() return m.failedMessage } func (m *messageBuffer) fail(failedMessage string) bool { m.lock.Lock() defer m.lock.Unlock() // fail only for the first time. return false all other times. if !m.errorOnce { m.failedMessage = failedMessage m.errorOnce = true return m.errorOnce } return false } var messages = messageBuffer{ lock: &sync.RWMutex{}, successMessages: []string{}, } type indexHandlerResponse struct { Message string `json:"message,omitempty"` } type testHandlerResponse struct { ReceivedMessages []string `json:"received_messages,omitempty"` Message string `json:"message,omitempty"` FailedMessage string `json:"failed_message,omitempty"` RoutedMessages []string `json:"routeed_messages,omitempty"` } // indexHandler is the handler for root path func indexHandler(w http.ResponseWriter, r *http.Request) { log.Println("indexHandler is called") w.WriteHeader(http.StatusOK) json.NewEncoder(w).Encode(indexHandlerResponse{Message: "OK"}) } func testTopicHandler(w http.ResponseWriter, r *http.Request) { log.Printf("testTopicHandler called") if r.Method == http.MethodOptions { log.Println("test-topic binding input has been accepted") // Sending StatusOK back to the topic, so it will not attempt to redeliver on session restart. // Consumer marking successfully consumed offset. w.WriteHeader(http.StatusOK) return } var message string err := json.NewDecoder(r.Body).Decode(&message) log.Printf("Got message: %s", message) if err != nil { log.Printf("error parsing test-topic input binding payload: %s", err) w.WriteHeader(http.StatusOK) return } if fail := messages.fail(message); fail { // simulate failure. fail only for the first time. log.Print("failing message") w.WriteHeader(http.StatusInternalServerError) return } messages.add(message) w.WriteHeader(http.StatusOK) } func testRoutedTopicHandler(w http.ResponseWriter, r *http.Request) { log.Printf("testRoutedTopicHandler called") if r.Method == http.MethodOptions { log.Println("test-topic routed binding input has been accepted") // Sending StatusOK back to the topic, so it will not attempt to redeliver on session restart. // Consumer marking successfully consumed offset. w.WriteHeader(http.StatusOK) return } var message string err := json.NewDecoder(r.Body).Decode(&message) log.Printf("Got message: %s", message) if err != nil { log.Printf("error parsing test-topic input binding payload: %s", err) w.WriteHeader(http.StatusOK) return } messages.addRouted(message) w.WriteHeader(http.StatusOK) } func testHandler(w http.ResponseWriter, r *http.Request) { failedMessage := messages.getFailed() log.Printf("failed message %s", failedMessage) if err := json.NewEncoder(w).Encode(testHandlerResponse{ ReceivedMessages: messages.getAllSuccessful(), FailedMessage: failedMessage, RoutedMessages: messages.getAllRouted(), }); err != nil { log.Printf("error encoding saved messages: %s", err) w.WriteHeader(http.StatusInternalServerError) json.NewEncoder(w).Encode(testHandlerResponse{ Message: err.Error(), }) return } } // appRouter initializes restful api router func appRouter() http.Handler { router := mux.NewRouter().StrictSlash(true) // Log requests and their processing time router.Use(utils.LoggerMiddleware) router.HandleFunc("/", indexHandler).Methods("GET") router.HandleFunc(fmt.Sprintf("/%s", topicName), testTopicHandler).Methods("POST", "OPTIONS") router.HandleFunc(fmt.Sprintf("/%s", topicCustomPath), testRoutedTopicHandler).Methods("POST", "OPTIONS") router.HandleFunc("/tests/get_received_topics", testHandler).Methods("POST") router.Use(mux.CORSMethodMiddleware(router)) return router } func main() { log.Printf("Hello Dapr - listening on http://localhost:%d", appPort) utils.StartServer(appPort, appRouter, true, false) }
mikeee/dapr
tests/apps/binding_input/app.go
GO
mit
5,930
# In e2e test, this will not be used to deploy the app to test cluster. # This is created for testing purpose in order to deploy this app using kubectl # before writing e2e test. kind: Service apiVersion: v1 metadata: name: bindinginput labels: testapp: bindinginput namespace: dapr-system spec: selector: testapp: bindinginput ports: - protocol: TCP port: 80 targetPort: 3000 type: LoadBalancer --- apiVersion: apps/v1 kind: Deployment metadata: name: bindinginput labels: testapp: bindinginput namespace: dapr-system spec: replicas: 1 selector: matchLabels: testapp: bindinginput template: metadata: labels: testapp: bindinginput annotations: dapr.io/enabled: "true" dapr.io/app-id: "bindinginput" dapr.io/app-port: "3000" spec: containers: - name: bindinginput image: YOUR_REGISTRY/e2e-binding_input:dev ports: - containerPort: 3000 imagePullPolicy: Always
mikeee/dapr
tests/apps/binding_input/service.yaml
YAML
mit
1,032
../utils/*.go ../../../dapr/proto/runtime/v1/*.proto ../../../dapr/proto/common/v1/*.proto
mikeee/dapr
tests/apps/binding_input_grpc/.cache-include
none
mit
90
/* Copyright 2021 The Dapr Authors Licensed 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 main import ( "context" "encoding/json" "fmt" "log" "net" "os" "sync" "google.golang.org/protobuf/types/known/anypb" "google.golang.org/protobuf/types/known/emptypb" commonv1pb "github.com/dapr/dapr/pkg/proto/common/v1" runtimev1pb "github.com/dapr/dapr/pkg/proto/runtime/v1" "google.golang.org/grpc" ) const ( appPort = "3000" DaprTestGRPCTopicEnvVar = "DAPR_TEST_GRPC_TOPIC_NAME" ) var topicName = "test-topic-grpc" func init() { if envTopicName := os.Getenv(DaprTestGRPCTopicEnvVar); len(envTopicName) != 0 { topicName = envTopicName } } // server is our user app. type server struct{} type messageBuffer struct { lock *sync.RWMutex successMessages []string // errorOnce is used to make sure that message is failed only once. errorOnce bool failedMessage string } func (m *messageBuffer) add(message string) { m.lock.Lock() defer m.lock.Unlock() m.successMessages = append(m.successMessages, message) } func (m *messageBuffer) getAllSuccessful() []string { m.lock.RLock() defer m.lock.RUnlock() return m.successMessages } func (m *messageBuffer) getFailed() string { m.lock.RLock() defer m.lock.RUnlock() return m.failedMessage } func (m *messageBuffer) fail(failedMessage string) bool { m.lock.Lock() defer m.lock.Unlock() // fail only for the first time. return false all other times. if !m.errorOnce { m.failedMessage = failedMessage m.errorOnce = true return m.errorOnce } return false } var messages = messageBuffer{ lock: &sync.RWMutex{}, successMessages: []string{}, } type receivedMessagesResponse struct { ReceivedMessages []string `json:"received_messages,omitempty"` Message string `json:"message,omitempty"` FailedMessage string `json:"failed_message,omitempty"` } func main() { log.Printf("Initializing grpc") /* #nosec */ lis, err := net.Listen("tcp", fmt.Sprintf(":%s", appPort)) if err != nil { log.Fatalf("failed to listen: %v", err) } /* #nosec */ s := grpc.NewServer() runtimev1pb.RegisterAppCallbackServer(s, &server{}) log.Println("Client starting...") if err := s.Serve(lis); err != nil { log.Fatalf("failed to serve: %v", err) } } //nolint:forbidigo func (s *server) OnInvoke(ctx context.Context, in *commonv1pb.InvokeRequest) (*commonv1pb.InvokeResponse, error) { fmt.Printf("Got invoked method %s and data: %s\n", in.GetMethod(), string(in.GetData().GetValue())) switch in.GetMethod() { case "GetReceivedTopics": return s.GetReceivedTopics(ctx, in) } return &commonv1pb.InvokeResponse{}, nil } func (s *server) GetReceivedTopics(ctx context.Context, in *commonv1pb.InvokeRequest) (*commonv1pb.InvokeResponse, error) { failedMessage := messages.getFailed() log.Printf("failed message %s", failedMessage) resp := receivedMessagesResponse{ ReceivedMessages: messages.getAllSuccessful(), FailedMessage: failedMessage, } rawResp, err := json.Marshal(resp) if err != nil { log.Printf("Could not encode response: %s", err.Error()) return &commonv1pb.InvokeResponse{}, err } data := anypb.Any{ Value: rawResp, } return &commonv1pb.InvokeResponse{ Data: &data, }, nil } // Dapr will call this method to get the list of topics the app wants to subscribe to. func (s *server) ListTopicSubscriptions(ctx context.Context, in *emptypb.Empty) (*runtimev1pb.ListTopicSubscriptionsResponse, error) { log.Println("List Topic Subscription called") return &runtimev1pb.ListTopicSubscriptionsResponse{ Subscriptions: []*runtimev1pb.TopicSubscription{}, }, nil } // This method is fired whenever a message has been published to a topic that has been subscribed. Dapr sends published messages in a CloudEvents 1.0 envelope. func (s *server) OnTopicEvent(ctx context.Context, in *runtimev1pb.TopicEventRequest) (*runtimev1pb.TopicEventResponse, error) { log.Printf("Message arrived - Topic: %s, Message: %s\n", in.GetTopic(), string(in.GetData())) var message string err := json.Unmarshal(in.GetData(), &message) log.Printf("Got message: %s", message) if err != nil { log.Printf("error parsing test-topic input binding payload: %s", err) return &runtimev1pb.TopicEventResponse{}, nil } if fail := messages.fail(message); fail { // simulate failure. fail only for the first time. log.Print("failing message") return &runtimev1pb.TopicEventResponse{}, nil } messages.add(message) return &runtimev1pb.TopicEventResponse{ Status: runtimev1pb.TopicEventResponse_SUCCESS, //nolint:nosnakecase }, nil } func (s *server) ListInputBindings(ctx context.Context, in *emptypb.Empty) (*runtimev1pb.ListInputBindingsResponse, error) { log.Println("List Input Bindings called") return &runtimev1pb.ListInputBindingsResponse{ Bindings: []string{ topicName, }, }, nil } // This method gets invoked every time a new event is fired from a registered binding. The message carries the binding name, a payload and optional metadata. // //nolint:forbidigo func (s *server) OnBindingEvent(ctx context.Context, in *runtimev1pb.BindingEventRequest) (*runtimev1pb.BindingEventResponse, error) { fmt.Printf("Invoked from binding: %s - %s\n", in.GetName(), string(in.GetData())) return &runtimev1pb.BindingEventResponse{}, nil }
mikeee/dapr
tests/apps/binding_input_grpc/app.go
GO
mit
5,798
../utils/*.go ../../../dapr/proto/runtime/v1/*.proto ../../../dapr/proto/common/v1/*.proto
mikeee/dapr
tests/apps/binding_output/.cache-include
none
mit
90
/* Copyright 2021 The Dapr Authors Licensed 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 main import ( "bytes" "context" "encoding/json" "fmt" "log" "net/http" "os" "github.com/gorilla/mux" "google.golang.org/protobuf/types/known/anypb" commonv1pb "github.com/dapr/dapr/pkg/proto/common/v1" runtimev1pb "github.com/dapr/dapr/pkg/proto/runtime/v1" "github.com/dapr/dapr/tests/apps/utils" ) const ( appPort = 3000 daprPort = 3500 DaprTestTopicEnvVar = "DAPR_TEST_TOPIC_NAME" DaprTestGRPCTopicEnvVar = "DAPR_TEST_GRPC_TOPIC_NAME" DaprTestInputBindingServiceEnVar = "DAPR_TEST_INPUT_BINDING_SVC" ) var ( daprClient runtimev1pb.DaprClient topicName = "test-topic" topicNameGrpc = "test-topic-grpc" inputbindingSvc = "bindinginputgrpc" ) func init() { if envTopicName := os.Getenv(DaprTestTopicEnvVar); len(envTopicName) != 0 { topicName = envTopicName } if envGrpcTopic := os.Getenv(DaprTestGRPCTopicEnvVar); len(envGrpcTopic) != 0 { topicNameGrpc = envGrpcTopic } if envinputBinding := os.Getenv(DaprTestInputBindingServiceEnVar); len(envinputBinding) != 0 { inputbindingSvc = envinputBinding } } type testCommandRequest struct { Messages []struct { Data string `json:"data,omitempty"` Operation string `json:"operation"` } `json:"messages,omitempty"` } type indexHandlerResponse struct { Message string `json:"message,omitempty"` } // indexHandler is the handler for root path func indexHandler(w http.ResponseWriter, r *http.Request) { log.Println("indexHandler is called") w.WriteHeader(http.StatusOK) json.NewEncoder(w).Encode(indexHandlerResponse{Message: "OK"}) } //nolint:gosec func testHandler(w http.ResponseWriter, r *http.Request) { log.Printf("Entered testHandler") var requestBody testCommandRequest err := json.NewDecoder(r.Body).Decode(&requestBody) if err != nil { log.Printf("error parsing request body: %s", err) w.WriteHeader(http.StatusBadRequest) return } url := fmt.Sprintf("http://localhost:%d/v1.0/bindings/%s", daprPort, topicName) for _, message := range requestBody.Messages { body, err := json.Marshal(&message) if err != nil { log.Printf("error encoding message: %s", err) w.WriteHeader(http.StatusInternalServerError) w.Write([]byte("error: " + err.Error())) return } /* #nosec */ resp, err := http.Post(url, "application/json", bytes.NewBuffer(body)) resp.Body.Close() if err != nil { log.Printf("error sending request to output binding: %s", err) w.WriteHeader(http.StatusInternalServerError) w.Write([]byte("error: " + err.Error())) return } } w.WriteHeader(http.StatusOK) } func sendGRPC(w http.ResponseWriter, r *http.Request) { log.Printf("Entered sendGRPC") var requestBody testCommandRequest err := json.NewDecoder(r.Body).Decode(&requestBody) if err != nil { log.Printf("error parsing request body: %s", err) w.WriteHeader(http.StatusBadRequest) return } for _, message := range requestBody.Messages { //nolint:gosec body, _ := json.Marshal(&message) log.Printf("Sending message: %s", body) req := runtimev1pb.InvokeBindingRequest{ Name: topicNameGrpc, Data: body, Operation: "create", } _, err = daprClient.InvokeBinding(context.Background(), &req) if err != nil { log.Printf("Error sending request to GRPC output binding: %s", err) w.WriteHeader(http.StatusInternalServerError) w.Write([]byte("error: " + err.Error())) return } } } func getReceivedTopicsGRPC(w http.ResponseWriter, r *http.Request) { log.Printf("Entered getReceivedTopicsGRPC") req := runtimev1pb.InvokeServiceRequest{ Id: inputbindingSvc, Message: &commonv1pb.InvokeRequest{ Method: "GetReceivedTopics", Data: &anypb.Any{}, HttpExtension: &commonv1pb.HTTPExtension{ Verb: commonv1pb.HTTPExtension_POST, //nolint:nosnakecase }, }, } resp, err := daprClient.InvokeService(context.Background(), &req) if err != nil { log.Printf("Could not get received messages: %s", err.Error()) w.WriteHeader(http.StatusInternalServerError) return } w.Write(resp.GetData().GetValue()) } // appRouter initializes restful api router func appRouter() http.Handler { router := mux.NewRouter().StrictSlash(true) // Log requests and their processing time router.Use(utils.LoggerMiddleware) router.HandleFunc("/", indexHandler).Methods("GET") router.HandleFunc("/tests/send", testHandler).Methods("POST") router.HandleFunc("/tests/sendGRPC", sendGRPC).Methods("POST") router.HandleFunc("/tests/get_received_topics_grpc", getReceivedTopicsGRPC).Methods("POST") router.Use(mux.CORSMethodMiddleware(router)) return router } func main() { daprClient = utils.GetGRPCClient(50001) log.Printf("Hello Dapr - listening on http://localhost:%d", appPort) utils.StartServer(appPort, appRouter, true, false) }
mikeee/dapr
tests/apps/binding_output/app.go
GO
mit
5,387
# In e2e test, this will not be used to deploy the app to test cluster. # This is created for testing purpose in order to deploy this app using kubectl # before writing e2e test. kind: Service apiVersion: v1 metadata: name: bindingoutput labels: testapp: bindingoutput spec: selector: testapp: bindingoutput ports: - protocol: TCP port: 80 targetPort: 3000 type: LoadBalancer --- apiVersion: apps/v1 kind: Deployment metadata: name: bindingoutput labels: testapp: bindingoutput spec: replicas: 1 selector: matchLabels: testapp: bindingoutput template: metadata: labels: testapp: bindingoutput annotations: dapr.io/enabled: "true" dapr.io/app-id: "bindingoutput" dapr.io/app-port: "3000" spec: containers: - name: bindingoutput image: YOUR_REGISTRY/e2e-binding_output:dev ports: - containerPort: 3000 imagePullPolicy: Always
mikeee/dapr
tests/apps/binding_output/service.yaml
YAML
mit
992
/* Copyright 2021 The Dapr Authors Licensed 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 main import ( "context" "encoding/json" "errors" "fmt" "io" "log" "net/http" "os" "strconv" "strings" "sync" "time" "github.com/gorilla/mux" "github.com/jackc/pgx/v5/pgxpool" "github.com/redis/go-redis/v9" runtimev1pb "github.com/dapr/dapr/pkg/proto/runtime/v1" "github.com/dapr/dapr/tests/apps/utils" ) const ( daprGRPCPort = 50001 daprConfigurationURLStable = "http://localhost:3500/v1.0/configuration/" daprConfigurationURLAlpha1 = "http://localhost:3500/v1.0-alpha1/configuration/" separator = "||" redisHost = "dapr-redis-master.dapr-tests.svc.cluster.local:6379" writeTimeout = 5 * time.Second alpha1Endpoint = "alpha1" postgresComponent = "postgres" redisComponent = "redis" postgresChannel = "config" postgresConnectionString = "host=dapr-postgres-postgresql.dapr-tests.svc.cluster.local user=postgres password=example port=5432 connect_timeout=10 database=dapr_test" postgresConfigTable = "configtable" ) var ( appPort = 3000 lock sync.Mutex receivedUpdates map[string][]string updater Updater httpClient = utils.NewHTTPClient() grpcClient runtimev1pb.DaprClient grpcSubs = make(map[string]context.CancelFunc) ) type UnsubscribeConfigurationResponse struct { Ok bool `json:"ok,omitempty"` Message string `json:"message,omitempty"` } type appResponse struct { Message string `json:"message,omitempty"` StartTime int `json:"start_time,omitempty"` EndTime int `json:"end_time,omitempty"` } type receivedMessagesResponse struct { ReceivedUpdates []string `json:"received-messages"` } type Item struct { Value string `json:"value,omitempty"` Version string `json:"version,omitempty"` Metadata map[string]string `json:"metadata,omitempty"` } type UpdateEvent struct { ID string `json:"id"` Items map[string]*Item `json:"items"` } type Updater interface { Init() error AddKey(items map[string]*Item) error UpdateKey(items map[string]*Item) error } type RedisUpdater struct { client *redis.Client } func (r *RedisUpdater) Init() error { opts := &redis.Options{ Addr: redisHost, Password: "", DB: 0, } r.client = redis.NewClient(opts) timeoutCtx, cancel := context.WithTimeout(context.Background(), writeTimeout) defer cancel() err := r.client.Ping(timeoutCtx).Err() if err != nil { return fmt.Errorf("error connecting to redis config store. err: %s", err) } return nil } func (r *RedisUpdater) AddKey(items map[string]*Item) error { timeoutCtx, cancel := context.WithTimeout(context.Background(), writeTimeout) defer cancel() values := getRedisValuesFromItems(items) valuesWithCommand := append([]interface{}{"MSET"}, values...) return r.client.Do(timeoutCtx, valuesWithCommand...).Err() } func (r *RedisUpdater) UpdateKey(items map[string]*Item) error { return r.AddKey(items) } type PostgresUpdater struct { client *pgxpool.Pool } func createAndSetTable(ctx context.Context, client *pgxpool.Pool, configTable string) error { // Creating table if not exists _, err := client.Exec(ctx, "CREATE TABLE IF NOT EXISTS "+configTable+" (KEY VARCHAR NOT NULL, VALUE VARCHAR NOT NULL, VERSION VARCHAR NOT NULL, METADATA JSON)") if err != nil { return fmt.Errorf("error creating table : %w", err) } // Deleting existing data _, err = client.Exec(ctx, "TRUNCATE TABLE "+configTable) if err != nil { return fmt.Errorf("error truncating table : %w", err) } return nil } func (r *PostgresUpdater) CreateTrigger(channel string) error { ctx := context.Background() procedureName := "configuration_event_" + channel createConfigEventSQL := `CREATE OR REPLACE FUNCTION ` + procedureName + `() RETURNS TRIGGER AS $$ DECLARE data json; notification json; BEGIN IF (TG_OP = 'DELETE') THEN data = row_to_json(OLD); ELSE data = row_to_json(NEW); END IF; notification = json_build_object( 'table',TG_TABLE_NAME, 'action', TG_OP, 'data', data); PERFORM pg_notify('` + channel + `' ,notification::text); RETURN NULL; END; $$ LANGUAGE plpgsql; ` _, err := r.client.Exec(ctx, createConfigEventSQL) if err != nil { return fmt.Errorf("error creating config event function : %w", err) } triggerName := "configTrigger_" + channel createTriggerSQL := "CREATE TRIGGER " + triggerName + " AFTER INSERT OR UPDATE OR DELETE ON " + postgresConfigTable + " FOR EACH ROW EXECUTE PROCEDURE " + procedureName + "();" _, err = r.client.Exec(ctx, createTriggerSQL) if err != nil { return fmt.Errorf("error creating config trigger : %w", err) } return nil } func (r *PostgresUpdater) Init() error { ctx := context.Background() config, err := pgxpool.ParseConfig(postgresConnectionString) if err != nil { return fmt.Errorf("postgres configuration store connection error : %w", err) } pool, err := pgxpool.NewWithConfig(ctx, config) if err != nil { return fmt.Errorf("postgres configuration store connection error : %w", err) } err = pool.Ping(ctx) if err != nil { return fmt.Errorf("postgres configuration store ping error : %w", err) } r.client = pool err = createAndSetTable(ctx, r.client, postgresConfigTable) if err != nil { return fmt.Errorf("postgres configuration store table creation error : %w", err) } err = r.CreateTrigger(postgresChannel) if err != nil { return fmt.Errorf("postgres configuration store trigger creation error : %w", err) } return nil } func buildAddQuery(items map[string]*Item, configTable string) (string, []interface{}, error) { query := "" paramWildcard := make([]string, 0, len(items)) params := make([]interface{}, 0, 4*len(items)) if len(items) == 0 { return query, params, fmt.Errorf("empty list of items") } var queryBuilder strings.Builder queryBuilder.WriteString("INSERT INTO " + configTable + " (KEY, VALUE, VERSION, METADATA) VALUES ") paramPosition := 1 for key, item := range items { paramWildcard = append(paramWildcard, "($"+strconv.Itoa(paramPosition)+", $"+strconv.Itoa(paramPosition+1)+", $"+strconv.Itoa(paramPosition+2)+", $"+strconv.Itoa(paramPosition+3)+")") params = append(params, key, item.Value, item.Version, item.Metadata) paramPosition += 4 } queryBuilder.WriteString(strings.Join(paramWildcard, " , ")) query = queryBuilder.String() return query, params, nil } func (r *PostgresUpdater) AddKey(items map[string]*Item) error { query, params, err := buildAddQuery(items, postgresConfigTable) if err != nil { return err } _, err = r.client.Exec(context.Background(), query, params...) if err != nil { return err } return nil } func (r *PostgresUpdater) UpdateKey(items map[string]*Item) error { if len(items) == 0 { return fmt.Errorf("empty list of items") } for key, item := range items { var params []interface{} query := "UPDATE " + postgresConfigTable + " SET VALUE = $1, VERSION = $2, METADATA = $3 WHERE KEY = $4" params = append(params, item.Value, item.Version, item.Metadata, key) _, err := r.client.Exec(context.Background(), query, params...) if err != nil { return err } } return nil } func init() { p := os.Getenv("PORT") if p != "" && p != "0" { appPort, _ = strconv.Atoi(p) } receivedUpdates = make(map[string][]string) } // indexHandler is the handler for root path func indexHandler(w http.ResponseWriter, r *http.Request) { log.Println("indexHandler is called") w.WriteHeader(http.StatusOK) json.NewEncoder(w).Encode(appResponse{Message: "OK"}) } // sendResponse returns response with status code and message func sendResponse(w http.ResponseWriter, statusCode int, message string) { w.WriteHeader(statusCode) json.NewEncoder(w).Encode(appResponse{Message: message}) } // return key-value pairs as a list of strings func getRedisValuesFromItems(items map[string]*Item) []interface{} { m := make([]interface{}, 0, 2*len(items)+1) for key, item := range items { val := item.Value + separator + item.Version m = append(m, key, val) } return m } func getHTTP(keys []string, endpointType string, configStore string) (string, error) { daprConfigurationURL := daprConfigurationURLStable if endpointType == alpha1Endpoint { daprConfigurationURL = daprConfigurationURLAlpha1 } url := daprConfigurationURL + configStore + buildQueryParams(keys) resp, err := httpClient.Get(url) if err != nil { return "", fmt.Errorf("error getting key-values from config store. err: %w", err) } defer resp.Body.Close() respInBytes, _ := io.ReadAll(resp.Body) return string(respInBytes), nil } func getGRPC(keys []string, endpointType string, configStore string) (string, error) { getConfigGRPC := grpcClient.GetConfiguration if endpointType == alpha1Endpoint { getConfigGRPC = grpcClient.GetConfigurationAlpha1 } res, err := getConfigGRPC(context.Background(), &runtimev1pb.GetConfigurationRequest{ StoreName: configStore, Keys: keys, }) if err != nil { return "", fmt.Errorf("error getting key-values from config store. err: %w", err) } items := res.GetItems() respInBytes, _ := json.Marshal(items) return string(respInBytes), nil } // getKeyValues is the handler for getting key-values from config store func getKeyValues(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) protocol := vars["protocol"] endpointType := vars["endpointType"] configStore := vars["configStore"] var keys []string err := json.NewDecoder(r.Body).Decode(&keys) if err != nil { sendResponse(w, http.StatusBadRequest, err.Error()) return } var response string if protocol == "http" { response, err = getHTTP(keys, endpointType, configStore) } else if protocol == "grpc" { response, err = getGRPC(keys, endpointType, configStore) } else { err = fmt.Errorf("unknown protocol in Get call: %s", protocol) } if err != nil { sendResponse(w, http.StatusInternalServerError, err.Error()) return } sendResponse(w, http.StatusOK, response) } func buildQueryParams(keys []string) string { if len(keys) == 0 { return "" } ret := "?key=" + keys[0] for i := 1; i < len(keys); i++ { ret = ret + "&key=" + keys[i] } return ret } func subscribeGRPC(keys []string, endpointType string, configStore string, component string) (subscriptionID string, err error) { var client runtimev1pb.Dapr_SubscribeConfigurationClient subscribeConfigurationRequest := &runtimev1pb.SubscribeConfigurationRequest{ StoreName: configStore, Keys: keys, } if component == postgresComponent { subscribeConfigurationRequest.Metadata = map[string]string{ "pgNotifyChannel": postgresChannel, } } ctx, cancel := context.WithCancel(context.Background()) if endpointType == alpha1Endpoint { client, err = grpcClient.SubscribeConfigurationAlpha1(ctx, subscribeConfigurationRequest) } else { client, err = grpcClient.SubscribeConfiguration(ctx, subscribeConfigurationRequest) } if err != nil { cancel() return "", fmt.Errorf("error subscribing config updates: %w", err) } res, err := client.Recv() if errors.Is(err, io.EOF) { cancel() return "", fmt.Errorf("error subscribe: stream closed before receiving ID") } if err != nil { cancel() return "", fmt.Errorf("error subscribe: %w", err) } subscriptionID = res.GetId() go subscribeHandlerGRPC(client) log.Printf("App subscribed to config changes with subscription id: %s", subscriptionID) lock.Lock() grpcSubs[subscriptionID] = cancel lock.Unlock() return subscriptionID, nil } func subscribeHandlerGRPC(client runtimev1pb.Dapr_SubscribeConfigurationClient) { for { rsp, err := client.Recv() if errors.Is(err, io.EOF) || rsp == nil { log.Print("Dapr subscribe finished") break } if err != nil { log.Printf("Error receiving config updates: %v", err) break } subscribeID := rsp.GetId() configurationItems := make(map[string]*Item) for key, item := range rsp.GetItems() { configurationItems[key] = &Item{ Value: item.GetValue(), Version: item.GetVersion(), } } receivedItemsInBytes, _ := json.Marshal(configurationItems) receivedItems := string(receivedItemsInBytes) log.Printf("SubscriptionID: %s, Received item: %s", subscribeID, receivedItems) lock.Lock() if receivedUpdates[subscribeID] == nil { receivedUpdates[subscribeID] = make([]string, 10) } receivedUpdates[subscribeID] = append(receivedUpdates[subscribeID], receivedItems) lock.Unlock() } } func subscribeHTTP(keys []string, endpointType string, configStore string, component string) (string, error) { daprConfigurationURL := daprConfigurationURLStable if endpointType == alpha1Endpoint { daprConfigurationURL = daprConfigurationURLAlpha1 } url := daprConfigurationURL + configStore + "/subscribe" + buildQueryParams(keys) if component == postgresComponent { url = url + "&metadata.pgNotifyChannel=" + postgresChannel } resp, err := httpClient.Get(url) if err != nil { return "", fmt.Errorf("error subscribing config updates: %w", err) } defer resp.Body.Close() sub, err := io.ReadAll(resp.Body) if err != nil { return "", fmt.Errorf("error reading subscription Id: %w", err) } var subscriptionID string if !strings.Contains(string(sub), "errorCode") { var subid map[string]interface{} json.Unmarshal(sub, &subid) log.Printf("App subscribed to config changes with subscription id: %s", subid["id"]) subscriptionID = subid["id"].(string) } else { return "", fmt.Errorf("error subscribing to config updates: %s", string(sub)) } return subscriptionID, nil } // startSubscription is the handler for starting a subscription to config store func startSubscription(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) protocol := vars["protocol"] endpointType := vars["endpointType"] configStore := vars["configStore"] component := vars["component"] var keys []string err := json.NewDecoder(r.Body).Decode(&keys) if err != nil { sendResponse(w, http.StatusBadRequest, err.Error()) return } var subscriptionID string if protocol == "http" { subscriptionID, err = subscribeHTTP(keys, endpointType, configStore, component) } else if protocol == "grpc" { subscriptionID, err = subscribeGRPC(keys, endpointType, configStore, component) } else { err = fmt.Errorf("unknown protocol in Subscribe call: %s", protocol) } if err != nil { sendResponse(w, http.StatusInternalServerError, err.Error()) return } sendResponse(w, http.StatusOK, subscriptionID) } func unsubscribeHTTP(subscriptionID string, endpointType string, configStore string) (string, error) { daprConfigurationURL := daprConfigurationURLStable if endpointType == alpha1Endpoint { daprConfigurationURL = daprConfigurationURLAlpha1 } url := daprConfigurationURL + configStore + "/" + subscriptionID + "/unsubscribe" resp, err := httpClient.Get(url) if err != nil { return "", fmt.Errorf("error unsubscribing config updates: %w", err) } defer resp.Body.Close() respInBytes, _ := io.ReadAll(resp.Body) var unsubscribeResp UnsubscribeConfigurationResponse err = json.Unmarshal(respInBytes, &unsubscribeResp) if err != nil { return "", fmt.Errorf("error unmarshalling unsubscribe response: %s", err.Error()) } if !unsubscribeResp.Ok { return "", fmt.Errorf("error subscriptionID not found: %s", unsubscribeResp.Message) } return string(respInBytes), nil } func unsubscribeGRPC(subscriptionID string) error { lock.Lock() cancel := grpcSubs[subscriptionID] delete(grpcSubs, subscriptionID) lock.Unlock() if cancel == nil { return errors.New("error subscriptionID not found") } cancel() return nil } // stopSubscription is the handler for unsubscribing from config store func stopSubscription(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) subscriptionID := vars["subscriptionID"] protocol := vars["protocol"] endpointType := vars["endpointType"] configStore := vars["configStore"] response := "OK" var err error if protocol == "http" { response, err = unsubscribeHTTP(subscriptionID, endpointType, configStore) } else if protocol == "grpc" { err = unsubscribeGRPC(subscriptionID) } else { err = fmt.Errorf("unknown protocol in unsubscribe call: %s", protocol) } if err != nil { sendResponse(w, http.StatusInternalServerError, err.Error()) return } sendResponse(w, http.StatusOK, response) } // configurationUpdateHandler is the handler for receiving updates from config store func configurationUpdateHandler(w http.ResponseWriter, r *http.Request) { var updateEvent UpdateEvent err := json.NewDecoder(r.Body).Decode(&updateEvent) if err != nil { sendResponse(w, http.StatusBadRequest, err.Error()) return } subID := updateEvent.ID receivedItemsInBytes, _ := json.Marshal(updateEvent.Items) receivedItems := string(receivedItemsInBytes) log.Printf("SubscriptionID: %s, Received item: %s", subID, receivedItems) lock.Lock() defer lock.Unlock() if receivedUpdates[subID] == nil { receivedUpdates[subID] = make([]string, 10) } receivedUpdates[subID] = append(receivedUpdates[subID], receivedItems) sendResponse(w, http.StatusOK, "OK") } // getReceivedUpdates is the handler for getting received updates from config store func getReceivedUpdates(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) subID := vars["subscriptionID"] lock.Lock() defer lock.Unlock() response := receivedMessagesResponse{ ReceivedUpdates: receivedUpdates[subID], } receivedUpdates[subID] = make([]string, 10) w.WriteHeader(http.StatusOK) json.NewEncoder(w).Encode(response) } // initializeUpdater is the handler for initializing config updater func initializeUpdater(w http.ResponseWriter, r *http.Request) { var component string err := json.NewDecoder(r.Body).Decode(&component) if err != nil { sendResponse(w, http.StatusBadRequest, err.Error()) return } log.Printf("Initializing updater with component: %s\n", component) switch component { case redisComponent: updater = &RedisUpdater{} err := updater.Init() if err != nil { sendResponse(w, http.StatusInternalServerError, err.Error()) return } case postgresComponent: updater = &PostgresUpdater{} err := updater.Init() if err != nil { sendResponse(w, http.StatusInternalServerError, err.Error()) return } default: sendResponse(w, http.StatusBadRequest, "Invalid component:"+component+".Allowed values are 'redis' and 'postgres'") return } sendResponse(w, http.StatusOK, "OK") } // updateKeyValues is the handler for updating key values in the config store func updateKeyValues(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) operation := vars["operation"] items := make(map[string]*Item, 10) err := json.NewDecoder(r.Body).Decode(&items) if err != nil { sendResponse(w, http.StatusBadRequest, err.Error()) return } switch operation { case "add": err = updater.AddKey(items) case "update": err = updater.UpdateKey(items) default: err = fmt.Errorf("unknown operation: %s", operation) } if err != nil { sendResponse(w, http.StatusBadRequest, err.Error()) return } sendResponse(w, http.StatusOK, "OK") } // appRouter initializes restful api router func appRouter() http.Handler { router := mux.NewRouter().StrictSlash(true) // Log requests and their processing time router.Use(utils.LoggerMiddleware) router.HandleFunc("/", indexHandler).Methods("GET") router.HandleFunc("/initialize-updater", initializeUpdater).Methods("POST") router.HandleFunc("/get-key-values/{protocol}/{endpointType}/{configStore}", getKeyValues).Methods("POST") router.HandleFunc("/subscribe/{protocol}/{endpointType}/{configStore}/{component}", startSubscription).Methods("POST") router.HandleFunc("/unsubscribe/{subscriptionID}/{protocol}/{endpointType}/{configStore}", stopSubscription).Methods("GET") router.HandleFunc("/configuration/{storeName}/{key}", configurationUpdateHandler).Methods("POST") router.HandleFunc("/get-received-updates/{subscriptionID}", getReceivedUpdates).Methods("GET") router.HandleFunc("/update-key-values/{operation}", updateKeyValues).Methods("POST") router.Use(mux.CORSMethodMiddleware(router)) return router } func main() { grpcClient = utils.GetGRPCClient(daprGRPCPort) log.Printf("Starting application on http://localhost:%d", appPort) utils.StartServer(appPort, appRouter, true, false) }
mikeee/dapr
tests/apps/configurationapp/app.go
GO
mit
20,932
# In e2e test, this will not be used to deploy the app to test cluster. # This is created for testing purpose in order to deploy this app using kubectl # before writing e2e test. kind: Service apiVersion: v1 metadata: name: configurationapp labels: testapp: configurationapp spec: selector: testapp: configurationapp ports: - protocol: TCP port: 80 targetPort: 3000 type: LoadBalancer --- apiVersion: apps/v1 kind: Deployment metadata: name: configurationapp labels: testapp: configurationapp spec: replicas: 1 selector: matchLabels: testapp: configurationapp template: metadata: labels: testapp: configurationapp annotations: dapr.io/enabled: "true" dapr.io/app-id: "configurationapp" dapr.io/app-port: "3000" spec: containers: - name: configurationapp image: dapriotest/e2e-hellodapr ports: - containerPort: 3000 imagePullPolicy: Always
mikeee/dapr
tests/apps/configurationapp/service.yaml
YAML
mit
989
# # Copyright 2024 The Dapr Authors # Licensed 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. # FROM golang:1.22.3 as build_env ENV CGO_ENABLED=0 WORKDIR /app # Copy go.mod and go.sum first for better caching COPY go.mod go.sum /app/ RUN go mod download # Copy source COPY *.go /app/ RUN go build -o app . FROM gcr.io/distroless/base-nossl:nonroot WORKDIR / COPY --from=build_env /app/app / CMD ["/app"]
mikeee/dapr
tests/apps/crypto/Dockerfile
Dockerfile
mit
891
/* Copyright 2023 The Dapr Authors Licensed 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 main import ( "bytes" "context" "encoding/json" "fmt" "io" "log" "net" "net/http" "strconv" "time" "github.com/go-chi/chi/v5" "golang.org/x/exp/slices" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/proto" daprClientSDK "github.com/dapr/go-sdk/client" runtimev1pb "github.com/dapr/go-sdk/dapr/proto/runtime/v1" ) var ( appPort, daprGRPCPort, daprHTTPPort int sdkClient daprClientSDK.Client httpClient = NewHTTPClient() ) type resettableProto interface { proto.Message Reset() } // Handles HTTP tests func httpTestRouter(r chi.Router) { // POST /test/http/{component}/encrypt?key={key}&alg={alg} r.Post("/encrypt", func(w http.ResponseWriter, r *http.Request) { u := fmt.Sprintf("http://localhost:%v/v1.0-alpha1/crypto/%s/encrypt", daprHTTPPort, chi.URLParam(r, "component")) req, err := http.NewRequestWithContext(r.Context(), http.MethodPut, u, r.Body) if err != nil { http.Error(w, fmt.Sprintf("error creating request: %v", err), http.StatusInternalServerError) return } req.Header.Set("dapr-key-name", r.URL.Query().Get("key")) req.Header.Set("dapr-key-wrap-algorithm", r.URL.Query().Get("alg")) res, err := httpClient.Do(req) if err != nil { http.Error(w, fmt.Sprintf("error sending request: %v", err), http.StatusInternalServerError) return } defer res.Body.Close() if res.StatusCode != http.StatusOK { http.Error(w, fmt.Sprintf("invalid status code: %v", res.StatusCode), http.StatusInternalServerError) return } n, err := io.Copy(w, res.Body) log.Printf("Encrypted %d bytes. Error: %v", n, err) }) // POST /test/http/{component}/decrypt r.Post("/decrypt", func(w http.ResponseWriter, r *http.Request) { u := fmt.Sprintf("http://localhost:%v/v1.0-alpha1/crypto/%s/decrypt", daprHTTPPort, chi.URLParam(r, "component")) req, err := http.NewRequestWithContext(r.Context(), http.MethodPut, u, r.Body) if err != nil { http.Error(w, fmt.Sprintf("error creating request: %v", err), http.StatusInternalServerError) return } res, err := httpClient.Do(req) if err != nil { http.Error(w, fmt.Sprintf("error sending request: %v", err), http.StatusInternalServerError) return } defer res.Body.Close() if res.StatusCode != http.StatusOK { http.Error(w, fmt.Sprintf("invalid status code: %v", res.StatusCode), http.StatusInternalServerError) return } n, err := io.Copy(w, res.Body) log.Printf("Decrypted %d bytes. Error: %v", n, err) }) } // Handles gRPC tests func grpcTestRouter(r chi.Router) { // POST /test/grpc/{component}/encrypt?key={key}&alg={alg} r.Post("/encrypt", func(w http.ResponseWriter, r *http.Request) { enc, err := sdkClient.Encrypt(r.Context(), r.Body, daprClientSDK.EncryptOptions{ ComponentName: chi.URLParam(r, "component"), KeyName: r.URL.Query().Get("key"), KeyWrapAlgorithm: r.URL.Query().Get("alg"), }) if err != nil { http.Error(w, fmt.Sprintf("error encrypting data: %v", err), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) n, err := io.Copy(w, enc) log.Printf("Encrypted %d bytes. Error: %v", n, err) }) // POST /test/grpc/{component}/decrypt r.Post("/decrypt", func(w http.ResponseWriter, r *http.Request) { dec, err := sdkClient.Decrypt(r.Context(), r.Body, daprClientSDK.DecryptOptions{ ComponentName: chi.URLParam(r, "component"), }) if err != nil { http.Error(w, fmt.Sprintf("error decrypting data: %v", err), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) n, err := io.Copy(w, dec) log.Printf("Decrypted %d bytes. Error: %v", n, err) }) } func grpcSubtleTestRouter(r chi.Router) { grpcClient := sdkClient.GrpcClient() // POST /test/subtle/grpc/getkey r.Post("/getkey", subtleOpGRPC(grpcClient, &runtimev1pb.SubtleGetKeyRequest{}, grpcClient.SubtleGetKeyAlpha1)) // POST /test/subtle/grpc/encrypt r.Post("/encrypt", subtleOpGRPC(grpcClient, &runtimev1pb.SubtleEncryptRequest{}, grpcClient.SubtleEncryptAlpha1)) // POST /test/subtle/grpc/decrypt r.Post("/decrypt", subtleOpGRPC(grpcClient, &runtimev1pb.SubtleDecryptRequest{}, grpcClient.SubtleDecryptAlpha1)) // POST /test/subtle/grpc/wrapkey r.Post("/wrapkey", subtleOpGRPC(grpcClient, &runtimev1pb.SubtleWrapKeyRequest{}, grpcClient.SubtleWrapKeyAlpha1)) // POST /test/subtle/grpc/unwrapkey r.Post("/unwrapkey", subtleOpGRPC(grpcClient, &runtimev1pb.SubtleUnwrapKeyRequest{}, grpcClient.SubtleUnwrapKeyAlpha1)) // POST /test/subtle/grpc/sign r.Post("/sign", subtleOpGRPC(grpcClient, &runtimev1pb.SubtleSignRequest{}, grpcClient.SubtleSignAlpha1)) // POST /test/subtle/grpc/verify r.Post("/verify", subtleOpGRPC(grpcClient, &runtimev1pb.SubtleVerifyRequest{}, grpcClient.SubtleVerifyAlpha1)) } func httpSubtleTestRouter(r chi.Router) { // POST /test/subtle/http/getkey r.Post("/getkey", subtleOpHTTP("getkey", &runtimev1pb.SubtleGetKeyRequest{}, &runtimev1pb.SubtleGetKeyResponse{})) // POST /test/subtle/http/encrypt r.Post("/encrypt", subtleOpHTTP("encrypt", &runtimev1pb.SubtleEncryptRequest{}, &runtimev1pb.SubtleEncryptResponse{})) // POST /test/subtle/http/decrypt r.Post("/decrypt", subtleOpHTTP("decrypt", &runtimev1pb.SubtleDecryptRequest{}, &runtimev1pb.SubtleDecryptResponse{})) // POST /test/subtle/http/wrapkey r.Post("/wrapkey", subtleOpHTTP("wrapkey", &runtimev1pb.SubtleWrapKeyRequest{}, &runtimev1pb.SubtleWrapKeyResponse{})) // POST /test/subtle/http/unwrapkey r.Post("/unwrapkey", subtleOpHTTP("unwrapkey", &runtimev1pb.SubtleUnwrapKeyRequest{}, &runtimev1pb.SubtleUnwrapKeyResponse{})) // POST /test/subtle/http/sign r.Post("/sign", subtleOpHTTP("sign", &runtimev1pb.SubtleSignRequest{}, &runtimev1pb.SubtleSignResponse{})) // POST /test/subtle/http/verify r.Post("/verify", subtleOpHTTP("verify", &runtimev1pb.SubtleVerifyRequest{}, &runtimev1pb.SubtleVerifyResponse{})) } // Note: these methods are not thread-safe func subtleOpGRPC[ Req resettableProto, Res proto.Message, ]( grpcClient runtimev1pb.DaprClient, req Req, fn func(ctx context.Context, req Req, opts ...grpc.CallOption) (Res, error), ) func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) { req.Reset() reqData, err := io.ReadAll(r.Body) if err != nil { http.Error(w, fmt.Sprintf("error reading body: %v", err), http.StatusInternalServerError) return } err = protojson.Unmarshal(reqData, req) if err != nil { http.Error(w, fmt.Sprintf("failed to unmarshal request data with protojson: %v", err), http.StatusInternalServerError) return } res, err := fn(r.Context(), req) if err != nil { http.Error(w, fmt.Sprintf("error performing operation: %v", err), http.StatusInternalServerError) return } resData, err := protojson.Marshal(res) if err != nil { http.Error(w, fmt.Sprintf("failed marshal response data with protojson: %v", err), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) w.Write(resData) } } type subtlecryptoReq interface { SetComponentName(name string) GetComponentName() string resettableProto } // Note: these methods are not thread-safe func subtleOpHTTP[ Req subtlecryptoReq, Res resettableProto, ]( method string, req Req, res Res, ) func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) { req.Reset() res.Reset() reqData, err := io.ReadAll(r.Body) if err != nil { http.Error(w, fmt.Sprintf("error reading body: %v", err), http.StatusInternalServerError) return } err = protojson.Unmarshal(reqData, req) if err != nil { http.Error(w, fmt.Sprintf("failed to unmarshal request data with protojson: %v", err), http.StatusInternalServerError) return } u := fmt.Sprintf("http://localhost:%v/v1.0-alpha1/subtlecrypto/%s/%s", daprHTTPPort, req.GetComponentName(), method) res, err := httpClient.Post(u, "application/json", bytes.NewReader(reqData)) if err != nil { http.Error(w, fmt.Sprintf("error performing operation: %v", err), http.StatusInternalServerError) return } defer res.Body.Close() if res.StatusCode != http.StatusOK { http.Error(w, fmt.Sprintf("invalid response status code: %d", res.StatusCode), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) io.Copy(w, res.Body) } } type metadataResponse struct { EnabledFeatures []string `json:"enabledFeatures"` } // TODO: Remove this handler when SubtleCrypto is finalized func handleSubtleCryptoEnabled(w http.ResponseWriter, r *http.Request) { var metadata metadataResponse res, err := httpClient.Get(fmt.Sprintf("http://localhost:%v/v1.0/metadata", daprHTTPPort)) if err != nil { http.Error(w, fmt.Sprintf("could not get sidecar metadata: %v", err), http.StatusInternalServerError) return } defer res.Body.Close() if res.StatusCode != http.StatusOK { http.Error(w, fmt.Sprintf("invalid response status code from metadata endpoint: %d", res.StatusCode), http.StatusInternalServerError) return } err = json.NewDecoder(res.Body).Decode(&metadata) if err != nil { http.Error(w, fmt.Sprintf("could not get sidecar metadata from JSON: %v", err), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) if len(metadata.EnabledFeatures) > 0 && slices.Contains(metadata.EnabledFeatures, "_SubtleCrypto") { fmt.Fprint(w, "1") } else { fmt.Fprint(w, "0") } } // appRouter initializes restful api router func appRouter() http.Handler { router := chi.NewRouter() // Log requests and their processing time router.Use(LoggerMiddleware) // Handler for / which returns a "hello world" like message router.Get("/", func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) fmt.Fprint(w, "👋") }) // Handler for /getSubtleCryptoEnabled that returns whether subtle crypto APIs are enabled router.Get("/getSubtleCryptoEnabled", handleSubtleCryptoEnabled) // Run tests router.Route("/test/grpc/{component}", grpcTestRouter) router.Route("/test/http/{component}", httpTestRouter) router.Route("/test/subtle/grpc", grpcSubtleTestRouter) router.Route("/test/subtle/http", httpSubtleTestRouter) return router } func main() { // Ports appPort = PortFromEnv("APP_PORT", 3000) daprGRPCPort = PortFromEnv("DAPR_GRPC_PORT", 50001) daprHTTPPort = PortFromEnv("DAPR_HTTP_PORT", 3500) log.Printf("Dapr ports: gRPC: %d, HTTP: %d", daprGRPCPort, daprHTTPPort) // Connect to gRPC ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) conn, err := grpc.DialContext( ctx, net.JoinHostPort("127.0.0.1", strconv.Itoa(daprGRPCPort)), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock(), ) cancel() if err != nil { log.Fatalf("Error connecting to Dapr's gRPC endpoint on port %d: %v", daprGRPCPort, err) } // Create a Dapr SDK client sdkClient = daprClientSDK.NewClientWithConnection(conn) // Start the server log.Printf("Starting application on http://localhost:%d", appPort) StartServer(appPort, appRouter) }
mikeee/dapr
tests/apps/crypto/app.go
GO
mit
11,745
module github.com/dapr/dapr/tests/apps/crypto go 1.22.3 require ( github.com/dapr/go-sdk v1.8.0 github.com/go-chi/chi/v5 v5.0.10 github.com/google/uuid v1.5.0 golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 google.golang.org/grpc v1.55.0 google.golang.org/protobuf v1.30.0 ) require ( github.com/golang/protobuf v1.5.3 // indirect github.com/kr/pretty v0.3.1 // indirect golang.org/x/net v0.10.0 // indirect golang.org/x/sys v0.8.0 // indirect golang.org/x/text v0.9.0 // indirect google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect )
mikeee/dapr
tests/apps/crypto/go.mod
mod
mit
613
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/dapr/go-sdk v1.8.0 h1:OEleeL3zUTqXxIZ7Vkk3PClAeCh1g8sZ1yR2JFZKfXM= github.com/dapr/go-sdk v1.8.0/go.mod h1:MBcTKXg8PmBc8A968tVWQg1Xt+DZtmeVR6zVVVGcmeA= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-chi/chi/v5 v5.0.10 h1:rLz5avzKpjqxrYwXNfmjkrYYXOyLJd37pz53UFHC6vk= github.com/go-chi/chi/v5 v5.0.10/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc= golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= google.golang.org/grpc v1.55.0 h1:3Oj82/tFSCeUrRTg/5E/7d/W5A1tj6Ky1ABAuZuv5ag= google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGONTY8= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
mikeee/dapr
tests/apps/crypto/go.sum
sum
mit
4,212
/* Copyright 2024 The Dapr Authors Licensed 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 main import ( "context" "fmt" "log" "net" "net/http" "os" "os/signal" "strconv" "syscall" "time" "github.com/google/uuid" ) /** This file contains code from tests/e2e/utils (with some simplifications). It is copied here otherwise we'd have to import dapr/dapr in the Docker container, causing a number of issues. */ // NewHTTPClient returns a HTTP client configured func NewHTTPClient() *http.Client { dialer := &net.Dialer{ //nolint:exhaustivestruct Timeout: 5 * time.Second, } netTransport := &http.Transport{ //nolint:exhaustivestruct DialContext: dialer.DialContext, TLSHandshakeTimeout: 5 * time.Second, } return &http.Client{ //nolint:exhaustivestruct Timeout: 30 * time.Second, Transport: netTransport, } } // PortFromEnv returns a port from an env var, or the default value. func PortFromEnv(envName string, defaultPort int) (res int) { p := os.Getenv(envName) if p != "" && p != "0" { res, _ = strconv.Atoi(p) } if res <= 0 { res = defaultPort } return } // StartServer starts a HTTP or HTTP2 server func StartServer(port int, appRouter func() http.Handler) { // Create a listener addr := fmt.Sprintf(":%d", port) ln, err := net.Listen("tcp", addr) if err != nil { log.Fatalf("Failed to create listener: %v", err) } //nolint:gosec server := &http.Server{ Addr: addr, Handler: appRouter(), } // Stop the server when we get a termination signal stopCh := make(chan os.Signal, 1) signal.Notify(stopCh, syscall.SIGKILL, syscall.SIGTERM, syscall.SIGINT) //nolint:staticcheck go func() { // Wait for cancelation signal <-stopCh log.Println("Shutdown signal received") ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second) defer cancel() server.Shutdown(ctx) }() // Blocking call if server.Serve(ln) != http.ErrServerClosed { log.Fatalf("Failed to run server: %v", err) } log.Println("Server shut down") } // LoggerMiddleware returns a middleware for gorilla/mux that logs all requests and processing times func LoggerMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // Check if we have a request ID or generate one reqID := r.URL.Query().Get("reqid") if reqID == "" { reqID = r.Header.Get("x-daprtest-reqid") } if reqID == "" { reqID = "m-" + uuid.New().String() } ctx := context.WithValue(r.Context(), "reqid", reqID) //nolint:staticcheck log.Printf("Received request %s %s (source=%s, reqID=%s)", r.Method, r.URL.Path, r.RemoteAddr, reqID) // Process the request start := time.Now() next.ServeHTTP(w, r.WithContext(ctx)) log.Printf("Request %s: completed in %s", reqID, time.Since(start)) }) }
mikeee/dapr
tests/apps/crypto/utils.go
GO
mit
3,287
../utils/*.go ../../../dapr/proto/runtime/v1/*.proto ../../../dapr/proto/common/v1/*.proto
mikeee/dapr
tests/apps/healthapp/.cache-include
none
mit
90
/* Copyright 2022 The Dapr Authors Licensed 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 main import ( "context" "encoding/json" "errors" "fmt" "io" "log" "net" "net/http" "os" "os/signal" "strconv" "strings" "sync" "syscall" "time" "github.com/gorilla/mux" "golang.org/x/net/http2" "golang.org/x/net/http2/h2c" "google.golang.org/grpc" "google.golang.org/protobuf/types/known/anypb" "google.golang.org/protobuf/types/known/emptypb" commonv1pb "github.com/dapr/dapr/pkg/proto/common/v1" runtimev1pb "github.com/dapr/dapr/pkg/proto/runtime/v1" "github.com/dapr/dapr/tests/apps/utils" "github.com/dapr/kit/ptr" ) var ( appPort string appProtocol string controlPort string daprPort string healthCheckPlan *healthCheck lastInputBinding = newCountAndLast() lastTopicMessage = newCountAndLast() lastHealthCheck = newCountAndLast() ready chan struct{} httpClient = utils.NewHTTPClient() ) const ( invokeURL = "http://localhost:%s/v1.0/invoke/%s/method/%s" publishURL = "http://localhost:%s/v1.0/publish/inmemorypubsub/mytopic" ) func main() { ready = make(chan struct{}) healthCheckPlan = newHealthCheck() appPort = os.Getenv("APP_PORT") if appPort == "" { appPort = "4000" } appProtocol = os.Getenv("APP_PROTOCOL") expectAppProtocol := os.Getenv("EXPECT_APP_PROTOCOL") if expectAppProtocol != "" && appProtocol != expectAppProtocol { log.Fatalf("Expected injected APP_PROTOCOL to be %q, but got %q", expectAppProtocol, appProtocol) } controlPort = os.Getenv("CONTROL_PORT") if controlPort == "" { controlPort = "3000" } daprPort = os.Getenv("DAPR_HTTP_PORT") // Start the control server go startControlServer() // Publish messages in background ctx, cancel := context.WithCancel(context.Background()) go func() { <-ready startPublishing(ctx) }() switch appProtocol { case "grpc": log.Println("using gRPC") // Blocking call startGRPC() case "http": log.Println("using HTTP") // Blocking call startHTTP() case "h2c": log.Println("using H2C") // Blocking call startH2C() } cancel() } func startGRPC() { lis, err := net.Listen("tcp", "0.0.0.0:"+appPort) if err != nil { log.Fatalf("failed to listen: %v", err) } h := &grpcServer{} s := grpc.NewServer() runtimev1pb.RegisterAppCallbackServer(s, h) runtimev1pb.RegisterAppCallbackHealthCheckServer(s, h) // Stop the gRPC server when we get a termination signal stopCh := make(chan os.Signal, 1) signal.Notify(stopCh, syscall.SIGTERM, os.Interrupt) go func() { // Wait for cancelation signal <-stopCh log.Println("Shutdown signal received") s.GracefulStop() }() // Blocking call log.Printf("Health App GRPC server listening on :%s", appPort) if err := s.Serve(lis); err != nil { log.Fatalf("Failed to start gRPC server: %v", err) } log.Println("App shut down") } type countAndLast struct { count int64 lastTime time.Time lock *sync.Mutex } func newCountAndLast() *countAndLast { return &countAndLast{ lock: &sync.Mutex{}, } } func (c *countAndLast) Record() { c.lock.Lock() defer c.lock.Unlock() c.count++ c.lastTime = time.Now() } func (c *countAndLast) MarshalJSON() ([]byte, error) { obj := struct { // Total number of actions Count int64 `json:"count"` // Time since last action, in ms Last *int64 `json:"last"` }{ Count: c.count, } if c.lastTime.Unix() > 0 { obj.Last = ptr.Of(time.Now().Sub(c.lastTime).Milliseconds()) } return json.Marshal(obj) } func startControlServer() { // Wait until the first health probe log.Print("Waiting for signal to start control server…") <-ready port, _ := strconv.Atoi(controlPort) log.Printf("Health App control server listening on http://:%d", port) utils.StartServer(port, func() http.Handler { r := mux.NewRouter().StrictSlash(true) // Log requests and their processing time r.Use(utils.LoggerMiddleware) // Hello world r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) w.Write([]byte("⚙️")) }).Methods("GET") // Get last input binding r.HandleFunc("/last-input-binding", func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) j, _ := json.Marshal(lastInputBinding) w.Write(j) }).Methods("GET") // Get last topic message r.HandleFunc("/last-topic-message", func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) j, _ := json.Marshal(lastTopicMessage) w.Write(j) }).Methods("GET") // Get last health check r.HandleFunc("/last-health-check", func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) j, _ := json.Marshal(lastHealthCheck) w.Write(j) }).Methods("GET") // Performs a service invocation r.HandleFunc("/invoke/{name}/{method}", func(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) u := fmt.Sprintf(invokeURL, daprPort, vars["name"], vars["method"]) log.Println("Invoking URL", u) res, err := httpClient.Post(u, r.Header.Get("content-type"), r.Body) if err != nil { w.WriteHeader(http.StatusInternalServerError) w.Write([]byte("Failed to invoke method: " + err.Error())) return } defer res.Body.Close() w.WriteHeader(res.StatusCode) io.Copy(w, res.Body) }).Methods("POST") // Update the plan r.HandleFunc("/set-plan", func(w http.ResponseWriter, r *http.Request) { ct := r.Header.Get("content-type") if ct != "application/json" && !strings.HasPrefix(ct, "application/json;") { w.WriteHeader(http.StatusBadRequest) w.Write([]byte("Invalid content type")) return } plan := []bool{} err := json.NewDecoder(r.Body).Decode(&plan) if err != nil { w.WriteHeader(http.StatusBadRequest) w.Write([]byte("Failed to parse body: " + err.Error())) return } healthCheckPlan.SetPlan(plan) w.WriteHeader(http.StatusNoContent) }).Methods("POST", "PUT") return r }, false, false) } func startPublishing(ctx context.Context) { t := time.NewTicker(time.Second) var i int for { select { case <-ctx.Done(): log.Println("Context done; stop publishing") case <-t.C: i++ publishMessage(i) } } } func publishMessage(count int) { u := fmt.Sprintf(publishURL, daprPort) log.Println("Invoking URL", u) body := fmt.Sprintf(`{"orderId": "%d"}`, count) res, err := httpClient.Post(u, "application/json", strings.NewReader(body)) if err != nil { log.Printf("Failed to publish message. Error: %v", err) return } // Drain before closing _, _ = io.Copy(io.Discard, res.Body) res.Body.Close() } func startHTTP() { port, _ := strconv.Atoi(appPort) log.Printf("Health App HTTP server listening on http://:%d", port) utils.StartServer(port, httpRouter, true, false) } func startH2C() { log.Printf("Health App HTTP/2 Cleartext server listening on http://:%s", appPort) h2s := &http2.Server{} srv := &http.Server{ Addr: ":" + appPort, Handler: h2c.NewHandler(httpRouter(), h2s), ReadHeaderTimeout: 30 * time.Second, } // Stop the server when we get a termination signal stopCh := make(chan os.Signal, 1) signal.Notify(stopCh, syscall.SIGKILL, syscall.SIGTERM, syscall.SIGINT) //nolint:staticcheck go func() { // Wait for cancelation signal <-stopCh log.Println("Shutdown signal received") ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second) defer cancel() srv.Shutdown(ctx) }() // Blocking call err := srv.ListenAndServe() if err != http.ErrServerClosed { log.Fatalf("Failed to run server: %v", err) } log.Println("Server shut down") } func httpRouter() http.Handler { r := mux.NewRouter().StrictSlash(true) // Log requests and their processing time r.Use(utils.LoggerMiddleware) r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) w.Write([]byte("👋")) }).Methods("GET") r.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) { if ready != nil { close(ready) ready = nil } lastHealthCheck.Record() err := healthCheckPlan.Do() if err != nil { w.WriteHeader(http.StatusInternalServerError) w.Write([]byte(err.Error())) return } w.WriteHeader(http.StatusNoContent) }).Methods("GET") r.HandleFunc("/schedule", func(w http.ResponseWriter, r *http.Request) { log.Println("Received scheduled message") lastInputBinding.Record() w.WriteHeader(http.StatusOK) }).Methods("POST") r.HandleFunc("/mytopic", func(w http.ResponseWriter, r *http.Request) { log.Println("Received message on /mytopic topic") lastTopicMessage.Record() w.WriteHeader(http.StatusOK) }).Methods("POST") r.HandleFunc("/foo", func(w http.ResponseWriter, r *http.Request) { log.Println("Received foo request") w.WriteHeader(http.StatusOK) w.Write([]byte("🤗")) }).Methods("POST") r.HandleFunc("/dapr/subscribe", func(w http.ResponseWriter, r *http.Request) { log.Println("Received /dapr/subscribe request") w.WriteHeader(http.StatusOK) json.NewEncoder(w).Encode([]subscription{ { PubsubName: "inmemorypubsub", Topic: "mytopic", Route: "/mytopic", Metadata: map[string]string{}, }, }) }).Methods("GET") return r } type subscription struct { PubsubName string `json:"pubsubname"` Topic string `json:"topic"` Route string `json:"route"` Metadata map[string]string `json:"metadata"` } // Server for gRPC type grpcServer struct{} func (s *grpcServer) HealthCheck(ctx context.Context, _ *emptypb.Empty) (*runtimev1pb.HealthCheckResponse, error) { if ready != nil { close(ready) ready = nil } lastHealthCheck.Record() err := healthCheckPlan.Do() if err != nil { return nil, err } return &runtimev1pb.HealthCheckResponse{}, nil } func (s *grpcServer) OnInvoke(_ context.Context, in *commonv1pb.InvokeRequest) (*commonv1pb.InvokeResponse, error) { if in.GetMethod() == "foo" { log.Println("Received method invocation: " + in.GetMethod()) return &commonv1pb.InvokeResponse{ Data: &anypb.Any{ Value: []byte("🤗"), }, }, nil } return nil, errors.New("unexpected method invocation: " + in.GetMethod()) } func (s *grpcServer) ListTopicSubscriptions(_ context.Context, in *emptypb.Empty) (*runtimev1pb.ListTopicSubscriptionsResponse, error) { return &runtimev1pb.ListTopicSubscriptionsResponse{ Subscriptions: []*runtimev1pb.TopicSubscription{ { PubsubName: "inmemorypubsub", Topic: "mytopic", }, }, }, nil } func (s *grpcServer) OnTopicEvent(_ context.Context, in *runtimev1pb.TopicEventRequest) (*runtimev1pb.TopicEventResponse, error) { if in.GetTopic() == "mytopic" { log.Println("Received topic event: " + in.GetTopic()) lastTopicMessage.Record() return &runtimev1pb.TopicEventResponse{}, nil } return nil, errors.New("unexpected topic event: " + in.GetTopic()) } func (s *grpcServer) ListInputBindings(_ context.Context, in *emptypb.Empty) (*runtimev1pb.ListInputBindingsResponse, error) { return &runtimev1pb.ListInputBindingsResponse{ Bindings: []string{"schedule"}, }, nil } func (s *grpcServer) OnBindingEvent(_ context.Context, in *runtimev1pb.BindingEventRequest) (*runtimev1pb.BindingEventResponse, error) { if in.GetName() == "schedule" { log.Println("Received binding event: " + in.GetName()) lastInputBinding.Record() return &runtimev1pb.BindingEventResponse{}, nil } return nil, errors.New("unexpected binding event: " + in.GetName()) } type healthCheck struct { plan []bool count int lock *sync.Mutex } func newHealthCheck() *healthCheck { return &healthCheck{ lock: &sync.Mutex{}, } } func (h *healthCheck) SetPlan(plan []bool) { h.lock.Lock() defer h.lock.Unlock() // Set the new plan and reset the counter h.plan = plan h.count = 0 } func (h *healthCheck) Do() error { h.lock.Lock() defer h.lock.Unlock() success := true if h.count < len(h.plan) { success = h.plan[h.count] h.count++ } if success { log.Println("Responding to health check request with success") return nil } log.Println("Responding to health check request with failure") return errors.New("simulated failure") }
mikeee/dapr
tests/apps/healthapp/app.go
GO
mit
12,693
#!/bin/sh # Use this script to run the app manually LOG_LEVEL=${1:-"debug"} export APP_PORT=6009 #export APP_PROTOCOL=http export APP_PROTOCOL=grpc ~/.dapr/bin/daprd \ --app-id healthcheck \ --dapr-http-port 3602 \ --dapr-grpc-port 6602 \ --metrics-port 9090 \ --app-port $APP_PORT \ --app-protocol $APP_PROTOCOL \ --components-path ./components \ --enable-app-health-check=true \ --app-health-check-path=/healthz \ --app-health-probe-interval=15 \ --log-level "$LOG_LEVEL"
mikeee/dapr
tests/apps/healthapp/run-daprd.sh
Shell
mit
521
#!/bin/sh # Use this script to run the app manually export APP_PORT=6009 #export APP_PROTOCOL=http export APP_PROTOCOL=grpc go run .
mikeee/dapr
tests/apps/healthapp/run-manually.sh
Shell
mit
136
../utils/*.go
mikeee/dapr
tests/apps/hellodapr/.cache-include
none
mit
13
/* Copyright 2021 The Dapr Authors Licensed 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 main import ( "encoding/json" "fmt" "log" "net/http" "os" "strconv" "time" "github.com/gorilla/mux" "github.com/dapr/dapr/tests/apps/utils" ) var appPort = 3000 func init() { p := os.Getenv("PORT") if p != "" && p != "0" { appPort, _ = strconv.Atoi(p) } } type testCommandRequest struct { Message string `json:"message,omitempty"` } type appResponse struct { Message string `json:"message,omitempty"` StartTime int `json:"start_time,omitempty"` EndTime int `json:"end_time,omitempty"` } // indexHandler is the handler for root path func indexHandler(w http.ResponseWriter, r *http.Request) { log.Println("indexHandler is called") w.WriteHeader(http.StatusOK) json.NewEncoder(w).Encode(appResponse{Message: "OK"}) } // testHandler is the handler for end-to-end test entry point // test driver code call this endpoint to trigger the test func testHandler(w http.ResponseWriter, r *http.Request) { testCommand := mux.Vars(r)["test"] // Retrieve request body contents var commandBody testCommandRequest err := json.NewDecoder(r.Body).Decode(&commandBody) if err != nil { w.WriteHeader(http.StatusBadRequest) json.NewEncoder(w).Encode(appResponse{ Message: err.Error(), }) return } // Trigger the test res := appResponse{Message: fmt.Sprintf("%s is not supported", testCommand)} statusCode := http.StatusBadRequest startTime := epoch() switch testCommand { case "blue": statusCode, res = blueTest(commandBody) case "green": statusCode, res = greenTest(commandBody) case "envTest": statusCode, res = envTest(commandBody) } res.StartTime = startTime res.EndTime = epoch() w.WriteHeader(statusCode) json.NewEncoder(w).Encode(res) } func greenTest(commandRequest testCommandRequest) (int, appResponse) { log.Printf("GreenTest - message: %s", commandRequest.Message) return http.StatusOK, appResponse{Message: "Hello green dapr!"} } func blueTest(commandRequest testCommandRequest) (int, appResponse) { log.Printf("BlueTest - message: %s", commandRequest.Message) return http.StatusOK, appResponse{Message: "Hello blue dapr!"} } func envTest(commandRequest testCommandRequest) (int, appResponse) { log.Printf("envTest - message: %s", commandRequest.Message) daprHTTPPort, ok := os.LookupEnv("DAPR_HTTP_PORT") if !ok { log.Println("Expected DAPR_HTTP_PORT to be set.") } daprGRPCPort, ok := os.LookupEnv("DAPR_GRPC_PORT") if !ok { log.Println("Expected DAPR_GRPC_PORT to be set.") } return http.StatusOK, appResponse{Message: fmt.Sprintf("%s %s", daprHTTPPort, daprGRPCPort)} } // epoch returns the current unix epoch timestamp func epoch() int { return int(time.Now().UnixMilli()) } // appRouter initializes restful api router func appRouter() http.Handler { router := mux.NewRouter().StrictSlash(true) // Log requests and their processing time router.Use(utils.LoggerMiddleware) router.HandleFunc("/", indexHandler).Methods("GET") router.HandleFunc("/tests/{test}", testHandler).Methods("POST") router.Use(mux.CORSMethodMiddleware(router)) return router } func main() { log.Printf("Hello Dapr - listening on http://localhost:%d", appPort) utils.StartServer(appPort, appRouter, true, false) }
mikeee/dapr
tests/apps/hellodapr/app.go
GO
mit
3,769
# In e2e test, this will not be used to deploy the app to test cluster. # This is created for testing purpose in order to deploy this app using kubectl # before writing e2e test. kind: Service apiVersion: v1 metadata: name: hellodapr labels: testapp: hellodapr spec: selector: testapp: hellodapr ports: - protocol: TCP port: 80 targetPort: 3000 type: LoadBalancer --- apiVersion: apps/v1 kind: Deployment metadata: name: hellodapr labels: testapp: hellodapr spec: replicas: 1 selector: matchLabels: testapp: hellodapr template: metadata: labels: testapp: hellodapr annotations: dapr.io/enabled: "true" dapr.io/app-id: "hellodapr" dapr.io/app-port: "3000" spec: containers: - name: hellodapr image: dapriotest/e2e-hellodapr ports: - containerPort: 3000 imagePullPolicy: Always
mikeee/dapr
tests/apps/hellodapr/service.yaml
YAML
mit
926
../utils/*.go
mikeee/dapr
tests/apps/injectorapp-init/.cache-include
none
mit
13
/* Copyright 2022 The Dapr Authors Licensed 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 main import ( "io/fs" "log" "os" "time" "github.com/dapr/dapr/tests/apps/utils" ) //nolint:gosec func writeSecrets() { data := []byte(`{"secret-key": "secret-value"}`) err := os.WriteFile("/tmp/testdata/secrets.json", data, fs.ModePerm) if err != nil { log.Printf("failed to write secret file: %v", err) } else { log.Printf("secret file is written") } } func writeTLSCertAndKey() { host := "localhost" validFrom := time.Now() validFor := time.Hour directory := "/tmp/testdata/certs" // ensure that the directory exists if _, err := os.Stat(directory); os.IsNotExist(err) { err := os.MkdirAll(directory, os.ModePerm) if err != nil { log.Printf("failed to create directory: %v", err) } } // generate the certs err := utils.GenerateTLSCertAndKey(host, validFrom, validFor, directory) if err != nil { log.Printf("failed to generate TLS cert and key: %v", err) } else { log.Printf("TLS cert and key is generated") } } func main() { // used by the injector test to validate volume mount writeSecrets() // used by the injector test to validate root cert installation feature writeTLSCertAndKey() }
mikeee/dapr
tests/apps/injectorapp-init/app.go
GO
mit
1,711
../utils/*.go
mikeee/dapr
tests/apps/injectorapp/.cache-include
none
mit
13
/* Copyright 2022 The Dapr Authors Licensed 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 main import ( "encoding/json" "fmt" "io" "log" "net/http" "net/url" "os" "strings" "time" "github.com/gorilla/mux" "github.com/dapr/dapr/tests/apps/utils" ) const ( appPort = 3000 securedAppPort = 3001 secretKey = "secret-key" secretStoreName = "local-secret-store" bindingName = "secured-binding" /* #nosec */ secretURL = "http://localhost:3500/v1.0/secrets/%s/%s?metadata.namespace=dapr-tests" bindingURL = "http://localhost:3500/v1.0/bindings/%s" tlsCertEnvKey = "DAPR_TESTS_TLS_CERT" tlsKeyEnvKey = "DAPR_TESTS_TLS_KEY" ) type appResponse struct { Message string `json:"message,omitempty"` StartTime int `json:"start_time,omitempty"` EndTime int `json:"end_time,omitempty"` } // indexHandler is the handler for root path func indexHandler(w http.ResponseWriter, r *http.Request) { log.Println("indexHandler is called") w.WriteHeader(http.StatusOK) json.NewEncoder(w).Encode(appResponse{Message: "OK"}) } func volumeMountTest() (int, appResponse) { log.Printf("volumeMountTest is called") // the secret store will be only able to get the value // if the volume is mounted correctly. url, err := url.Parse(fmt.Sprintf(secretURL, secretStoreName, secretKey)) if err != nil { return http.StatusInternalServerError, appResponse{Message: fmt.Sprintf("Failed to parse secret url: %v", err)} } // get the secret value resp, err := http.Get(url.String()) if err != nil { return http.StatusInternalServerError, appResponse{Message: fmt.Sprintf("Failed to get secret: %v", err)} } defer resp.Body.Close() // parse the secret value body, err := io.ReadAll(resp.Body) if err != nil { return http.StatusInternalServerError, appResponse{Message: fmt.Sprintf("Failed to read secret: %v", err)} } if resp.StatusCode != http.StatusOK { log.Printf("Non 200 StatusCode: %d\n", resp.StatusCode) return resp.StatusCode, appResponse{Message: fmt.Sprintf("Got error response for URL %s from Dapr: %v", url.String(), string(body))} } log.Printf("Found secret value: %s\n", string(body)) state := map[string]string{} err = json.Unmarshal(body, &state) if err != nil { return http.StatusInternalServerError, appResponse{Message: fmt.Sprintf("Failed to unmarshal secret: %v", err)} } return http.StatusOK, appResponse{Message: state[secretKey]} } func bindingTest() (int, appResponse) { log.Printf("bindingTest is called") url, err := url.Parse(fmt.Sprintf(bindingURL, bindingName)) if err != nil { return http.StatusInternalServerError, appResponse{Message: fmt.Sprintf("Failed to parse binding url: %v", err)} } // invoke the binding endpoint reqBody := "{\"operation\": \"get\"}" resp, err := http.Post(url.String(), "application/json", strings.NewReader(reqBody)) if err != nil { return http.StatusInternalServerError, appResponse{Message: fmt.Sprintf("Failed to get binding: %v", err)} } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { log.Printf("Non 200 StatusCode: %d\n", resp.StatusCode) return resp.StatusCode, appResponse{Message: fmt.Sprintf("Got error response for URL %s from Dapr, status code: %v", url.String(), resp.StatusCode)} } return http.StatusOK, appResponse{Message: "OK"} } // commandHandler is the handler for end-to-end test entry point // test driver code call this endpoint to trigger the test func commandHandler(w http.ResponseWriter, r *http.Request) { testCommand := mux.Vars(r)["command"] // Trigger the test res := appResponse{Message: fmt.Sprintf("%s is not supported", testCommand)} statusCode := http.StatusBadRequest startTime := epoch() switch testCommand { case "testVolumeMount": statusCode, res = volumeMountTest() case "testBinding": statusCode, res = bindingTest() } res.StartTime = startTime res.EndTime = epoch() w.WriteHeader(statusCode) json.NewEncoder(w).Encode(res) } // epoch returns the current unix epoch timestamp func epoch() int { return int(time.Now().UnixMilli()) } // appRouter initializes restful api router func appRouter() http.Handler { router := mux.NewRouter().StrictSlash(true) // Log requests and their processing time router.Use(utils.LoggerMiddleware) router.HandleFunc("/", indexHandler).Methods("GET") router.HandleFunc("/tests/{command}", commandHandler).Methods("POST") router.Use(mux.CORSMethodMiddleware(router)) return router } func securedAppRouter() http.Handler { router := mux.NewRouter().StrictSlash(true) // Log requests and their processing time router.Use(utils.LoggerMiddleware) router.HandleFunc("/", indexHandler).Methods("GET") router.Use(mux.CORSMethodMiddleware(router)) return router } func main() { log.Printf("Injector App - listening on http://localhost:%d", appPort) // start a secured app (with TLS) on an alternate port go func() { os.Setenv(tlsCertEnvKey, "/tmp/testdata/certs/cert.pem") os.Setenv(tlsKeyEnvKey, "/tmp/testdata/certs/key.pem") utils.StartServer(securedAppPort, securedAppRouter, true, true) }() utils.StartServer(appPort, appRouter, true, false) }
mikeee/dapr
tests/apps/injectorapp/app.go
GO
mit
5,621
# In e2e test, this will not be used to deploy the app to test cluster. # This is created for testing purpose in order to deploy this app using kubectl # before writing e2e test. kind: Service apiVersion: v1 metadata: name: injectorapp labels: testapp: injectorapp spec: selector: testapp: injectorapp ports: - protocol: TCP port: 80 targetPort: 3000 type: LoadBalancer --- apiVersion: apps/v1 kind: Deployment metadata: name: injectorapp labels: testapp: injectorapp spec: replicas: 1 selector: matchLabels: testapp: injectorapp template: metadata: labels: testapp: injectorapp annotations: dapr.io/enabled: "true" dapr.io/app-id: "injectorapp" dapr.io/app-port: "3000" dapr.io/volume-mounts: "storage-volume:/tmp/secrets/" spec: initContainers: - name: injectorapp-init image: dapriotest/e2e-injectorapp-init volumeMounts: - mountPath: /tmp/storage name: storage-volume containers: - name: injectorapp image: dapriotest/e2e-injectorapp ports: - containerPort: 3000 imagePullPolicy: Always resources: limits: cpu: "0.5" memory: "128Mi" volumes: - name: storage-volume emptyDir: {} nodeSelector: kubernetes.io/os: linux
mikeee/dapr
tests/apps/injectorapp/service.yaml
YAML
mit
1,419
../utils/*.go
mikeee/dapr
tests/apps/job-publisher/.cache-include
none
mit
13
/* Copyright 2021 The Dapr Authors Licensed 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 main import ( "bytes" "encoding/json" "fmt" "io" "log" "os" "time" "github.com/dapr/dapr/tests/apps/utils" ) const ( daprPort = 3500 pubsubName = "messagebus" pubsubTopic = "pubsub-job-topic-http" message = "message-from-job" publishRetries = 10 ) var httpClient = utils.NewHTTPClient() func stopSidecar() { log.Printf("Shutting down the sidecar at %s", fmt.Sprintf("http://localhost:%d/v1.0/shutdown", daprPort)) for retryCount := 0; retryCount < 200; retryCount++ { r, err := httpClient.Post(fmt.Sprintf("http://localhost:%d/v1.0/shutdown", daprPort), "", bytes.NewBuffer([]byte{})) if r != nil { // Drain before closing _, _ = io.Copy(io.Discard, r.Body) r.Body.Close() } if err != nil { log.Printf("Error stopping the sidecar %s", err) } if r.StatusCode != 200 && r.StatusCode != 204 { log.Printf("Received Non-200 from shutdown API. Code: %d", r.StatusCode) time.Sleep(10 * time.Second) continue } break } log.Printf("Sidecar stopped") } func publishMessagesToPubsub() error { daprPubsubURL := fmt.Sprintf("http://localhost:%d/v1.0/publish/%s/%s", daprPort, pubsubName, pubsubTopic) jsonValue, err := json.Marshal(message) if err != nil { log.Printf("Error marshalling %s to JSON", message) } log.Printf("Publishing to %s", daprPubsubURL) r, err := httpClient.Post(daprPubsubURL, "application/json", bytes.NewBuffer(jsonValue)) if r != nil { // Drain before closing _, _ = io.Copy(io.Discard, r.Body) r.Body.Close() } if err != nil { log.Printf("Error publishing messages to pubsub: %+v", err) } return err } func main() { for retryCount := 0; retryCount < publishRetries; retryCount++ { err := publishMessagesToPubsub() if err != nil { log.Printf("Unable to publish, retrying.") time.Sleep(10 * time.Second) } else { // Wait for a minute before shutting down to give time for any validation by E2E test code. time.Sleep(1 * time.Minute) stopSidecar() os.Exit(0) } } stopSidecar() os.Exit(1) }
mikeee/dapr
tests/apps/job-publisher/app.go
GO
mit
2,601
# In e2e test, this will not be used to deploy the app to test cluster. # This is created for testing purpose in order to deploy this app using kubectl # before writing e2e test. kind: Service apiVersion: v1 metadata: name: job-publisher labels: testapp: job-publisher spec: selector: testapp: job-publisher ports: - protocol: TCP port: 80 targetPort: 3000 type: LoadBalancer --- apiVersion: batch/v1 kind: Job metadata: name: job-publisher labels: testapp: job-publisher spec: selector: matchLabels: testapp: job-publisher template: metadata: labels: testapp: job-publisher annotations: dapr.io/enabled: "true" dapr.io/app-id: "job-publisher" dapr.io/app-port: "3000" spec: containers: - name: job-publisher image: docker.io/YOUR ID/e2e-job-publisher:dev ports: - containerPort: 3000 imagePullPolicy: Always
mikeee/dapr
tests/apps/job-publisher/service.yaml
YAML
mit
974
/* Copyright 2021 The Dapr Authors Licensed 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 main import ( "context" "encoding/json" "errors" "fmt" "io" "log" "net/http" "os" "strings" "time" chi "github.com/go-chi/chi/v5" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" runtimev1pb "github.com/dapr/dapr/pkg/proto/runtime/v1" "github.com/dapr/dapr/tests/apps/utils" ) const ( appPort = 3000 /* #nosec */ metadataURL = "http://localhost:3500/v1.0/metadata" ) var ( httpClient *http.Client grpcClient runtimev1pb.DaprClient ) // requestResponse represents a request or response for the APIs in this app. type requestResponse struct { StartTime time.Time `json:"start_time,omitempty"` EndTime time.Time `json:"end_time,omitempty"` Message string `json:"message,omitempty"` } type setMetadataRequest struct { Key string `json:"key"` Value string `json:"value"` } type mockMetadata struct { ID string `json:"id"` ActiveActorsCount []activeActorsCount `json:"actors"` Extended map[string]string `json:"extended"` RegisteredComponents []mockRegisteredComponent `json:"components"` EnabledFeatures []string `json:"enabledFeatures"` } type activeActorsCount struct { Type string `json:"type"` Count int `json:"count"` } type mockRegisteredComponent struct { Name string `json:"name"` Type string `json:"type"` Version string `json:"version"` Capabilities []string `json:"capabilities"` } func newMockMetadataFromGrpc(res *runtimev1pb.GetMetadataResponse) mockMetadata { activeActors := res.GetActorRuntime().GetActiveActors() metadata := mockMetadata{ ID: res.GetId(), ActiveActorsCount: make([]activeActorsCount, len(activeActors)), Extended: res.GetExtendedMetadata(), RegisteredComponents: make([]mockRegisteredComponent, len(res.GetRegisteredComponents())), EnabledFeatures: res.GetEnabledFeatures(), } for i, v := range activeActors { metadata.ActiveActorsCount[i] = activeActorsCount{ Type: v.GetType(), Count: int(v.GetCount()), } } for i, v := range res.GetRegisteredComponents() { metadata.RegisteredComponents[i] = mockRegisteredComponent{ Name: v.GetName(), Type: v.GetType(), Version: v.GetVersion(), Capabilities: v.GetCapabilities(), } } return metadata } func indexHandler(w http.ResponseWriter, _ *http.Request) { log.Println("indexHandler is called") w.WriteHeader(http.StatusOK) } func setMetadata(r *http.Request) error { var data setMetadataRequest if err := json.NewDecoder(r.Body).Decode(&data); err != nil { return err } if data.Key == "" || data.Value == "" { return errors.New("key or value in request must be set") } ctx, cancel := context.WithTimeout(r.Context(), 15*time.Second) defer cancel() switch chi.URLParam(r, "protocol") { case "http": req, err := http.NewRequestWithContext(ctx, http.MethodPut, metadataURL+"/"+data.Key, strings.NewReader(data.Value), ) if err != nil { return err } req.Header.Set("content-type", "text/plain") res, err := httpClient.Do(req) if err != nil { return err } defer res.Body.Close() if res.StatusCode != http.StatusNoContent { return fmt.Errorf("invalid status code: %d", res.StatusCode) } case "grpc": _, err := grpcClient.SetMetadata(ctx, &runtimev1pb.SetMetadataRequest{ Key: data.Key, Value: data.Value, }) if err != nil { return fmt.Errorf("failed to set metadata using gRPC: %w", err) } } return nil } func getMetadataHTTP(ctx context.Context) (metadata mockMetadata, err error) { req, err := http.NewRequestWithContext(ctx, http.MethodGet, metadataURL, nil) if err != nil { return metadata, err } res, err := httpClient.Do(req) if err != nil { return metadata, fmt.Errorf("could not get sidecar metadata %s", err.Error()) } defer res.Body.Close() body, err := io.ReadAll(res.Body) if err != nil { return metadata, fmt.Errorf("could not load value for Metadata: %s", err.Error()) } if res.StatusCode != http.StatusOK { log.Printf("Non 200 StatusCode: %d", res.StatusCode) return metadata, fmt.Errorf("got err response for get Metadata: %s", body) } err = json.Unmarshal(body, &metadata) return metadata, nil } func getMetadataGRPC(ctx context.Context) (metadata mockMetadata, err error) { ctx, cancel := context.WithTimeout(ctx, 15*time.Second) defer cancel() res, err := grpcClient.GetMetadata(ctx, &runtimev1pb.GetMetadataRequest{}) if err != nil { return metadata, fmt.Errorf("failed to get sidecar metadata from gRPC: %w", err) } return newMockMetadataFromGrpc(res), nil } // Handles tests func testHandler(w http.ResponseWriter, r *http.Request) { log.Printf("Processing request for %s", r.URL.RequestURI()) var ( metadata mockMetadata err error res requestResponse ) statusCode := http.StatusOK res.StartTime = time.Now() protocol := chi.URLParam(r, "protocol") if protocol != "http" && protocol != "grpc" { err = fmt.Errorf("invalid URI: %s", r.URL.RequestURI()) statusCode = http.StatusBadRequest res.Message = err.Error() } else { switch chi.URLParam(r, "command") { case "set": err = setMetadata(r) if err != nil { statusCode = http.StatusInternalServerError res.Message = err.Error() } res.Message = "ok" case "get": if protocol == "http" { metadata, err = getMetadataHTTP(r.Context()) } else { metadata, err = getMetadataGRPC(r.Context()) } if err != nil { statusCode = http.StatusInternalServerError res.Message = err.Error() } default: err = fmt.Errorf("invalid URI: %s", r.URL.RequestURI()) statusCode = http.StatusBadRequest res.Message = err.Error() } } res.EndTime = time.Now() if statusCode != http.StatusOK { log.Printf("Error status code %v: %v", statusCode, res.Message) } w.Header().Set("Content-Type", "application/json") w.WriteHeader(statusCode) if res.Message == "" { json.NewEncoder(w).Encode(metadata) } else { json.NewEncoder(w).Encode(res) } } // appRouter initializes restful api router func appRouter() http.Handler { router := chi.NewRouter() router.Use(utils.LoggerMiddleware) router.Get("/", indexHandler) router.Post("/test/{protocol}/{command}", testHandler) return router } func main() { // Connect to gRPC var ( conn *grpc.ClientConn err error ) grpcSocketAddr := os.Getenv("DAPR_GRPC_SOCKET_ADDR") if grpcSocketAddr != "" { conn, err = grpc.Dial( "unix://"+grpcSocketAddr, grpc.WithTransportCredentials(insecure.NewCredentials()), ) } else { ctx, cancel := context.WithTimeout(context.Background(), time.Minute) defer cancel() conn, err = grpc.DialContext(ctx, "localhost:50001", grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock(), ) } if err != nil { log.Fatalf("Failed to establish gRPC connection to Dapr: %v", err) } grpcClient = runtimev1pb.NewDaprClient(conn) // If using Unix Domain Sockets, we need to change the HTTP client too httpSocketAddr := os.Getenv("DAPR_HTTP_SOCKET_ADDR") if httpSocketAddr != "" { httpClient = utils.NewHTTPClientForSocket(httpSocketAddr) } else { httpClient = utils.NewHTTPClient() } // Start app log.Printf("Metadata App - listening on http://:%d", appPort) utils.StartServer(appPort, appRouter, true, false) }
mikeee/dapr
tests/apps/metadata/app.go
GO
mit
7,960
# In e2e test, this will not be used to deploy the app to test cluster. # This is created for testing purpose in order to deploy this app using kubectl # before writing e2e test. kind: Service apiVersion: v1 metadata: name: metadataapp labels: testapp: metadataapp spec: selector: testapp: metadataapp ports: - protocol: TCP port: 80 targetPort: 3000 type: LoadBalancer --- apiVersion: apps/v1 kind: Deployment metadata: name: metadataapp labels: testapp: metadataapp spec: replicas: 1 selector: matchLabels: testapp: metadataapp template: metadata: labels: testapp: metadataapp annotations: dapr.io/enabled: "true" dapr.io/app-id: "metadataapp" dapr.io/app-port: "3000" spec: containers: - name: metadataapp image: YOUR_REGISTRY/e2e-metadata:dev ports: - containerPort: 3000 imagePullPolicy: Always
mikeee/dapr
tests/apps/metadata/service.yaml
YAML
mit
950
../utils/*.go
mikeee/dapr
tests/apps/middleware/.cache-include
none
mit
13
/* Copyright 2021 The Dapr Authors Licensed 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 main import ( "bytes" "encoding/json" "fmt" "io" "log" "net/http" "os" "strconv" "github.com/gorilla/mux" "github.com/dapr/dapr/tests/apps/utils" ) var ( appPort = 3000 daprPort = 3500 ) func init() { p := os.Getenv("DAPR_HTTP_PORT") if p != "" && p != "0" { daprPort, _ = strconv.Atoi(p) } p = os.Getenv("PORT") if p != "" && p != "0" { appPort, _ = strconv.Atoi(p) } } type testResponse struct { Input string `json:"input"` Output string `json:"output"` } func healthzHandler(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) w.Write([]byte("")) } // indexHandler is the handler for root path. func indexHandler(w http.ResponseWriter, r *http.Request) { log.Println("indexHandler is called") w.WriteHeader(http.StatusOK) } func testLogCall(w http.ResponseWriter, r *http.Request) { log.Printf("testLogCall is called") service := mux.Vars(r)["service"] input := "hello" url := fmt.Sprintf("http://localhost:%d/v1.0/invoke/%s/method/logCall", daprPort, service) resp, err := http.Post(url, "application/json", bytes.NewReader([]byte(input))) //nolint:gosec if err != nil { log.Printf("Could not call service") w.WriteHeader(http.StatusInternalServerError) return } defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) results := testResponse{ input, string(body), } w.WriteHeader(resp.StatusCode) _ = json.NewEncoder(w).Encode(results) } func logCall(w http.ResponseWriter, r *http.Request) { log.Printf("logCall is called") defer r.Body.Close() body, _ := io.ReadAll(r.Body) log.Printf("Got: %s", string(body)) w.Write(body) } // appRouter initializes restful api router. func appRouter() http.Handler { router := mux.NewRouter().StrictSlash(true) // Log requests and their processing time router.Use(utils.LoggerMiddleware) router.HandleFunc("/", indexHandler).Methods("GET") router.HandleFunc("/test/logCall/{service}", testLogCall).Methods("POST") router.HandleFunc("/logCall", logCall).Methods("POST") router.HandleFunc("/healthz", healthzHandler).Methods("GET") router.Use(mux.CORSMethodMiddleware(router)) return router } func main() { log.Printf("Middleware App - listening on http://localhost:%d", appPort) utils.StartServer(appPort, appRouter, true, false) }
mikeee/dapr
tests/apps/middleware/app.go
GO
mit
2,854
# In e2e test, this will not be used to deploy the app to test cluster. # This is created for testing purpose in order to deploy this app using kubectl # before writing e2e test. kind: Service apiVersion: v1 metadata: name: middleware labels: testapp: middleware spec: selector: testapp: middleware ports: - protocol: TCP port: 80 targetPort: 3000 type: LoadBalancer --- apiVersion: apps/v1 kind: Deployment metadata: name: middleware labels: testapp: middleware spec: replicas: 1 selector: matchLabels: testapp: middleware template: metadata: labels: testapp: middleware annotations: dapr.io/enabled: "true" dapr.io/app-id: "middleware" dapr.io/app-port: "3000" spec: containers: - name: middleware image: docker.io/[YOUR ALIAS]/e2e-middleware:dev ports: - containerPort: 3000 imagePullPolicy: Always
mikeee/dapr
tests/apps/middleware/service.yaml
YAML
mit
951
result.json */app *.exe
mikeee/dapr
tests/apps/perf/.gitignore
Git
mit
24
Dockerfile*
mikeee/dapr
tests/apps/perf/actor-activation-locker/.dockerignore
Dockerfile
mit
11
# # Copyright 2022 The Dapr Authors # Licensed 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. # FROM golang:1.22.3 as build_env ENV CGO_ENABLED=0 WORKDIR /app COPY . . RUN go get -d -v RUN go build -o app . FROM ggcr.io/distroless/base-nossl:nonroot WORKDIR / COPY --from=build_env /app/app / CMD ["/app"]
mikeee/dapr
tests/apps/perf/actor-activation-locker/Dockerfile
Dockerfile
mit
791
/* Copyright 2022 The Dapr Authors Licensed 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 main import ( "context" "errors" "fmt" "log" "net/http" "time" "github.com/bsm/redislock" redis "github.com/go-redis/redis/v9" "github.com/dapr/go-sdk/actor" dapr "github.com/dapr/go-sdk/client" daprd "github.com/dapr/go-sdk/service/http" ) func testActorFactory(client dapr.Client, redisClient *redis.Client) func() actor.ServerContext { lockClient := redislock.New(redisClient) return func() actor.ServerContext { return &TestActor{ daprClient: client, locker: lockClient, } } } type TestActor struct { actor.ServerImplBaseCtx daprClient dapr.Client locker *redislock.Client } func (t *TestActor) Type() string { return "fake-actor-type" } // user defined functions func (t *TestActor) Lock(ctx context.Context, req any) (any, error) { lockTimeout := time.Second // Try to obtain lock. lock, err := t.locker.Obtain(ctx, fmt.Sprintf("DOUBLE_ACTIVATION_ACTOR_TEST_%s", t.ID()), lockTimeout, nil) if err == redislock.ErrNotObtained { return nil, errors.New("resource was locked!") } if err == nil { if releaseErr := lock.Release(ctx); releaseErr != nil { time.Sleep(lockTimeout * 2) // sleep to make sure that the lock will be automatically released } } return "succeed", nil } func main() { client, err := dapr.NewClient() if err != nil { panic(err) } defer client.Close() m, err := client.GetSecret(context.Background(), "kubernetes", "redissecret", map[string]string{}) if err != nil { panic(err) } redisHost := m["host"] if len(redisHost) == 0 { panic(errors.New("redis host not provided")) } // Connect to redis. redisClient := redis.NewClient(&redis.Options{ Network: "tcp", Addr: redisHost, }) defer client.Close() s := daprd.NewService(":3000") s.RegisterActorImplFactoryContext(testActorFactory(client, redisClient)) log.Println("Started") if err := s.Start(); err != nil && err != http.ErrServerClosed { log.Fatalf("Error listenning: %v", err) } }
mikeee/dapr
tests/apps/perf/actor-activation-locker/app.go
GO
mit
2,523
module github.com/dapr/dapr/tests/apps/perf/actor-activation-locker go 1.22.3 require ( github.com/bsm/redislock v0.8.2 github.com/dapr/go-sdk v1.8.0 github.com/go-redis/redis/v9 v9.0.0-rc.1 ) require ( github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/go-chi/chi/v5 v5.0.8 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/uuid v1.3.0 // indirect github.com/kr/pretty v0.3.1 // indirect golang.org/x/net v0.12.0 // indirect golang.org/x/sys v0.10.0 // indirect golang.org/x/text v0.11.0 // indirect google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect google.golang.org/grpc v1.55.0 // indirect google.golang.org/protobuf v1.30.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect )
mikeee/dapr
tests/apps/perf/actor-activation-locker/go.mod
mod
mit
836