daml/ledger/ledger-api-client/BUILD.bazel

138 lines
4.5 KiB
Python
Raw Normal View History

# Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
2019-04-04 11:33:38 +03:00
# SPDX-License-Identifier: Apache-2.0
load(
"//bazel_tools:scala.bzl",
"da_scala_library",
"da_scala_test_suite",
"silencer_plugin",
2019-04-04 11:33:38 +03:00
)
load("@scala_version//:index.bzl", "scala_major_version")
2019-04-04 11:33:38 +03:00
da_scala_library(
name = "ledger-api-client",
srcs = glob(["src/main/scala/**/*.scala"]),
plugins = [
silencer_plugin,
],
scala_deps = [
"@maven//:org_scala_lang_modules_scala_collection_compat",
"@maven//:com_typesafe_akka_akka_actor",
"@maven//:com_typesafe_akka_akka_stream",
],
tags = ["maven_coordinates=com.daml:ledger-api-client:__VERSION__"],
visibility = [
"//visibility:public",
],
deps = [
"//daml-lf/data",
"//language-support/scala/bindings",
"//ledger-api/rs-grpc-akka",
"//ledger-api/rs-grpc-bridge",
"//ledger/error",
"//ledger/ledger-api-auth-client",
"//ledger/ledger-api-common",
"//ledger/ledger-api-domain",
"//ledger/ledger-grpc",
resources: Customizable contexts. (#7678) * resources: Move builders into //ledger/ledger-resources. Keep the actual constructors in a trait, but instantiate it when working with ledger code. This allows us to later introduce an extra "context" type parameter to ResourceOwner. * resources-akka: Move the builders in to //ledger/ledger-resources. * resources: Introduce an abstract `Context` parameter for owners. This replaces the concrete `ExecutionContext`. While it _can_ be an execution context, it really doesn't matter as long as we can get at one somehow. This is being introduced so we can wrap the context in a container, either for type tagging or to include extra information. Because our current context _is_ `ExecutionContext`, and an implicit is provided to extract it, we can end up with two ways to get the same value. We use shadowing to prevent this. This problem should go away in the near future when a new context type is added. CHANGELOG_BEGIN - [Integration Kit] The `ResourceOwner` type is now parameterized by a `Context`, which is filled in by the corresponding `Context` class in the _ledger-resources_ dependency. This allows us to pass extra information through resource acquisition. CHANGELOG_END * ledger-resources: Move `ResourceOwner` here from `resources`. * ledger-resources: Remove dependencies from outside //ledger. * ledger-resource: Wrap the acquisition execution context in `Context`. So we can add a logging context to it. * resources: Pass the Context, not the ExecutionContext, to Resource. * Avoid importing `HasExecutionContext`. * ledger-resources: Publish to Maven Central. * resources: Make the small changes suggested by @stefanobaghino-da. Co-Authored-By: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com> * ledger-resources: Pull out a trait for test resource contexts. Saves a few lines of code. * Restore some imports that were accidentally wildcarded. * resources: Replace an `implicit def` with a couple of imports. * participant-integration-api: Simplify the JdbcLedgerDaoBackend tests. Try and use the right execution context where possible. Co-authored-by: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com>
2020-10-20 12:26:28 +03:00
"//ledger/ledger-resources",
"//ledger/metrics",
"//libs-scala/grpc-utils",
2020-07-21 18:50:33 +03:00
"//libs-scala/ports",
"//libs-scala/resources",
Track command - use types for error handling instead of grpc statuses [KVL-1005] (#10503) * Track command response using an Either instead of passing the completion with the grpc code. This makes it clearer as to the result of command tracking. We no longer count on the grpc status to determine if there was an error or not, and instead use types for that. CHANGELOG_BEGIN akka-bindings: `LedgerClientBinding.commands` now returns a flow of `Either[CompletionFailure, CompletionSuccess]` instead of `Completion` for clearer error handling. For backwards compatiblity the new return type can be turned back into a `Completion` using `CompletionResponse.toCompletion` CHANGELOG_END * Fix formatting * Code review changes - remove usages of Symbol in tests - clean curly braces * Remove change added from another PR * Fix import * Fix import * Fix retry flow and extract one more match case * Un-nest matches to a single level for simplicity * fix typo Co-authored-by: Samir Talwar <samir.talwar@digitalasset.com> * Be consistent in assertions and prefer `inside` for pattern matching * Inline CompletionResponse to use the full type * Use simpler matcher * Formatting * Add a way to convert back an `Either[CompletionFailure, CompletionSuccess]` to a `Completion` for backwards compatibility. This simplifies update for systems that are tightly coupled to `Completion` * Add test for converting to/from CompletionResponse * Remove unnecessary brackets * Add missing header * Use checked exceptions to preserve backwards compatiblity * Fix unapply Co-authored-by: Samir Talwar <samir.talwar@digitalasset.com>
2021-08-12 09:37:53 +03:00
"@maven//:com_google_api_grpc_proto_google_common_protos",
"@maven//:com_google_protobuf_protobuf_java",
"@maven//:io_dropwizard_metrics_metrics_core",
"@maven//:io_grpc_grpc_netty",
"@maven//:io_netty_netty_handler",
"@maven//:org_slf4j_slf4j_api",
],
2019-04-04 11:33:38 +03:00
)
da_scala_test_suite(
name = "ledger-api-client-tests",
srcs = glob(["src/test/suite/**/*.scala"]),
plugins = [
silencer_plugin,
],
scala_deps = [
"@maven//:com_typesafe_akka_akka_actor",
"@maven//:com_typesafe_akka_akka_stream",
"@maven//:com_typesafe_akka_akka_stream_testkit",
"@maven//:org_mockito_mockito_scala",
"@maven//:org_scalatest_scalatest_core",
"@maven//:org_scalatest_scalatest_matchers_core",
"@maven//:org_scalatest_scalatest_shouldmatchers",
"@maven//:org_scalatest_scalatest_wordspec",
],
scalacopts = [
"-P:silencer:lineContentFilters=import Compat._",
],
2019-04-04 11:33:38 +03:00
deps = [
":ledger-api-client",
"//language-support/scala/bindings",
"//ledger-api/rs-grpc-bridge",
"//ledger-api/testing-utils",
"//ledger/caching",
"//ledger/error",
"//ledger/ledger-api-common",
"//ledger/ledger-api-domain",
"//ledger/ledger-grpc",
"//ledger/metrics",
"//libs-scala/concurrent",
"//libs-scala/contextualized-logging",
"//libs-scala/grpc-utils",
"@maven//:com_google_api_grpc_proto_google_common_protos",
"@maven//:com_google_protobuf_protobuf_java",
"@maven//:io_dropwizard_metrics_metrics_core",
"@maven//:org_mockito_mockito_core",
"@maven//:org_reactivestreams_reactive_streams",
"@maven//:org_scalatest_scalatest_compatible",
],
2019-04-04 11:33:38 +03:00
)
da_scala_test_suite(
name = "ledger-api-client-integration-tests",
srcs = glob(["src/it/**/*.scala"]),
data = [
"//ledger/test-common:dar-files",
],
resources = [
"src/it/resources/logback-test.xml",
],
scala_deps = [
"@maven//:com_typesafe_akka_akka_actor",
"@maven//:com_typesafe_akka_akka_stream",
],
deps = [
":ledger-api-client",
"//language-support/scala/bindings",
"//ledger-api/rs-grpc-bridge",
"//ledger-api/testing-utils",
"//ledger/caching",
"//ledger/error",
"//ledger/ledger-api-auth",
"//ledger/ledger-api-common",
"//ledger/ledger-api-domain",
"//ledger/ledger-configuration",
resources: Customizable contexts. (#7678) * resources: Move builders into //ledger/ledger-resources. Keep the actual constructors in a trait, but instantiate it when working with ledger code. This allows us to later introduce an extra "context" type parameter to ResourceOwner. * resources-akka: Move the builders in to //ledger/ledger-resources. * resources: Introduce an abstract `Context` parameter for owners. This replaces the concrete `ExecutionContext`. While it _can_ be an execution context, it really doesn't matter as long as we can get at one somehow. This is being introduced so we can wrap the context in a container, either for type tagging or to include extra information. Because our current context _is_ `ExecutionContext`, and an implicit is provided to extract it, we can end up with two ways to get the same value. We use shadowing to prevent this. This problem should go away in the near future when a new context type is added. CHANGELOG_BEGIN - [Integration Kit] The `ResourceOwner` type is now parameterized by a `Context`, which is filled in by the corresponding `Context` class in the _ledger-resources_ dependency. This allows us to pass extra information through resource acquisition. CHANGELOG_END * ledger-resources: Move `ResourceOwner` here from `resources`. * ledger-resources: Remove dependencies from outside //ledger. * ledger-resource: Wrap the acquisition execution context in `Context`. So we can add a logging context to it. * resources: Pass the Context, not the ExecutionContext, to Resource. * Avoid importing `HasExecutionContext`. * ledger-resources: Publish to Maven Central. * resources: Make the small changes suggested by @stefanobaghino-da. Co-Authored-By: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com> * ledger-resources: Pull out a trait for test resource contexts. Saves a few lines of code. * Restore some imports that were accidentally wildcarded. * resources: Replace an `implicit def` with a couple of imports. * participant-integration-api: Simplify the JdbcLedgerDaoBackend tests. Try and use the right execution context where possible. Co-authored-by: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com>
2020-10-20 12:26:28 +03:00
"//ledger/ledger-resources",
"//ledger/metrics",
"//ledger/participant-integration-api",
"//ledger/participant-state",
"//ledger/sandbox",
"//ledger/sandbox:sandbox-scala-tests-lib",
"//ledger/sandbox-classic",
"//ledger/sandbox-classic:sandbox-classic-scala-tests-lib",
"//ledger/sandbox-common",
"//ledger/sandbox-common:sandbox-common-scala-tests-lib",
"//ledger/test-common",
"//libs-scala/concurrent",
contextualized-logging: Introduce different logging types for more structure. [KVL-996] (#10134) * contextualized-logging: Automatically convert logging values to strings. For now, this has almost the same behavior, but it allows us to customize the output in the future. The main change is that the log format has gone from: context: {a=b, x=1, foo=bar} to: context: {a: "b", x: "1", foo: "bar"} * contextualized-logging: Move `writeTo` inside `LoggingValue`. * contextualized-logging: Allow for more than just strings. `null`, numbers, and sequences are now correctly logged. The log format has gone from: context: {a: "b", x: "1", foo: "bar", parties: "[alice, bob]"} to: context: {a: "b", x: 1, foo: "bar", parties: ["alice", "bob"]} CHANGELOG_BEGIN - The log output of Daml components has changed so that the structured part is closer to JSON. This allows us to distinguish and parse numbers and lists. If you are parsing this log output, you may need to change your parser. The log output has changed from: .. code-block:: context: {a=b, x=1, foo=bar, parties=[alice, bob]} to: .. code-block:: context: {a: "b", x: 1, foo: "bar", parties: ["alice", "bob"]} CHANGELOG_END * contextualized-logging: Extract the string serializer. * Use non-string logging where possible. * contextualized-logging: Split logging values from serialization. So that callers don't have to know about Jackson. * contextualized-logging: `SeqView` is `Iterable`. Don't need both. * contextualized-logging: Make `ToStringToLoggingValue` a `val`. Co-Authored-By: Stephen Compall <stephen.compall@daml.com> * contextualized-logging: Add a transient dependency for 2.12 only. This required more infrastructure than I thought it would. * kvutils: Make it explicit that we're logging the hashes of archives. The implicit was found to be a little confusing. Co-authored-by: Stephen Compall <stephen.compall@daml.com>
2021-06-29 12:16:26 +03:00
"//libs-scala/contextualized-logging",
"//libs-scala/grpc-utils",
"//libs-scala/logging-entries",
"//libs-scala/ports",
"//libs-scala/resources",
"@maven//:ch_qos_logback_logback_classic",
"@maven//:io_netty_netty_handler",
],
)