|
| 1 | +/* |
| 2 | + * Copyright 2025 The Dapr Authors |
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | + * you may not use this file except in compliance with the License. |
| 5 | + * You may obtain a copy of the License at |
| 6 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | + * Unless required by applicable law or agreed to in writing, software |
| 8 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 9 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 10 | + * See the License for the specific language governing permissions and |
| 11 | +limitations under the License. |
| 12 | +*/ |
| 13 | + |
| 14 | +package io.dapr.it.testcontainers; |
| 15 | + |
| 16 | +import io.dapr.client.DaprClient; |
| 17 | +import io.dapr.client.DaprClientBuilder; |
| 18 | +import io.dapr.client.DaprPreviewClient; |
| 19 | +import io.dapr.config.Properties; |
| 20 | +import io.dapr.config.Property; |
| 21 | +import org.springframework.beans.factory.annotation.Value; |
| 22 | +import org.springframework.context.annotation.Bean; |
| 23 | +import org.springframework.context.annotation.Configuration; |
| 24 | + |
| 25 | +import java.util.Map; |
| 26 | + |
| 27 | +@Configuration |
| 28 | +public class DaprClientConfiguration { |
| 29 | + @Bean |
| 30 | + public DaprClient daprClient( |
| 31 | + @Value("${dapr.http.endpoint}") String daprHttpEndpoint, |
| 32 | + @Value("${dapr.grpc.endpoint}") String daprGrpcEndpoint |
| 33 | + ){ |
| 34 | + Map<Property<?>, String> overrides = Map.of( |
| 35 | + Properties.HTTP_ENDPOINT, daprHttpEndpoint, |
| 36 | + Properties.GRPC_ENDPOINT, daprGrpcEndpoint |
| 37 | + ); |
| 38 | + |
| 39 | + return new DaprClientBuilder().withPropertyOverrides(overrides).build(); |
| 40 | + } |
| 41 | +} |
0 commit comments