diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 9b1e094e..f77596b7 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -85,8 +85,11 @@ jobs: cd ./examples/js/ npm install + - name: Pull git submodule + run: git submodule update --init --recursive + - name: Up docker-compose - run: docker-compose --file "./docker/docker-compose.yaml" up --detach # db zookeeper kafka + run: docker-compose --file "./orchestra/docker/docker-compose.yaml" up --detach # 1. we build the binary after starting docker-compose, to ensure time for running services in docker-compose # 2. we avoid nohup cargo run directly, to make sure server is running before starting trading tests @@ -106,7 +109,7 @@ jobs: run: | sleep 5 make taillogs - docker-compose --file "./docker/docker-compose.yaml" logs --tail=20 + docker-compose --file "./orchestra/docker/docker-compose.yaml" logs --tail=20 - name: Run trading tests run: | diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..10784d19 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "orchestra"] + path = orchestra + url = https://github.com/Fluidex/orchestra.git diff --git a/Cargo.lock b/Cargo.lock index 75e38dff..b2405120 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -708,8 +708,7 @@ dependencies = [ "log", "nix", "num_enum", - "prost 0.7.0", - "prost-types 0.8.0", + "orchestra", "qstring", "rand 0.8.3", "serde 1.0.124", @@ -718,7 +717,6 @@ dependencies = [ "thiserror", "tokio", "tonic", - "tonic-build", "tracing", "tracing-appender", "tracing-subscriber", @@ -1552,6 +1550,17 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "orchestra" +version = "0.1.0" +source = "git+https://github.com/Fluidex/orchestra.git?branch=master#b3b45ccb205c5769d1b4ec7bf05c1c4127ebd84d" +dependencies = [ + "prost", + "serde 1.0.124", + "tonic", + "tonic-build", +] + [[package]] name = "parking_lot" version = "0.11.1" @@ -1744,17 +1753,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e6984d2f1a23009bd270b8bb56d0926810a3d483f59c987d77969e9d8e840b2" dependencies = [ "bytes", - "prost-derive 0.7.0", -] - -[[package]] -name = "prost" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de5e2533f59d08fcf364fd374ebda0692a70bd6d7e66ef97f306f45c6c5d8020" -dependencies = [ - "bytes", - "prost-derive 0.8.0", + "prost-derive", ] [[package]] @@ -1769,8 +1768,8 @@ dependencies = [ "log", "multimap", "petgraph", - "prost 0.7.0", - "prost-types 0.7.0", + "prost", + "prost-types", "tempfile", "which", ] @@ -1788,19 +1787,6 @@ dependencies = [ "syn", ] -[[package]] -name = "prost-derive" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "600d2f334aa05acb02a755e217ef1ab6dea4d51b58b7846588b747edec04efba" -dependencies = [ - "anyhow", - "itertools 0.10.0", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "prost-types" version = "0.7.0" @@ -1808,17 +1794,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b518d7cdd93dab1d1122cf07fa9a60771836c668dde9d9e2a139f957f0d9f1bb" dependencies = [ "bytes", - "prost 0.7.0", -] - -[[package]] -name = "prost-types" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "603bbd6394701d13f3f25aada59c7de9d35a6a5887cfc156181234a44002771b" -dependencies = [ - "bytes", - "prost 0.8.0", + "prost", ] [[package]] @@ -2709,8 +2685,8 @@ dependencies = [ "hyper", "percent-encoding", "pin-project", - "prost 0.7.0", - "prost-derive 0.7.0", + "prost", + "prost-derive", "tokio", "tokio-stream", "tokio-util", diff --git a/Cargo.toml b/Cargo.toml index a2cf727c..98eb1d08 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,8 +28,7 @@ lazy_static = "1.4.0" log = "0.4.14" nix = "0.20.0" num_enum = "0.5.1" -prost = "0.7.0" -prost-types = "0.8.0" +orchestra = { git = "https://github.com/Fluidex/orchestra.git", branch = "master", features = [ "exchange" ] } qstring = "0.7.2" rand = "0.8.3" serde = { version = "1.0.124", features = [ "derive" ] } @@ -43,10 +42,6 @@ tracing-appender = "0.1" tracing-subscriber = "0.2" ttl_cache = "0.5.1" -[build-dependencies] -prost = "0.7.0" -tonic-build = "0.4.0" - [[bin]] name = "restapi" path = "src/bin/restapi.rs" diff --git a/Makefile b/Makefile index a23252e0..a58fe0d3 100644 --- a/Makefile +++ b/Makefile @@ -11,9 +11,6 @@ lint: cargo fmt --all -- --check cargo clippy -- -D warnings -fmtproto: - clang-format -i proto/exchange/matchengine.proto - fmtsql: find migrations -type f | xargs -L 1 pg_format --type-case 2 -i @@ -23,7 +20,7 @@ fmtrs: fmtjs: cd examples/js && yarn fmt -fmt: fmtproto fmtsql fmtrs fmtjs +fmt: fmtsql fmtrs fmtjs startall: cargo build @@ -52,6 +49,3 @@ cleardb: # https://stackoverflow.com/a/13823560/2078461 psql $(DB) -X -a -f $(DB_RESET_DIR)/down.sql psql $(DB) -X -a -f $(DB_RESET_DIR)/up.sql - -genpb: - cd proto && protoc -Ithird_party/googleapis -I. --include_imports --include_source_info --descriptor_set_out=matchengine.pb exchange/matchengine.proto diff --git a/build.rs b/build.rs deleted file mode 100644 index 62baa352..00000000 --- a/build.rs +++ /dev/null @@ -1,14 +0,0 @@ -fn build_grpc() { - tonic_build::configure() - .out_dir("src/matchengine/rpc") - .type_attribute(".", "#[derive(serde::Serialize, serde::Deserialize)]") - .compile( - &["proto/exchange/matchengine.proto"], - &["proto/exchange", "proto/third_party/googleapis"], - ) - .unwrap(); -} - -fn main() { - build_grpc() -} diff --git a/config/development.yaml b/config/development.yaml index a0fa0771..ff861bb0 100644 --- a/config/development.yaml +++ b/config/development.yaml @@ -1,4 +1,4 @@ debug: true -db_log: postgres://exchange:exchange_AA9944@127.0.0.1/exchange -db_history: postgres://exchange:exchange_AA9944@127.0.0.1/exchange +db_log: postgres://exchange:exchange_AA9944@127.0.0.1/exchange +db_history: postgres://exchange:exchange_AA9944@127.0.0.1/exchange brokers: '127.0.0.1:9092' diff --git a/docker/.gitignore b/docker/.gitignore deleted file mode 100644 index 1269488f..00000000 --- a/docker/.gitignore +++ /dev/null @@ -1 +0,0 @@ -data diff --git a/docker/configs/proxy.conf b/docker/configs/proxy.conf deleted file mode 100644 index 0bc9a27a..00000000 --- a/docker/configs/proxy.conf +++ /dev/null @@ -1,19 +0,0 @@ - server { - listen 8765; - location /api { - proxy_pass http://grpcgateway:50052; # TODO - proxy_redirect off; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Host $server_name; - } - location /restapi { - proxy_pass http://host.docker.internal:50053; - proxy_redirect off; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Host $server_name; - } - } diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml deleted file mode 100644 index 6b1994cd..00000000 --- a/docker/docker-compose.yaml +++ /dev/null @@ -1,51 +0,0 @@ -version: '3.4' -services: - envoy: - image: envoyproxy/envoy-dev:f2906f5ce372814b8e6f688a0e1766703d8b56f2 - container_name: exchange_envoy - restart: always - ports: - - "8765:8765" - command: -c /etc/envoy/envoy.yaml --log-level debug - volumes: - - ./envoy.yaml:/etc/envoy/envoy.yaml - - ../proto/matchengine.pb:/tmp/envoy/proto.pb - extra_hosts: - - "host.docker.internal:host-gateway" - db: - image: timescale/timescaledb:2.1.0-pg13 - container_name: exchange_pq - restart: always - volumes: - - ./data/volumes/postgres_data:/var/lib/postgresql/data - ports: - - "5432:5432" - environment: - POSTGRES_DB: exchange - POSTGRES_USER: exchange - POSTGRES_PASSWORD: exchange_AA9944 - - zookeeper: - image: zookeeper - container_name: exchange_zookeeper - restart: always - ports: - - "2181:2181" - volumes: - - ./data/volumes/log_zookeeper:/var/log/zookeeper - - kafka: - image: wurstmeister/kafka:2.13-2.7.0 - container_name: exchange_kafka - restart: always - logging: - options: - max-size: 10m - ports: - - "9092:9092" - volumes: - - ./data/volumes/log_kafka:/var/log/kafka - environment: - KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 - KAFKA_ADVERTISED_HOST_NAME: 127.0.0.1 - KAFKA_CREATE_TOPICS: "trades:1:1,orders:1:1,balances:1:1,internaltransfer:1:1,registeruser:1:1,unifyevents:1:1" diff --git a/docker/envoy.yaml b/docker/envoy.yaml deleted file mode 100644 index d5c2b617..00000000 --- a/docker/envoy.yaml +++ /dev/null @@ -1,81 +0,0 @@ -admin: - address: - socket_address: {address: 0.0.0.0, port_value: 9901} - -static_resources: - listeners: - - name: listener1 - address: - socket_address: {address: 0.0.0.0, port_value: 8765} - filter_chains: - - filters: - - name: envoy.filters.network.http_connection_manager - typed_config: - "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager - stat_prefix: ingress_http - codec_type: AUTO - route_config: - name: local_route - virtual_hosts: - - name: local_service - domains: ["*"] - routes: - - match: {prefix: "/restapi"} - route: - cluster: rust_http - timeout: 60s - - match: {prefix: "/matchengine.Matchengine"} - route: - cluster: grpc - timeout: 60s - http_filters: - - name: envoy.filters.http.grpc_json_transcoder - typed_config: - "@type": type.googleapis.com/envoy.extensions.filters.http.grpc_json_transcoder.v3.GrpcJsonTranscoder - proto_descriptor: "/tmp/envoy/proto.pb" - services: ["matchengine.Matchengine"] - convert_grpc_status: true - print_options: - add_whitespace: true - always_print_primitive_fields: true - always_print_enums_as_ints: false - preserve_proto_field_names: true - - name: envoy.filters.http.router - - clusters: - - name: grpc - type: LOGICAL_DNS - lb_policy: ROUND_ROBIN - dns_lookup_family: V4_ONLY - typed_extension_protocol_options: - envoy.extensions.upstreams.http.v3.HttpProtocolOptions: - "@type": type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions - explicit_http_config: - http2_protocol_options: {} - load_assignment: - cluster_name: grpc - endpoints: - - lb_endpoints: - - endpoint: - address: - socket_address: - address: host.docker.internal - port_value: 50051 - - name: rust_http - type: LOGICAL_DNS - lb_policy: ROUND_ROBIN - dns_lookup_family: V4_ONLY - typed_extension_protocol_options: - envoy.extensions.upstreams.http.v3.HttpProtocolOptions: - "@type": type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions - explicit_http_config: - http_protocol_options: {} - load_assignment: - cluster_name: rust_http - endpoints: - - lb_endpoints: - - endpoint: - address: - socket_address: - address: host.docker.internal - port_value: 50053 diff --git a/examples/js/client.ts b/examples/js/client.ts index cbf1aae3..58f232c8 100644 --- a/examples/js/client.ts +++ b/examples/js/client.ts @@ -8,7 +8,7 @@ import { VERBOSE } from "./config"; -const file = "../../proto/exchange/matchengine.proto"; +const file = "../../orchestra/proto/exchange/matchengine.proto"; const load = { keepCase: true, longs: String, diff --git a/orchestra b/orchestra new file mode 160000 index 00000000..b3b45ccb --- /dev/null +++ b/orchestra @@ -0,0 +1 @@ +Subproject commit b3b45ccb205c5769d1b4ec7bf05c1c4127ebd84d diff --git a/proto/exchange/matchengine.proto b/proto/exchange/matchengine.proto deleted file mode 100644 index f266f2df..00000000 --- a/proto/exchange/matchengine.proto +++ /dev/null @@ -1,307 +0,0 @@ -syntax = "proto3"; - -package matchengine; - -import "google/api/annotations.proto"; - -service Matchengine { - rpc RegisterUser(UserInfo) returns (UserInfo) { - option (google.api.http) = { - post : "/api/registeruser" - body : "*" - }; - } - rpc BalanceQuery(BalanceQueryRequest) returns (BalanceQueryResponse) { - option (google.api.http) = { - get : "/api/balances/{user_id}" - }; - } - rpc BalanceUpdate(BalanceUpdateRequest) returns (BalanceUpdateResponse) { - option (google.api.http) = { - post : "/api/updatebalance" - body : "*" - }; - } - rpc AssetList(AssetListRequest) returns (AssetListResponse) { - option (google.api.http) = { - get : "/api/assets" - }; - } - // rpc AssetSummary(AssetSummaryRequest) returns (AssetSummaryResponse) {} - rpc OrderPut(OrderPutRequest) returns (OrderInfo) { - option (google.api.http) = { - post : "/api/order" - body : "*" - }; - } - rpc OrderQuery(OrderQueryRequest) returns (OrderQueryResponse) { - option (google.api.http) = { - get : "/api/orders/{market}/{user_id}" - }; - } - rpc OrderCancel(OrderCancelRequest) returns (OrderInfo) { - option (google.api.http) = { - post : "/api/cancelorder/{market}/{user_id}/{order_id}" - body : "*" - }; - } - rpc OrderCancelAll(OrderCancelAllRequest) returns (OrderCancelAllResponse) { - option (google.api.http) = { - post : "/api/cancelorders/{market}/{user_id}" - body : "*" - }; - } - - // rpc OrderBook(OrderBookRequest) returns (OrderBookResponse) {} - rpc OrderBookDepth(OrderBookDepthRequest) returns (OrderBookDepthResponse) { - option (google.api.http) = { - get : "/api/depth/{market}/{limit}" - }; - } - rpc OrderDetail(OrderDetailRequest) returns (OrderInfo) {} - - rpc MarketList(MarketListRequest) returns (MarketListResponse) { - option (google.api.http) = { - get : "/api/markets" - }; - } - - rpc ReloadMarkets(ReloadMarketsRequest) returns (SimpleSuccessResponse) {} - rpc MarketSummary(MarketSummaryRequest) returns (MarketSummaryResponse) {} - - rpc Transfer(TransferRequest) returns (TransferResponse) { - option (google.api.http) = { - post : "/api/transfer" - body : "*" - }; - } - - // Used only in development - rpc DebugDump(DebugDumpRequest) returns (DebugDumpResponse) {} - rpc DebugReset(DebugResetRequest) returns (DebugResetResponse) {} - rpc DebugReload(DebugReloadRequest) returns (DebugReloadResponse) {} -} - -// -message UserInfo { - uint32 user_id = 1; - string l1_address = 2; - string l2_pubkey = 3; -} - -message BalanceQueryRequest { - uint32 user_id = 1; - repeated string assets = 2; // optional -} - -message BalanceQueryResponse { - message AssetBalance { - string asset_id = 1; - string available = 2; - string frozen = 3; - } - repeated AssetBalance balances = 1; -} - -message BalanceUpdateRequest { - uint32 user_id = 1; - string asset = 2; - string business = 3; - uint64 business_id = 4; - string delta = 5; - string detail = 6; -} - -message BalanceUpdateResponse {} - -message AssetListRequest { - // repeated string assets = 1; -} - -message AssetListResponse { - message AssetInfo { - string symbol = 1; - string name = 2; - int32 chain_id = 3; - string token_address = 4; - uint32 precision = 5; - string logo_uri = 6; - int32 inner_id = 7; - }; - repeated AssetInfo asset_lists = 1; -} -// -// internal? -message AssetSummaryRequest { repeated string assets = 1; } - -message AssetSummaryResponse { - message AssetSummaryInfo { - string name = 1; - string total_balance = 2; - int32 available_count = 3; - string available_balance = 4; - int32 frozen_count = 5; - string frozen_balance = 6; - } - repeated AssetSummaryInfo asset_summaries = 1; -} - -enum OrderSide { - ASK = 0; - BID = 1; -} - -enum OrderType { - LIMIT = 0; - MARKET = 1; -} - -message OrderPutRequest { - uint32 user_id = 1; - string market = 2; - OrderSide order_side = 3; - OrderType order_type = 4; - string amount = 5; // always amount for base, even for market bid - string price = 6; // should be empty or zero for market order - string quote_limit = 7; // onyl valid for market bid order - string taker_fee = 8; - string maker_fee = 9; - bool post_only = 10; // Ensures an Limit order is only subject to Maker Fees (ignored for Market orders). - string signature = 11; // bjj signature used in Fluidex -} - -message OrderInfo { - uint64 id = 1; - string market = 2; - OrderSide order_side = 3; - OrderType order_type = 4; - uint32 user_id = 5; - double create_time = 6; - double update_time = 7; - string price = 8; - string amount = 9; - string taker_fee = 10; - string maker_fee = 11; - string remain = 12; - string finished_base = 13; - string finished_quote = 14; - string finished_fee = 15; - bool post_only = 16; -} - -message OrderQueryRequest { - uint32 user_id = 1; - string market = 2; - int32 offset = 3; - int32 limit = 4; -} - -message OrderQueryResponse { - int32 offset = 1; - int32 limit = 2; - int32 total = 3; - repeated OrderInfo orders = 4; -} - -message OrderCancelRequest { - uint32 user_id = 1; - string market = 2; - uint64 order_id = 3; -} -message OrderCancelAllRequest { - uint32 user_id = 1; - string market = 2; -} -message OrderCancelAllResponse { uint32 total = 1; } - -// why not both side -message OrderBookRequest { - string market = 1; - OrderSide side = 2; - int32 offset = 3; - int32 limit = 4; -} - -// strange api -message OrderBookResponse { - int32 offset = 1; - int32 limit = 2; - uint64 total = 3; - repeated OrderInfo orders = 4; -} - -// with cache -message OrderBookDepthRequest { - string market = 1; - int32 limit = 2; - string interval = 3; -} - -message OrderBookDepthResponse { - message PriceInfo { - string price = 1; - string amount = 2; - } - repeated PriceInfo asks = 1; - repeated PriceInfo bids = 2; -} - -message OrderDetailRequest { - string market = 1; - uint64 order_id = 2; -} - -message MarketListRequest {} - -message MarketListResponse { - message MarketInfo { - string name = 1; - string base = 2; // base - string quote = 3; // quote - uint32 fee_precision = 4; - uint32 amount_precision = 5; - uint32 price_precision = 6; - string min_amount = 7; - } - repeated MarketInfo markets = 1; -} - -message MarketSummaryRequest { repeated string markets = 1; } - -message MarketSummaryResponse { - message MarketSummary { - string name = 1; - int32 ask_count = 2; - string ask_amount = 3; - int32 bid_count = 4; - string bid_amount = 5; - uint64 trade_count = 6; - } - repeated MarketSummary market_summaries = 1; -} - -message ReloadMarketsRequest { - bool from_scratch = 1; -} - -message SimpleSuccessResponse {} - -message TransferRequest { - uint32 from = 1; // user_id - uint32 to = 2; // user_id - string asset = 3; - string delta = 4; // should be > 0 - string memo = 5; -} - -message TransferResponse { - bool success = 1; - string asset = 2; - string balance_from = 3; -} -message DebugDumpRequest {} -message DebugDumpResponse {} -message DebugResetRequest {} -message DebugResetResponse {} -message DebugReloadRequest {} -message DebugReloadResponse {} diff --git a/proto/matchengine.pb b/proto/matchengine.pb deleted file mode 100644 index 9ec3de0e..00000000 Binary files a/proto/matchengine.pb and /dev/null differ diff --git a/proto/third_party/googleapis/LICENSE b/proto/third_party/googleapis/LICENSE deleted file mode 100644 index 261eeb9e..00000000 --- a/proto/third_party/googleapis/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. diff --git a/proto/third_party/googleapis/README.grpc-gateway b/proto/third_party/googleapis/README.grpc-gateway deleted file mode 100644 index b7d1bea3..00000000 --- a/proto/third_party/googleapis/README.grpc-gateway +++ /dev/null @@ -1,23 +0,0 @@ -Google APIs -============ - -Project: Google APIs -URL: https://github.com/google/googleapis -Revision: 3544ab16c3342d790b00764251e348705991ea4b -License: Apache License 2.0 - - -Imported Files ---------------- - -- google/api/annotations.proto -- google/api/http.proto -- google/api/httpbody.proto - - -Generated Files ----------------- - -They are generated from the .proto files by protoc-gen-go. -- google/api/annotations.pb.go -- google/api/http.pb.go diff --git a/proto/third_party/googleapis/google/api/annotations.proto b/proto/third_party/googleapis/google/api/annotations.proto deleted file mode 100644 index 85c361b4..00000000 --- a/proto/third_party/googleapis/google/api/annotations.proto +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2015, Google Inc. -// -// 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. - -syntax = "proto3"; - -package google.api; - -import "google/api/http.proto"; -import "google/protobuf/descriptor.proto"; - -option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; -option java_multiple_files = true; -option java_outer_classname = "AnnotationsProto"; -option java_package = "com.google.api"; -option objc_class_prefix = "GAPI"; - -extend google.protobuf.MethodOptions { - // See `HttpRule`. - HttpRule http = 72295728; -} diff --git a/proto/third_party/googleapis/google/api/field_behavior.proto b/proto/third_party/googleapis/google/api/field_behavior.proto deleted file mode 100644 index aa7127bf..00000000 --- a/proto/third_party/googleapis/google/api/field_behavior.proto +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2020 Google LLC -// -// 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. - -syntax = "proto3"; - -package google.api; - -import "google/protobuf/descriptor.proto"; - -option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; -option java_multiple_files = true; -option java_outer_classname = "FieldBehaviorProto"; -option java_package = "com.google.api"; -option objc_class_prefix = "GAPI"; - -extend google.protobuf.FieldOptions { - // A designation of a specific field behavior (required, output only, etc.) - // in protobuf messages. - // - // Examples: - // - // string name = 1 [(google.api.field_behavior) = REQUIRED]; - // State state = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - // google.protobuf.Duration ttl = 1 - // [(google.api.field_behavior) = INPUT_ONLY]; - // google.protobuf.Timestamp expire_time = 1 - // [(google.api.field_behavior) = OUTPUT_ONLY, - // (google.api.field_behavior) = IMMUTABLE]; - repeated google.api.FieldBehavior field_behavior = 1052; -} - -// An indicator of the behavior of a given field (for example, that a field -// is required in requests, or given as output but ignored as input). -// This **does not** change the behavior in protocol buffers itself; it only -// denotes the behavior and may affect how API tooling handles the field. -// -// Note: This enum **may** receive new values in the future. -enum FieldBehavior { - // Conventional default for enums. Do not use this. - FIELD_BEHAVIOR_UNSPECIFIED = 0; - - // Specifically denotes a field as optional. - // While all fields in protocol buffers are optional, this may be specified - // for emphasis if appropriate. - OPTIONAL = 1; - - // Denotes a field as required. - // This indicates that the field **must** be provided as part of the request, - // and failure to do so will cause an error (usually `INVALID_ARGUMENT`). - REQUIRED = 2; - - // Denotes a field as output only. - // This indicates that the field is provided in responses, but including the - // field in a request does nothing (the server *must* ignore it and - // *must not* throw an error as a result of the field's presence). - OUTPUT_ONLY = 3; - - // Denotes a field as input only. - // This indicates that the field is provided in requests, and the - // corresponding field is not included in output. - INPUT_ONLY = 4; - - // Denotes a field as immutable. - // This indicates that the field may be set once in a request to create a - // resource, but may not be changed thereafter. - IMMUTABLE = 5; -} diff --git a/proto/third_party/googleapis/google/api/http.proto b/proto/third_party/googleapis/google/api/http.proto deleted file mode 100644 index 2bd3a19b..00000000 --- a/proto/third_party/googleapis/google/api/http.proto +++ /dev/null @@ -1,318 +0,0 @@ -// Copyright 2018 Google LLC -// -// 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. - -syntax = "proto3"; - -package google.api; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; -option java_multiple_files = true; -option java_outer_classname = "HttpProto"; -option java_package = "com.google.api"; -option objc_class_prefix = "GAPI"; - - -// Defines the HTTP configuration for an API service. It contains a list of -// [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method -// to one or more HTTP REST API methods. -message Http { - // A list of HTTP configuration rules that apply to individual API methods. - // - // **NOTE:** All service configuration rules follow "last one wins" order. - repeated HttpRule rules = 1; - - // When set to true, URL path parmeters will be fully URI-decoded except in - // cases of single segment matches in reserved expansion, where "%2F" will be - // left encoded. - // - // The default behavior is to not decode RFC 6570 reserved characters in multi - // segment matches. - bool fully_decode_reserved_expansion = 2; -} - -// `HttpRule` defines the mapping of an RPC method to one or more HTTP -// REST API methods. The mapping specifies how different portions of the RPC -// request message are mapped to URL path, URL query parameters, and -// HTTP request body. The mapping is typically specified as an -// `google.api.http` annotation on the RPC method, -// see "google/api/annotations.proto" for details. -// -// The mapping consists of a field specifying the path template and -// method kind. The path template can refer to fields in the request -// message, as in the example below which describes a REST GET -// operation on a resource collection of messages: -// -// -// service Messaging { -// rpc GetMessage(GetMessageRequest) returns (Message) { -// option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; -// } -// } -// message GetMessageRequest { -// message SubMessage { -// string subfield = 1; -// } -// string message_id = 1; // mapped to the URL -// SubMessage sub = 2; // `sub.subfield` is url-mapped -// } -// message Message { -// string text = 1; // content of the resource -// } -// -// The same http annotation can alternatively be expressed inside the -// `GRPC API Configuration` YAML file. -// -// http: -// rules: -// - selector: .Messaging.GetMessage -// get: /v1/messages/{message_id}/{sub.subfield} -// -// This definition enables an automatic, bidrectional mapping of HTTP -// JSON to RPC. Example: -// -// HTTP | RPC -// -----|----- -// `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` -// -// In general, not only fields but also field paths can be referenced -// from a path pattern. Fields mapped to the path pattern cannot be -// repeated and must have a primitive (non-message) type. -// -// Any fields in the request message which are not bound by the path -// pattern automatically become (optional) HTTP query -// parameters. Assume the following definition of the request message: -// -// -// service Messaging { -// rpc GetMessage(GetMessageRequest) returns (Message) { -// option (google.api.http).get = "/v1/messages/{message_id}"; -// } -// } -// message GetMessageRequest { -// message SubMessage { -// string subfield = 1; -// } -// string message_id = 1; // mapped to the URL -// int64 revision = 2; // becomes a parameter -// SubMessage sub = 3; // `sub.subfield` becomes a parameter -// } -// -// -// This enables a HTTP JSON to RPC mapping as below: -// -// HTTP | RPC -// -----|----- -// `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` -// -// Note that fields which are mapped to HTTP parameters must have a -// primitive type or a repeated primitive type. Message types are not -// allowed. In the case of a repeated type, the parameter can be -// repeated in the URL, as in `...?param=A¶m=B`. -// -// For HTTP method kinds which allow a request body, the `body` field -// specifies the mapping. Consider a REST update method on the -// message resource collection: -// -// -// service Messaging { -// rpc UpdateMessage(UpdateMessageRequest) returns (Message) { -// option (google.api.http) = { -// put: "/v1/messages/{message_id}" -// body: "message" -// }; -// } -// } -// message UpdateMessageRequest { -// string message_id = 1; // mapped to the URL -// Message message = 2; // mapped to the body -// } -// -// -// The following HTTP JSON to RPC mapping is enabled, where the -// representation of the JSON in the request body is determined by -// protos JSON encoding: -// -// HTTP | RPC -// -----|----- -// `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` -// -// The special name `*` can be used in the body mapping to define that -// every field not bound by the path template should be mapped to the -// request body. This enables the following alternative definition of -// the update method: -// -// service Messaging { -// rpc UpdateMessage(Message) returns (Message) { -// option (google.api.http) = { -// put: "/v1/messages/{message_id}" -// body: "*" -// }; -// } -// } -// message Message { -// string message_id = 1; -// string text = 2; -// } -// -// -// The following HTTP JSON to RPC mapping is enabled: -// -// HTTP | RPC -// -----|----- -// `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` -// -// Note that when using `*` in the body mapping, it is not possible to -// have HTTP parameters, as all fields not bound by the path end in -// the body. This makes this option more rarely used in practice of -// defining REST APIs. The common usage of `*` is in custom methods -// which don't use the URL at all for transferring data. -// -// It is possible to define multiple HTTP methods for one RPC by using -// the `additional_bindings` option. Example: -// -// service Messaging { -// rpc GetMessage(GetMessageRequest) returns (Message) { -// option (google.api.http) = { -// get: "/v1/messages/{message_id}" -// additional_bindings { -// get: "/v1/users/{user_id}/messages/{message_id}" -// } -// }; -// } -// } -// message GetMessageRequest { -// string message_id = 1; -// string user_id = 2; -// } -// -// -// This enables the following two alternative HTTP JSON to RPC -// mappings: -// -// HTTP | RPC -// -----|----- -// `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` -// `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` -// -// # Rules for HTTP mapping -// -// The rules for mapping HTTP path, query parameters, and body fields -// to the request message are as follows: -// -// 1. The `body` field specifies either `*` or a field path, or is -// omitted. If omitted, it indicates there is no HTTP request body. -// 2. Leaf fields (recursive expansion of nested messages in the -// request) can be classified into three types: -// (a) Matched in the URL template. -// (b) Covered by body (if body is `*`, everything except (a) fields; -// else everything under the body field) -// (c) All other fields. -// 3. URL query parameters found in the HTTP request are mapped to (c) fields. -// 4. Any body sent with an HTTP request can contain only (b) fields. -// -// The syntax of the path template is as follows: -// -// Template = "/" Segments [ Verb ] ; -// Segments = Segment { "/" Segment } ; -// Segment = "*" | "**" | LITERAL | Variable ; -// Variable = "{" FieldPath [ "=" Segments ] "}" ; -// FieldPath = IDENT { "." IDENT } ; -// Verb = ":" LITERAL ; -// -// The syntax `*` matches a single path segment. The syntax `**` matches zero -// or more path segments, which must be the last part of the path except the -// `Verb`. The syntax `LITERAL` matches literal text in the path. -// -// The syntax `Variable` matches part of the URL path as specified by its -// template. A variable template must not contain other variables. If a variable -// matches a single path segment, its template may be omitted, e.g. `{var}` -// is equivalent to `{var=*}`. -// -// If a variable contains exactly one path segment, such as `"{var}"` or -// `"{var=*}"`, when such a variable is expanded into a URL path, all characters -// except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the -// Discovery Document as `{var}`. -// -// If a variable contains one or more path segments, such as `"{var=foo/*}"` -// or `"{var=**}"`, when such a variable is expanded into a URL path, all -// characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables -// show up in the Discovery Document as `{+var}`. -// -// NOTE: While the single segment variable matches the semantics of -// [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 -// Simple String Expansion, the multi segment variable **does not** match -// RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion -// does not expand special characters like `?` and `#`, which would lead -// to invalid URLs. -// -// NOTE: the field paths in variables and in the `body` must not refer to -// repeated fields or map fields. -message HttpRule { - // Selects methods to which this rule applies. - // - // Refer to [selector][google.api.DocumentationRule.selector] for syntax details. - string selector = 1; - - // Determines the URL pattern is matched by this rules. This pattern can be - // used with any of the {get|put|post|delete|patch} methods. A custom method - // can be defined using the 'custom' field. - oneof pattern { - // Used for listing and getting information about resources. - string get = 2; - - // Used for updating a resource. - string put = 3; - - // Used for creating a resource. - string post = 4; - - // Used for deleting a resource. - string delete = 5; - - // Used for updating a resource. - string patch = 6; - - // The custom pattern is used for specifying an HTTP method that is not - // included in the `pattern` field, such as HEAD, or "*" to leave the - // HTTP method unspecified for this rule. The wild-card rule is useful - // for services that provide content to Web (HTML) clients. - CustomHttpPattern custom = 8; - } - - // The name of the request field whose value is mapped to the HTTP body, or - // `*` for mapping all fields not captured by the path pattern to the HTTP - // body. NOTE: the referred field must not be a repeated field and must be - // present at the top-level of request message type. - string body = 7; - - // Optional. The name of the response field whose value is mapped to the HTTP - // body of response. Other response fields are ignored. When - // not set, the response message will be used as HTTP body of response. - string response_body = 12; - - // Additional HTTP bindings for the selector. Nested bindings must - // not contain an `additional_bindings` field themselves (that is, - // the nesting may only be one level deep). - repeated HttpRule additional_bindings = 11; -} - -// A custom pattern is used for defining custom HTTP verb. -message CustomHttpPattern { - // The name of this custom HTTP verb. - string kind = 1; - - // The path matched by this custom verb. - string path = 2; -} diff --git a/proto/third_party/googleapis/google/api/httpbody.proto b/proto/third_party/googleapis/google/api/httpbody.proto deleted file mode 100644 index 4428515c..00000000 --- a/proto/third_party/googleapis/google/api/httpbody.proto +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2018 Google LLC. -// -// 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. -// - -syntax = "proto3"; - -package google.api; - -import "google/protobuf/any.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/api/httpbody;httpbody"; -option java_multiple_files = true; -option java_outer_classname = "HttpBodyProto"; -option java_package = "com.google.api"; -option objc_class_prefix = "GAPI"; - -// Message that represents an arbitrary HTTP body. It should only be used for -// payload formats that can't be represented as JSON, such as raw binary or -// an HTML page. -// -// -// This message can be used both in streaming and non-streaming API methods in -// the request as well as the response. -// -// It can be used as a top-level request field, which is convenient if one -// wants to extract parameters from either the URL or HTTP template into the -// request fields and also want access to the raw HTTP body. -// -// Example: -// -// message GetResourceRequest { -// // A unique request id. -// string request_id = 1; -// -// // The raw HTTP body is bound to this field. -// google.api.HttpBody http_body = 2; -// } -// -// service ResourceService { -// rpc GetResource(GetResourceRequest) returns (google.api.HttpBody); -// rpc UpdateResource(google.api.HttpBody) returns -// (google.protobuf.Empty); -// } -// -// Example with streaming methods: -// -// service CaldavService { -// rpc GetCalendar(stream google.api.HttpBody) -// returns (stream google.api.HttpBody); -// rpc UpdateCalendar(stream google.api.HttpBody) -// returns (stream google.api.HttpBody); -// } -// -// Use of this type only changes how the request and response bodies are -// handled, all other features will continue to work unchanged. -message HttpBody { - // The HTTP Content-Type header value specifying the content type of the body. - string content_type = 1; - - // The HTTP request/response body as raw binary. - bytes data = 2; - - // Application specific response metadata. Must be set in the first response - // for streaming APIs. - repeated google.protobuf.Any extensions = 3; -} \ No newline at end of file diff --git a/proto/third_party/googleapis/google/rpc/code.proto b/proto/third_party/googleapis/google/rpc/code.proto deleted file mode 100644 index 8fef4117..00000000 --- a/proto/third_party/googleapis/google/rpc/code.proto +++ /dev/null @@ -1,186 +0,0 @@ -// Copyright 2017 Google Inc. -// -// 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. - -syntax = "proto3"; - -package google.rpc; - -option go_package = "google.golang.org/genproto/googleapis/rpc/code;code"; -option java_multiple_files = true; -option java_outer_classname = "CodeProto"; -option java_package = "com.google.rpc"; -option objc_class_prefix = "RPC"; - - -// The canonical error codes for Google APIs. -// -// -// Sometimes multiple error codes may apply. Services should return -// the most specific error code that applies. For example, prefer -// `OUT_OF_RANGE` over `FAILED_PRECONDITION` if both codes apply. -// Similarly prefer `NOT_FOUND` or `ALREADY_EXISTS` over `FAILED_PRECONDITION`. -enum Code { - // Not an error; returned on success - // - // HTTP Mapping: 200 OK - OK = 0; - - // The operation was cancelled, typically by the caller. - // - // HTTP Mapping: 499 Client Closed Request - CANCELLED = 1; - - // Unknown error. For example, this error may be returned when - // a `Status` value received from another address space belongs to - // an error space that is not known in this address space. Also - // errors raised by APIs that do not return enough error information - // may be converted to this error. - // - // HTTP Mapping: 500 Internal Server Error - UNKNOWN = 2; - - // The client specified an invalid argument. Note that this differs - // from `FAILED_PRECONDITION`. `INVALID_ARGUMENT` indicates arguments - // that are problematic regardless of the state of the system - // (e.g., a malformed file name). - // - // HTTP Mapping: 400 Bad Request - INVALID_ARGUMENT = 3; - - // The deadline expired before the operation could complete. For operations - // that change the state of the system, this error may be returned - // even if the operation has completed successfully. For example, a - // successful response from a server could have been delayed long - // enough for the deadline to expire. - // - // HTTP Mapping: 504 Gateway Timeout - DEADLINE_EXCEEDED = 4; - - // Some requested entity (e.g., file or directory) was not found. - // - // Note to server developers: if a request is denied for an entire class - // of users, such as gradual feature rollout or undocumented whitelist, - // `NOT_FOUND` may be used. If a request is denied for some users within - // a class of users, such as user-based access control, `PERMISSION_DENIED` - // must be used. - // - // HTTP Mapping: 404 Not Found - NOT_FOUND = 5; - - // The entity that a client attempted to create (e.g., file or directory) - // already exists. - // - // HTTP Mapping: 409 Conflict - ALREADY_EXISTS = 6; - - // The caller does not have permission to execute the specified - // operation. `PERMISSION_DENIED` must not be used for rejections - // caused by exhausting some resource (use `RESOURCE_EXHAUSTED` - // instead for those errors). `PERMISSION_DENIED` must not be - // used if the caller can not be identified (use `UNAUTHENTICATED` - // instead for those errors). This error code does not imply the - // request is valid or the requested entity exists or satisfies - // other pre-conditions. - // - // HTTP Mapping: 403 Forbidden - PERMISSION_DENIED = 7; - - // The request does not have valid authentication credentials for the - // operation. - // - // HTTP Mapping: 401 Unauthorized - UNAUTHENTICATED = 16; - - // Some resource has been exhausted, perhaps a per-user quota, or - // perhaps the entire file system is out of space. - // - // HTTP Mapping: 429 Too Many Requests - RESOURCE_EXHAUSTED = 8; - - // The operation was rejected because the system is not in a state - // required for the operation's execution. For example, the directory - // to be deleted is non-empty, an rmdir operation is applied to - // a non-directory, etc. - // - // Service implementors can use the following guidelines to decide - // between `FAILED_PRECONDITION`, `ABORTED`, and `UNAVAILABLE`: - // (a) Use `UNAVAILABLE` if the client can retry just the failing call. - // (b) Use `ABORTED` if the client should retry at a higher level - // (e.g., when a client-specified test-and-set fails, indicating the - // client should restart a read-modify-write sequence). - // (c) Use `FAILED_PRECONDITION` if the client should not retry until - // the system state has been explicitly fixed. E.g., if an "rmdir" - // fails because the directory is non-empty, `FAILED_PRECONDITION` - // should be returned since the client should not retry unless - // the files are deleted from the directory. - // - // HTTP Mapping: 400 Bad Request - FAILED_PRECONDITION = 9; - - // The operation was aborted, typically due to a concurrency issue such as - // a sequencer check failure or transaction abort. - // - // See the guidelines above for deciding between `FAILED_PRECONDITION`, - // `ABORTED`, and `UNAVAILABLE`. - // - // HTTP Mapping: 409 Conflict - ABORTED = 10; - - // The operation was attempted past the valid range. E.g., seeking or - // reading past end-of-file. - // - // Unlike `INVALID_ARGUMENT`, this error indicates a problem that may - // be fixed if the system state changes. For example, a 32-bit file - // system will generate `INVALID_ARGUMENT` if asked to read at an - // offset that is not in the range [0,2^32-1], but it will generate - // `OUT_OF_RANGE` if asked to read from an offset past the current - // file size. - // - // There is a fair bit of overlap between `FAILED_PRECONDITION` and - // `OUT_OF_RANGE`. We recommend using `OUT_OF_RANGE` (the more specific - // error) when it applies so that callers who are iterating through - // a space can easily look for an `OUT_OF_RANGE` error to detect when - // they are done. - // - // HTTP Mapping: 400 Bad Request - OUT_OF_RANGE = 11; - - // The operation is not implemented or is not supported/enabled in this - // service. - // - // HTTP Mapping: 501 Not Implemented - UNIMPLEMENTED = 12; - - // Internal errors. This means that some invariants expected by the - // underlying system have been broken. This error code is reserved - // for serious errors. - // - // HTTP Mapping: 500 Internal Server Error - INTERNAL = 13; - - // The service is currently unavailable. This is most likely a - // transient condition, which can be corrected by retrying with - // a backoff. - // - // See the guidelines above for deciding between `FAILED_PRECONDITION`, - // `ABORTED`, and `UNAVAILABLE`. - // - // HTTP Mapping: 503 Service Unavailable - UNAVAILABLE = 14; - - // Unrecoverable data loss or corruption. - // - // HTTP Mapping: 500 Internal Server Error - DATA_LOSS = 15; -} diff --git a/proto/third_party/googleapis/google/rpc/error_details.proto b/proto/third_party/googleapis/google/rpc/error_details.proto deleted file mode 100644 index f24ae009..00000000 --- a/proto/third_party/googleapis/google/rpc/error_details.proto +++ /dev/null @@ -1,200 +0,0 @@ -// Copyright 2017 Google Inc. -// -// 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. - -syntax = "proto3"; - -package google.rpc; - -import "google/protobuf/duration.proto"; - -option go_package = "google.golang.org/genproto/googleapis/rpc/errdetails;errdetails"; -option java_multiple_files = true; -option java_outer_classname = "ErrorDetailsProto"; -option java_package = "com.google.rpc"; -option objc_class_prefix = "RPC"; - - -// Describes when the clients can retry a failed request. Clients could ignore -// the recommendation here or retry when this information is missing from error -// responses. -// -// It's always recommended that clients should use exponential backoff when -// retrying. -// -// Clients should wait until `retry_delay` amount of time has passed since -// receiving the error response before retrying. If retrying requests also -// fail, clients should use an exponential backoff scheme to gradually increase -// the delay between retries based on `retry_delay`, until either a maximum -// number of retires have been reached or a maximum retry delay cap has been -// reached. -message RetryInfo { - // Clients should wait at least this long between retrying the same request. - google.protobuf.Duration retry_delay = 1; -} - -// Describes additional debugging info. -message DebugInfo { - // The stack trace entries indicating where the error occurred. - repeated string stack_entries = 1; - - // Additional debugging information provided by the server. - string detail = 2; -} - -// Describes how a quota check failed. -// -// For example if a daily limit was exceeded for the calling project, -// a service could respond with a QuotaFailure detail containing the project -// id and the description of the quota limit that was exceeded. If the -// calling project hasn't enabled the service in the developer console, then -// a service could respond with the project id and set `service_disabled` -// to true. -// -// Also see RetryDetail and Help types for other details about handling a -// quota failure. -message QuotaFailure { - // A message type used to describe a single quota violation. For example, a - // daily quota or a custom quota that was exceeded. - message Violation { - // The subject on which the quota check failed. - // For example, "clientip:" or "project:". - string subject = 1; - - // A description of how the quota check failed. Clients can use this - // description to find more about the quota configuration in the service's - // public documentation, or find the relevant quota limit to adjust through - // developer console. - // - // For example: "Service disabled" or "Daily Limit for read operations - // exceeded". - string description = 2; - } - - // Describes all quota violations. - repeated Violation violations = 1; -} - -// Describes what preconditions have failed. -// -// For example, if an RPC failed because it required the Terms of Service to be -// acknowledged, it could list the terms of service violation in the -// PreconditionFailure message. -message PreconditionFailure { - // A message type used to describe a single precondition failure. - message Violation { - // The type of PreconditionFailure. We recommend using a service-specific - // enum type to define the supported precondition violation types. For - // example, "TOS" for "Terms of Service violation". - string type = 1; - - // The subject, relative to the type, that failed. - // For example, "google.com/cloud" relative to the "TOS" type would - // indicate which terms of service is being referenced. - string subject = 2; - - // A description of how the precondition failed. Developers can use this - // description to understand how to fix the failure. - // - // For example: "Terms of service not accepted". - string description = 3; - } - - // Describes all precondition violations. - repeated Violation violations = 1; -} - -// Describes violations in a client request. This error type focuses on the -// syntactic aspects of the request. -message BadRequest { - // A message type used to describe a single bad request field. - message FieldViolation { - // A path leading to a field in the request body. The value will be a - // sequence of dot-separated identifiers that identify a protocol buffer - // field. E.g., "field_violations.field" would identify this field. - string field = 1; - - // A description of why the request element is bad. - string description = 2; - } - - // Describes all violations in a client request. - repeated FieldViolation field_violations = 1; -} - -// Contains metadata about the request that clients can attach when filing a bug -// or providing other forms of feedback. -message RequestInfo { - // An opaque string that should only be interpreted by the service generating - // it. For example, it can be used to identify requests in the service's logs. - string request_id = 1; - - // Any data that was used to serve this request. For example, an encrypted - // stack trace that can be sent back to the service provider for debugging. - string serving_data = 2; -} - -// Describes the resource that is being accessed. -message ResourceInfo { - // A name for the type of resource being accessed, e.g. "sql table", - // "cloud storage bucket", "file", "Google calendar"; or the type URL - // of the resource: e.g. "type.googleapis.com/google.pubsub.v1.Topic". - string resource_type = 1; - - // The name of the resource being accessed. For example, a shared calendar - // name: "example.com_4fghdhgsrgh@group.calendar.google.com", if the current - // error is [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED]. - string resource_name = 2; - - // The owner of the resource (optional). - // For example, "user:" or "project:". - string owner = 3; - - // Describes what error is encountered when accessing this resource. - // For example, updating a cloud project may require the `writer` permission - // on the developer console project. - string description = 4; -} - -// Provides links to documentation or for performing an out of band action. -// -// For example, if a quota check failed with an error indicating the calling -// project hasn't enabled the accessed service, this can contain a URL pointing -// directly to the right place in the developer console to flip the bit. -message Help { - // Describes a URL link. - message Link { - // Describes what the link offers. - string description = 1; - - // The URL of the link. - string url = 2; - } - - // URL(s) pointing to additional information on handling the current error. - repeated Link links = 1; -} - -// Provides a localized error message that is safe to return to the user -// which can be attached to an RPC error. -message LocalizedMessage { - // The locale used following the specification defined at - // http://www.rfc-editor.org/rfc/bcp/bcp47.txt. - // Examples are: "en-US", "fr-CH", "es-MX" - string locale = 1; - - // The localized error message in the above locale. - string message = 2; -} diff --git a/proto/third_party/googleapis/google/rpc/status.proto b/proto/third_party/googleapis/google/rpc/status.proto deleted file mode 100644 index 0839ee96..00000000 --- a/proto/third_party/googleapis/google/rpc/status.proto +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2017 Google Inc. -// -// 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. - -syntax = "proto3"; - -package google.rpc; - -import "google/protobuf/any.proto"; - -option go_package = "google.golang.org/genproto/googleapis/rpc/status;status"; -option java_multiple_files = true; -option java_outer_classname = "StatusProto"; -option java_package = "com.google.rpc"; -option objc_class_prefix = "RPC"; - - -// The `Status` type defines a logical error model that is suitable for different -// programming environments, including REST APIs and RPC APIs. It is used by -// [gRPC](https://github.com/grpc). The error model is designed to be: -// -// - Simple to use and understand for most users -// - Flexible enough to meet unexpected needs -// -// # Overview -// -// The `Status` message contains three pieces of data: error code, error message, -// and error details. The error code should be an enum value of -// [google.rpc.Code][google.rpc.Code], but it may accept additional error codes if needed. The -// error message should be a developer-facing English message that helps -// developers *understand* and *resolve* the error. If a localized user-facing -// error message is needed, put the localized message in the error details or -// localize it in the client. The optional error details may contain arbitrary -// information about the error. There is a predefined set of error detail types -// in the package `google.rpc` that can be used for common error conditions. -// -// # Language mapping -// -// The `Status` message is the logical representation of the error model, but it -// is not necessarily the actual wire format. When the `Status` message is -// exposed in different client libraries and different wire protocols, it can be -// mapped differently. For example, it will likely be mapped to some exceptions -// in Java, but more likely mapped to some error codes in C. -// -// # Other uses -// -// The error model and the `Status` message can be used in a variety of -// environments, either with or without APIs, to provide a -// consistent developer experience across different environments. -// -// Example uses of this error model include: -// -// - Partial errors. If a service needs to return partial errors to the client, -// it may embed the `Status` in the normal response to indicate the partial -// errors. -// -// - Workflow errors. A typical workflow has multiple steps. Each step may -// have a `Status` message for error reporting. -// -// - Batch operations. If a client uses batch request and batch response, the -// `Status` message should be used directly inside batch response, one for -// each error sub-response. -// -// - Asynchronous operations. If an API call embeds asynchronous operation -// results in its response, the status of those operations should be -// represented directly using the `Status` message. -// -// - Logging. If some API errors are stored in logs, the message `Status` could -// be used directly after any stripping needed for security/privacy reasons. -message Status { - // The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - int32 code = 1; - - // A developer-facing error message, which should be in English. Any - // user-facing error message should be localized and sent in the - // [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - string message = 2; - - // A list of messages that carry the error details. There is a common set of - // message types for APIs to use. - repeated google.protobuf.Any details = 3; -} diff --git a/src/bin/matchengine.rs b/src/bin/matchengine.rs index 2dfc9603..89b0d41c 100644 --- a/src/bin/matchengine.rs +++ b/src/bin/matchengine.rs @@ -7,13 +7,13 @@ use dingir_exchange::config; use dingir_exchange::controller::create_controller; -use dingir_exchange::matchengine::rpc::matchengine_server::MatchengineServer; use dingir_exchange::persist; use dingir_exchange::server::GrpcHandler; //use dingir_exchange::sqlxextend; use dingir_exchange::types::ConnectionType; use fluidex_common::non_blocking_tracing; +use orchestra::rpc::exchange::matchengine_server::MatchengineServer; use sqlx::Connection; fn main() { diff --git a/src/matchengine/asset/asset_manager.rs b/src/matchengine/asset/asset_manager.rs index 97e819cc..13b1a96f 100644 --- a/src/matchengine/asset/asset_manager.rs +++ b/src/matchengine/asset/asset_manager.rs @@ -1,10 +1,10 @@ use crate::config; use crate::market::{Market, OrderCommitment}; -use crate::matchengine::rpc::*; use anyhow::{bail, Result}; use fluidex_common::rust_decimal::{self, RoundingStrategy}; use fluidex_common::types::{DecimalExt, FrExt}; use fluidex_common::Fr; +use orchestra::rpc::exchange::*; use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::str::FromStr; diff --git a/src/matchengine/controller.rs b/src/matchengine/controller.rs index 8aca4df7..e3da9dd7 100644 --- a/src/matchengine/controller.rs +++ b/src/matchengine/controller.rs @@ -1,4 +1,3 @@ -use super::rpc::*; use crate::asset::{BalanceManager, BalanceType, BalanceUpdateController}; use crate::config::{self}; use crate::database::{DatabaseWriterConfig, OperationLogSender}; @@ -17,6 +16,7 @@ use anyhow::{anyhow, bail}; use fluidex_common::helper::{MergeSortIterator, Order as SortOrder}; use fluidex_common::rust_decimal::prelude::Zero; use fluidex_common::rust_decimal::Decimal; +use orchestra::rpc::exchange::*; use serde::Serialize; use serde_json::json; use sqlx::Connection; diff --git a/src/matchengine/dto.rs b/src/matchengine/dto.rs index 3fea77b1..c77a61c3 100644 --- a/src/matchengine/dto.rs +++ b/src/matchengine/dto.rs @@ -1,9 +1,9 @@ -use super::rpc::*; use crate::market; use anyhow::{anyhow, bail, Result}; use arrayref::array_ref; use fluidex_common::rust_decimal::{self, prelude::Zero, Decimal}; +use orchestra::rpc::exchange::*; use std::convert::TryFrom; use std::str::FromStr; diff --git a/src/matchengine/mod.rs b/src/matchengine/mod.rs index 6a0e5af1..4ec55567 100644 --- a/src/matchengine/mod.rs +++ b/src/matchengine/mod.rs @@ -4,7 +4,6 @@ pub mod dto; pub mod history; pub mod market; pub mod persist; -pub mod rpc; pub mod sequencer; pub mod server; pub mod user_manager; diff --git a/src/matchengine/rpc/google.api.rs b/src/matchengine/rpc/google.api.rs deleted file mode 100644 index e2e1e24c..00000000 --- a/src/matchengine/rpc/google.api.rs +++ /dev/null @@ -1,305 +0,0 @@ -/// Defines the HTTP configuration for an API service. It contains a list of -/// [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method -/// to one or more HTTP REST API methods. -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct Http { - /// A list of HTTP configuration rules that apply to individual API methods. - /// - /// **NOTE:** All service configuration rules follow "last one wins" order. - #[prost(message, repeated, tag = "1")] - pub rules: ::prost::alloc::vec::Vec, - /// When set to true, URL path parmeters will be fully URI-decoded except in - /// cases of single segment matches in reserved expansion, where "%2F" will be - /// left encoded. - /// - /// The default behavior is to not decode RFC 6570 reserved characters in multi - /// segment matches. - #[prost(bool, tag = "2")] - pub fully_decode_reserved_expansion: bool, -} -/// `HttpRule` defines the mapping of an RPC method to one or more HTTP -/// REST API methods. The mapping specifies how different portions of the RPC -/// request message are mapped to URL path, URL query parameters, and -/// HTTP request body. The mapping is typically specified as an -/// `google.api.http` annotation on the RPC method, -/// see "google/api/annotations.proto" for details. -/// -/// The mapping consists of a field specifying the path template and -/// method kind. The path template can refer to fields in the request -/// message, as in the example below which describes a REST GET -/// operation on a resource collection of messages: -/// -/// -/// service Messaging { -/// rpc GetMessage(GetMessageRequest) returns (Message) { -/// option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; -/// } -/// } -/// message GetMessageRequest { -/// message SubMessage { -/// string subfield = 1; -/// } -/// string message_id = 1; // mapped to the URL -/// SubMessage sub = 2; // `sub.subfield` is url-mapped -/// } -/// message Message { -/// string text = 1; // content of the resource -/// } -/// -/// The same http annotation can alternatively be expressed inside the -/// `GRPC API Configuration` YAML file. -/// -/// http: -/// rules: -/// - selector: .Messaging.GetMessage -/// get: /v1/messages/{message_id}/{sub.subfield} -/// -/// This definition enables an automatic, bidrectional mapping of HTTP -/// JSON to RPC. Example: -/// -/// HTTP | RPC -/// -----|----- -/// `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` -/// -/// In general, not only fields but also field paths can be referenced -/// from a path pattern. Fields mapped to the path pattern cannot be -/// repeated and must have a primitive (non-message) type. -/// -/// Any fields in the request message which are not bound by the path -/// pattern automatically become (optional) HTTP query -/// parameters. Assume the following definition of the request message: -/// -/// -/// service Messaging { -/// rpc GetMessage(GetMessageRequest) returns (Message) { -/// option (google.api.http).get = "/v1/messages/{message_id}"; -/// } -/// } -/// message GetMessageRequest { -/// message SubMessage { -/// string subfield = 1; -/// } -/// string message_id = 1; // mapped to the URL -/// int64 revision = 2; // becomes a parameter -/// SubMessage sub = 3; // `sub.subfield` becomes a parameter -/// } -/// -/// -/// This enables a HTTP JSON to RPC mapping as below: -/// -/// HTTP | RPC -/// -----|----- -/// `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` -/// -/// Note that fields which are mapped to HTTP parameters must have a -/// primitive type or a repeated primitive type. Message types are not -/// allowed. In the case of a repeated type, the parameter can be -/// repeated in the URL, as in `...?param=A¶m=B`. -/// -/// For HTTP method kinds which allow a request body, the `body` field -/// specifies the mapping. Consider a REST update method on the -/// message resource collection: -/// -/// -/// service Messaging { -/// rpc UpdateMessage(UpdateMessageRequest) returns (Message) { -/// option (google.api.http) = { -/// put: "/v1/messages/{message_id}" -/// body: "message" -/// }; -/// } -/// } -/// message UpdateMessageRequest { -/// string message_id = 1; // mapped to the URL -/// Message message = 2; // mapped to the body -/// } -/// -/// -/// The following HTTP JSON to RPC mapping is enabled, where the -/// representation of the JSON in the request body is determined by -/// protos JSON encoding: -/// -/// HTTP | RPC -/// -----|----- -/// `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` -/// -/// The special name `*` can be used in the body mapping to define that -/// every field not bound by the path template should be mapped to the -/// request body. This enables the following alternative definition of -/// the update method: -/// -/// service Messaging { -/// rpc UpdateMessage(Message) returns (Message) { -/// option (google.api.http) = { -/// put: "/v1/messages/{message_id}" -/// body: "*" -/// }; -/// } -/// } -/// message Message { -/// string message_id = 1; -/// string text = 2; -/// } -/// -/// -/// The following HTTP JSON to RPC mapping is enabled: -/// -/// HTTP | RPC -/// -----|----- -/// `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` -/// -/// Note that when using `*` in the body mapping, it is not possible to -/// have HTTP parameters, as all fields not bound by the path end in -/// the body. This makes this option more rarely used in practice of -/// defining REST APIs. The common usage of `*` is in custom methods -/// which don't use the URL at all for transferring data. -/// -/// It is possible to define multiple HTTP methods for one RPC by using -/// the `additional_bindings` option. Example: -/// -/// service Messaging { -/// rpc GetMessage(GetMessageRequest) returns (Message) { -/// option (google.api.http) = { -/// get: "/v1/messages/{message_id}" -/// additional_bindings { -/// get: "/v1/users/{user_id}/messages/{message_id}" -/// } -/// }; -/// } -/// } -/// message GetMessageRequest { -/// string message_id = 1; -/// string user_id = 2; -/// } -/// -/// -/// This enables the following two alternative HTTP JSON to RPC -/// mappings: -/// -/// HTTP | RPC -/// -----|----- -/// `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` -/// `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` -/// -/// # Rules for HTTP mapping -/// -/// The rules for mapping HTTP path, query parameters, and body fields -/// to the request message are as follows: -/// -/// 1. The `body` field specifies either `*` or a field path, or is -/// omitted. If omitted, it indicates there is no HTTP request body. -/// 2. Leaf fields (recursive expansion of nested messages in the -/// request) can be classified into three types: -/// (a) Matched in the URL template. -/// (b) Covered by body (if body is `*`, everything except (a) fields; -/// else everything under the body field) -/// (c) All other fields. -/// 3. URL query parameters found in the HTTP request are mapped to (c) fields. -/// 4. Any body sent with an HTTP request can contain only (b) fields. -/// -/// The syntax of the path template is as follows: -/// -/// Template = "/" Segments [ Verb ] ; -/// Segments = Segment { "/" Segment } ; -/// Segment = "*" | "**" | LITERAL | Variable ; -/// Variable = "{" FieldPath [ "=" Segments ] "}" ; -/// FieldPath = IDENT { "." IDENT } ; -/// Verb = ":" LITERAL ; -/// -/// The syntax `*` matches a single path segment. The syntax `**` matches zero -/// or more path segments, which must be the last part of the path except the -/// `Verb`. The syntax `LITERAL` matches literal text in the path. -/// -/// The syntax `Variable` matches part of the URL path as specified by its -/// template. A variable template must not contain other variables. If a variable -/// matches a single path segment, its template may be omitted, e.g. `{var}` -/// is equivalent to `{var=*}`. -/// -/// If a variable contains exactly one path segment, such as `"{var}"` or -/// `"{var=*}"`, when such a variable is expanded into a URL path, all characters -/// except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the -/// Discovery Document as `{var}`. -/// -/// If a variable contains one or more path segments, such as `"{var=foo/*}"` -/// or `"{var=**}"`, when such a variable is expanded into a URL path, all -/// characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables -/// show up in the Discovery Document as `{+var}`. -/// -/// NOTE: While the single segment variable matches the semantics of -/// [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 -/// Simple String Expansion, the multi segment variable **does not** match -/// RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion -/// does not expand special characters like `?` and `#`, which would lead -/// to invalid URLs. -/// -/// NOTE: the field paths in variables and in the `body` must not refer to -/// repeated fields or map fields. -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct HttpRule { - /// Selects methods to which this rule applies. - /// - /// Refer to [selector][google.api.DocumentationRule.selector] for syntax details. - #[prost(string, tag = "1")] - pub selector: ::prost::alloc::string::String, - /// The name of the request field whose value is mapped to the HTTP body, or - /// `*` for mapping all fields not captured by the path pattern to the HTTP - /// body. NOTE: the referred field must not be a repeated field and must be - /// present at the top-level of request message type. - #[prost(string, tag = "7")] - pub body: ::prost::alloc::string::String, - /// Optional. The name of the response field whose value is mapped to the HTTP - /// body of response. Other response fields are ignored. When - /// not set, the response message will be used as HTTP body of response. - #[prost(string, tag = "12")] - pub response_body: ::prost::alloc::string::String, - /// Additional HTTP bindings for the selector. Nested bindings must - /// not contain an `additional_bindings` field themselves (that is, - /// the nesting may only be one level deep). - #[prost(message, repeated, tag = "11")] - pub additional_bindings: ::prost::alloc::vec::Vec, - /// Determines the URL pattern is matched by this rules. This pattern can be - /// used with any of the {get|put|post|delete|patch} methods. A custom method - /// can be defined using the 'custom' field. - #[prost(oneof = "http_rule::Pattern", tags = "2, 3, 4, 5, 6, 8")] - pub pattern: ::core::option::Option, -} -/// Nested message and enum types in `HttpRule`. -pub mod http_rule { - /// Determines the URL pattern is matched by this rules. This pattern can be - /// used with any of the {get|put|post|delete|patch} methods. A custom method - /// can be defined using the 'custom' field. - #[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Oneof)] - pub enum Pattern { - /// Used for listing and getting information about resources. - #[prost(string, tag = "2")] - Get(::prost::alloc::string::String), - /// Used for updating a resource. - #[prost(string, tag = "3")] - Put(::prost::alloc::string::String), - /// Used for creating a resource. - #[prost(string, tag = "4")] - Post(::prost::alloc::string::String), - /// Used for deleting a resource. - #[prost(string, tag = "5")] - Delete(::prost::alloc::string::String), - /// Used for updating a resource. - #[prost(string, tag = "6")] - Patch(::prost::alloc::string::String), - /// The custom pattern is used for specifying an HTTP method that is not - /// included in the `pattern` field, such as HEAD, or "*" to leave the - /// HTTP method unspecified for this rule. The wild-card rule is useful - /// for services that provide content to Web (HTML) clients. - #[prost(message, tag = "8")] - Custom(super::CustomHttpPattern), - } -} -/// A custom pattern is used for defining custom HTTP verb. -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct CustomHttpPattern { - /// The name of this custom HTTP verb. - #[prost(string, tag = "1")] - pub kind: ::prost::alloc::string::String, - /// The path matched by this custom verb. - #[prost(string, tag = "2")] - pub path: ::prost::alloc::string::String, -} diff --git a/src/matchengine/rpc/google.protobuf.rs b/src/matchengine/rpc/google.protobuf.rs deleted file mode 100644 index 8b137891..00000000 --- a/src/matchengine/rpc/google.protobuf.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/matchengine/rpc/matchengine.rs b/src/matchengine/rpc/matchengine.rs deleted file mode 100644 index a9ffd6a1..00000000 --- a/src/matchengine/rpc/matchengine.rs +++ /dev/null @@ -1,1256 +0,0 @@ -/// -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct UserInfo { - #[prost(uint32, tag = "1")] - pub user_id: u32, - #[prost(string, tag = "2")] - pub l1_address: ::prost::alloc::string::String, - #[prost(string, tag = "3")] - pub l2_pubkey: ::prost::alloc::string::String, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct BalanceQueryRequest { - #[prost(uint32, tag = "1")] - pub user_id: u32, - /// optional - #[prost(string, repeated, tag = "2")] - pub assets: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct BalanceQueryResponse { - #[prost(message, repeated, tag = "1")] - pub balances: ::prost::alloc::vec::Vec, -} -/// Nested message and enum types in `BalanceQueryResponse`. -pub mod balance_query_response { - #[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] - pub struct AssetBalance { - #[prost(string, tag = "1")] - pub asset_id: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub available: ::prost::alloc::string::String, - #[prost(string, tag = "3")] - pub frozen: ::prost::alloc::string::String, - } -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct BalanceUpdateRequest { - #[prost(uint32, tag = "1")] - pub user_id: u32, - #[prost(string, tag = "2")] - pub asset: ::prost::alloc::string::String, - #[prost(string, tag = "3")] - pub business: ::prost::alloc::string::String, - #[prost(uint64, tag = "4")] - pub business_id: u64, - #[prost(string, tag = "5")] - pub delta: ::prost::alloc::string::String, - #[prost(string, tag = "6")] - pub detail: ::prost::alloc::string::String, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct BalanceUpdateResponse {} -/// repeated string assets = 1; -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct AssetListRequest {} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct AssetListResponse { - #[prost(message, repeated, tag = "1")] - pub asset_lists: ::prost::alloc::vec::Vec, -} -/// Nested message and enum types in `AssetListResponse`. -pub mod asset_list_response { - #[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] - pub struct AssetInfo { - #[prost(string, tag = "1")] - pub symbol: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub name: ::prost::alloc::string::String, - #[prost(int32, tag = "3")] - pub chain_id: i32, - #[prost(string, tag = "4")] - pub token_address: ::prost::alloc::string::String, - #[prost(uint32, tag = "5")] - pub precision: u32, - #[prost(string, tag = "6")] - pub logo_uri: ::prost::alloc::string::String, - #[prost(int32, tag = "7")] - pub inner_id: i32, - } -} -/// -/// internal? -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct AssetSummaryRequest { - #[prost(string, repeated, tag = "1")] - pub assets: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct AssetSummaryResponse { - #[prost(message, repeated, tag = "1")] - pub asset_summaries: ::prost::alloc::vec::Vec, -} -/// Nested message and enum types in `AssetSummaryResponse`. -pub mod asset_summary_response { - #[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] - pub struct AssetSummaryInfo { - #[prost(string, tag = "1")] - pub name: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub total_balance: ::prost::alloc::string::String, - #[prost(int32, tag = "3")] - pub available_count: i32, - #[prost(string, tag = "4")] - pub available_balance: ::prost::alloc::string::String, - #[prost(int32, tag = "5")] - pub frozen_count: i32, - #[prost(string, tag = "6")] - pub frozen_balance: ::prost::alloc::string::String, - } -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct OrderPutRequest { - #[prost(uint32, tag = "1")] - pub user_id: u32, - #[prost(string, tag = "2")] - pub market: ::prost::alloc::string::String, - #[prost(enumeration = "OrderSide", tag = "3")] - pub order_side: i32, - #[prost(enumeration = "OrderType", tag = "4")] - pub order_type: i32, - /// always amount for base, even for market bid - #[prost(string, tag = "5")] - pub amount: ::prost::alloc::string::String, - /// should be empty or zero for market order - #[prost(string, tag = "6")] - pub price: ::prost::alloc::string::String, - /// onyl valid for market bid order - #[prost(string, tag = "7")] - pub quote_limit: ::prost::alloc::string::String, - #[prost(string, tag = "8")] - pub taker_fee: ::prost::alloc::string::String, - #[prost(string, tag = "9")] - pub maker_fee: ::prost::alloc::string::String, - /// Ensures an Limit order is only subject to Maker Fees (ignored for Market orders). - #[prost(bool, tag = "10")] - pub post_only: bool, - /// bjj signature used in Fluidex - #[prost(string, tag = "11")] - pub signature: ::prost::alloc::string::String, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct OrderInfo { - #[prost(uint64, tag = "1")] - pub id: u64, - #[prost(string, tag = "2")] - pub market: ::prost::alloc::string::String, - #[prost(enumeration = "OrderSide", tag = "3")] - pub order_side: i32, - #[prost(enumeration = "OrderType", tag = "4")] - pub order_type: i32, - #[prost(uint32, tag = "5")] - pub user_id: u32, - #[prost(double, tag = "6")] - pub create_time: f64, - #[prost(double, tag = "7")] - pub update_time: f64, - #[prost(string, tag = "8")] - pub price: ::prost::alloc::string::String, - #[prost(string, tag = "9")] - pub amount: ::prost::alloc::string::String, - #[prost(string, tag = "10")] - pub taker_fee: ::prost::alloc::string::String, - #[prost(string, tag = "11")] - pub maker_fee: ::prost::alloc::string::String, - #[prost(string, tag = "12")] - pub remain: ::prost::alloc::string::String, - #[prost(string, tag = "13")] - pub finished_base: ::prost::alloc::string::String, - #[prost(string, tag = "14")] - pub finished_quote: ::prost::alloc::string::String, - #[prost(string, tag = "15")] - pub finished_fee: ::prost::alloc::string::String, - #[prost(bool, tag = "16")] - pub post_only: bool, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct OrderQueryRequest { - #[prost(uint32, tag = "1")] - pub user_id: u32, - #[prost(string, tag = "2")] - pub market: ::prost::alloc::string::String, - #[prost(int32, tag = "3")] - pub offset: i32, - #[prost(int32, tag = "4")] - pub limit: i32, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct OrderQueryResponse { - #[prost(int32, tag = "1")] - pub offset: i32, - #[prost(int32, tag = "2")] - pub limit: i32, - #[prost(int32, tag = "3")] - pub total: i32, - #[prost(message, repeated, tag = "4")] - pub orders: ::prost::alloc::vec::Vec, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct OrderCancelRequest { - #[prost(uint32, tag = "1")] - pub user_id: u32, - #[prost(string, tag = "2")] - pub market: ::prost::alloc::string::String, - #[prost(uint64, tag = "3")] - pub order_id: u64, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct OrderCancelAllRequest { - #[prost(uint32, tag = "1")] - pub user_id: u32, - #[prost(string, tag = "2")] - pub market: ::prost::alloc::string::String, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct OrderCancelAllResponse { - #[prost(uint32, tag = "1")] - pub total: u32, -} -/// why not both side -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct OrderBookRequest { - #[prost(string, tag = "1")] - pub market: ::prost::alloc::string::String, - #[prost(enumeration = "OrderSide", tag = "2")] - pub side: i32, - #[prost(int32, tag = "3")] - pub offset: i32, - #[prost(int32, tag = "4")] - pub limit: i32, -} -/// strange api -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct OrderBookResponse { - #[prost(int32, tag = "1")] - pub offset: i32, - #[prost(int32, tag = "2")] - pub limit: i32, - #[prost(uint64, tag = "3")] - pub total: u64, - #[prost(message, repeated, tag = "4")] - pub orders: ::prost::alloc::vec::Vec, -} -/// with cache -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct OrderBookDepthRequest { - #[prost(string, tag = "1")] - pub market: ::prost::alloc::string::String, - #[prost(int32, tag = "2")] - pub limit: i32, - #[prost(string, tag = "3")] - pub interval: ::prost::alloc::string::String, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct OrderBookDepthResponse { - #[prost(message, repeated, tag = "1")] - pub asks: ::prost::alloc::vec::Vec, - #[prost(message, repeated, tag = "2")] - pub bids: ::prost::alloc::vec::Vec, -} -/// Nested message and enum types in `OrderBookDepthResponse`. -pub mod order_book_depth_response { - #[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] - pub struct PriceInfo { - #[prost(string, tag = "1")] - pub price: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub amount: ::prost::alloc::string::String, - } -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct OrderDetailRequest { - #[prost(string, tag = "1")] - pub market: ::prost::alloc::string::String, - #[prost(uint64, tag = "2")] - pub order_id: u64, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct MarketListRequest {} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct MarketListResponse { - #[prost(message, repeated, tag = "1")] - pub markets: ::prost::alloc::vec::Vec, -} -/// Nested message and enum types in `MarketListResponse`. -pub mod market_list_response { - #[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] - pub struct MarketInfo { - #[prost(string, tag = "1")] - pub name: ::prost::alloc::string::String, - /// base - #[prost(string, tag = "2")] - pub base: ::prost::alloc::string::String, - /// quote - #[prost(string, tag = "3")] - pub quote: ::prost::alloc::string::String, - #[prost(uint32, tag = "4")] - pub fee_precision: u32, - #[prost(uint32, tag = "5")] - pub amount_precision: u32, - #[prost(uint32, tag = "6")] - pub price_precision: u32, - #[prost(string, tag = "7")] - pub min_amount: ::prost::alloc::string::String, - } -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct MarketSummaryRequest { - #[prost(string, repeated, tag = "1")] - pub markets: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct MarketSummaryResponse { - #[prost(message, repeated, tag = "1")] - pub market_summaries: ::prost::alloc::vec::Vec, -} -/// Nested message and enum types in `MarketSummaryResponse`. -pub mod market_summary_response { - #[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] - pub struct MarketSummary { - #[prost(string, tag = "1")] - pub name: ::prost::alloc::string::String, - #[prost(int32, tag = "2")] - pub ask_count: i32, - #[prost(string, tag = "3")] - pub ask_amount: ::prost::alloc::string::String, - #[prost(int32, tag = "4")] - pub bid_count: i32, - #[prost(string, tag = "5")] - pub bid_amount: ::prost::alloc::string::String, - #[prost(uint64, tag = "6")] - pub trade_count: u64, - } -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct ReloadMarketsRequest { - #[prost(bool, tag = "1")] - pub from_scratch: bool, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct SimpleSuccessResponse {} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct TransferRequest { - /// user_id - #[prost(uint32, tag = "1")] - pub from: u32, - /// user_id - #[prost(uint32, tag = "2")] - pub to: u32, - #[prost(string, tag = "3")] - pub asset: ::prost::alloc::string::String, - /// should be > 0 - #[prost(string, tag = "4")] - pub delta: ::prost::alloc::string::String, - #[prost(string, tag = "5")] - pub memo: ::prost::alloc::string::String, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct TransferResponse { - #[prost(bool, tag = "1")] - pub success: bool, - #[prost(string, tag = "2")] - pub asset: ::prost::alloc::string::String, - #[prost(string, tag = "3")] - pub balance_from: ::prost::alloc::string::String, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct DebugDumpRequest {} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct DebugDumpResponse {} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct DebugResetRequest {} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct DebugResetResponse {} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct DebugReloadRequest {} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct DebugReloadResponse {} -#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] -#[repr(i32)] -pub enum OrderSide { - Ask = 0, - Bid = 1, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] -#[repr(i32)] -pub enum OrderType { - Limit = 0, - Market = 1, -} -#[doc = r" Generated client implementations."] -pub mod matchengine_client { - #![allow(unused_variables, dead_code, missing_docs)] - use tonic::codegen::*; - pub struct MatchengineClient { - inner: tonic::client::Grpc, - } - impl MatchengineClient { - #[doc = r" Attempt to create a new client by connecting to a given endpoint."] - pub async fn connect(dst: D) -> Result - where - D: std::convert::TryInto, - D::Error: Into, - { - let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; - Ok(Self::new(conn)) - } - } - impl MatchengineClient - where - T: tonic::client::GrpcService, - T::ResponseBody: Body + HttpBody + Send + 'static, - T::Error: Into, - ::Error: Into + Send, - { - pub fn new(inner: T) -> Self { - let inner = tonic::client::Grpc::new(inner); - Self { inner } - } - pub fn with_interceptor(inner: T, interceptor: impl Into) -> Self { - let inner = tonic::client::Grpc::with_interceptor(inner, interceptor); - Self { inner } - } - pub async fn register_user( - &mut self, - request: impl tonic::IntoRequest, - ) -> Result, tonic::Status> { - self.inner - .ready() - .await - .map_err(|e| tonic::Status::new(tonic::Code::Unknown, format!("Service was not ready: {}", e.into())))?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/matchengine.Matchengine/RegisterUser"); - self.inner.unary(request.into_request(), path, codec).await - } - pub async fn balance_query( - &mut self, - request: impl tonic::IntoRequest, - ) -> Result, tonic::Status> { - self.inner - .ready() - .await - .map_err(|e| tonic::Status::new(tonic::Code::Unknown, format!("Service was not ready: {}", e.into())))?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/matchengine.Matchengine/BalanceQuery"); - self.inner.unary(request.into_request(), path, codec).await - } - pub async fn balance_update( - &mut self, - request: impl tonic::IntoRequest, - ) -> Result, tonic::Status> { - self.inner - .ready() - .await - .map_err(|e| tonic::Status::new(tonic::Code::Unknown, format!("Service was not ready: {}", e.into())))?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/matchengine.Matchengine/BalanceUpdate"); - self.inner.unary(request.into_request(), path, codec).await - } - pub async fn asset_list( - &mut self, - request: impl tonic::IntoRequest, - ) -> Result, tonic::Status> { - self.inner - .ready() - .await - .map_err(|e| tonic::Status::new(tonic::Code::Unknown, format!("Service was not ready: {}", e.into())))?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/matchengine.Matchengine/AssetList"); - self.inner.unary(request.into_request(), path, codec).await - } - #[doc = " rpc AssetSummary(AssetSummaryRequest) returns (AssetSummaryResponse) {}"] - pub async fn order_put( - &mut self, - request: impl tonic::IntoRequest, - ) -> Result, tonic::Status> { - self.inner - .ready() - .await - .map_err(|e| tonic::Status::new(tonic::Code::Unknown, format!("Service was not ready: {}", e.into())))?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/matchengine.Matchengine/OrderPut"); - self.inner.unary(request.into_request(), path, codec).await - } - pub async fn order_query( - &mut self, - request: impl tonic::IntoRequest, - ) -> Result, tonic::Status> { - self.inner - .ready() - .await - .map_err(|e| tonic::Status::new(tonic::Code::Unknown, format!("Service was not ready: {}", e.into())))?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/matchengine.Matchengine/OrderQuery"); - self.inner.unary(request.into_request(), path, codec).await - } - pub async fn order_cancel( - &mut self, - request: impl tonic::IntoRequest, - ) -> Result, tonic::Status> { - self.inner - .ready() - .await - .map_err(|e| tonic::Status::new(tonic::Code::Unknown, format!("Service was not ready: {}", e.into())))?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/matchengine.Matchengine/OrderCancel"); - self.inner.unary(request.into_request(), path, codec).await - } - pub async fn order_cancel_all( - &mut self, - request: impl tonic::IntoRequest, - ) -> Result, tonic::Status> { - self.inner - .ready() - .await - .map_err(|e| tonic::Status::new(tonic::Code::Unknown, format!("Service was not ready: {}", e.into())))?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/matchengine.Matchengine/OrderCancelAll"); - self.inner.unary(request.into_request(), path, codec).await - } - #[doc = " rpc OrderBook(OrderBookRequest) returns (OrderBookResponse) {}"] - pub async fn order_book_depth( - &mut self, - request: impl tonic::IntoRequest, - ) -> Result, tonic::Status> { - self.inner - .ready() - .await - .map_err(|e| tonic::Status::new(tonic::Code::Unknown, format!("Service was not ready: {}", e.into())))?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/matchengine.Matchengine/OrderBookDepth"); - self.inner.unary(request.into_request(), path, codec).await - } - pub async fn order_detail( - &mut self, - request: impl tonic::IntoRequest, - ) -> Result, tonic::Status> { - self.inner - .ready() - .await - .map_err(|e| tonic::Status::new(tonic::Code::Unknown, format!("Service was not ready: {}", e.into())))?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/matchengine.Matchengine/OrderDetail"); - self.inner.unary(request.into_request(), path, codec).await - } - pub async fn market_list( - &mut self, - request: impl tonic::IntoRequest, - ) -> Result, tonic::Status> { - self.inner - .ready() - .await - .map_err(|e| tonic::Status::new(tonic::Code::Unknown, format!("Service was not ready: {}", e.into())))?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/matchengine.Matchengine/MarketList"); - self.inner.unary(request.into_request(), path, codec).await - } - pub async fn reload_markets( - &mut self, - request: impl tonic::IntoRequest, - ) -> Result, tonic::Status> { - self.inner - .ready() - .await - .map_err(|e| tonic::Status::new(tonic::Code::Unknown, format!("Service was not ready: {}", e.into())))?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/matchengine.Matchengine/ReloadMarkets"); - self.inner.unary(request.into_request(), path, codec).await - } - pub async fn market_summary( - &mut self, - request: impl tonic::IntoRequest, - ) -> Result, tonic::Status> { - self.inner - .ready() - .await - .map_err(|e| tonic::Status::new(tonic::Code::Unknown, format!("Service was not ready: {}", e.into())))?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/matchengine.Matchengine/MarketSummary"); - self.inner.unary(request.into_request(), path, codec).await - } - pub async fn transfer( - &mut self, - request: impl tonic::IntoRequest, - ) -> Result, tonic::Status> { - self.inner - .ready() - .await - .map_err(|e| tonic::Status::new(tonic::Code::Unknown, format!("Service was not ready: {}", e.into())))?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/matchengine.Matchengine/Transfer"); - self.inner.unary(request.into_request(), path, codec).await - } - #[doc = " Used only in development"] - pub async fn debug_dump( - &mut self, - request: impl tonic::IntoRequest, - ) -> Result, tonic::Status> { - self.inner - .ready() - .await - .map_err(|e| tonic::Status::new(tonic::Code::Unknown, format!("Service was not ready: {}", e.into())))?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/matchengine.Matchengine/DebugDump"); - self.inner.unary(request.into_request(), path, codec).await - } - pub async fn debug_reset( - &mut self, - request: impl tonic::IntoRequest, - ) -> Result, tonic::Status> { - self.inner - .ready() - .await - .map_err(|e| tonic::Status::new(tonic::Code::Unknown, format!("Service was not ready: {}", e.into())))?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/matchengine.Matchengine/DebugReset"); - self.inner.unary(request.into_request(), path, codec).await - } - pub async fn debug_reload( - &mut self, - request: impl tonic::IntoRequest, - ) -> Result, tonic::Status> { - self.inner - .ready() - .await - .map_err(|e| tonic::Status::new(tonic::Code::Unknown, format!("Service was not ready: {}", e.into())))?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/matchengine.Matchengine/DebugReload"); - self.inner.unary(request.into_request(), path, codec).await - } - } - impl Clone for MatchengineClient { - fn clone(&self) -> Self { - Self { inner: self.inner.clone() } - } - } - impl std::fmt::Debug for MatchengineClient { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "MatchengineClient {{ ... }}") - } - } -} -#[doc = r" Generated server implementations."] -pub mod matchengine_server { - #![allow(unused_variables, dead_code, missing_docs)] - use tonic::codegen::*; - #[doc = "Generated trait containing gRPC methods that should be implemented for use with MatchengineServer."] - #[async_trait] - pub trait Matchengine: Send + Sync + 'static { - async fn register_user(&self, request: tonic::Request) -> Result, tonic::Status>; - async fn balance_query( - &self, - request: tonic::Request, - ) -> Result, tonic::Status>; - async fn balance_update( - &self, - request: tonic::Request, - ) -> Result, tonic::Status>; - async fn asset_list( - &self, - request: tonic::Request, - ) -> Result, tonic::Status>; - #[doc = " rpc AssetSummary(AssetSummaryRequest) returns (AssetSummaryResponse) {}"] - async fn order_put( - &self, - request: tonic::Request, - ) -> Result, tonic::Status>; - async fn order_query( - &self, - request: tonic::Request, - ) -> Result, tonic::Status>; - async fn order_cancel( - &self, - request: tonic::Request, - ) -> Result, tonic::Status>; - async fn order_cancel_all( - &self, - request: tonic::Request, - ) -> Result, tonic::Status>; - #[doc = " rpc OrderBook(OrderBookRequest) returns (OrderBookResponse) {}"] - async fn order_book_depth( - &self, - request: tonic::Request, - ) -> Result, tonic::Status>; - async fn order_detail( - &self, - request: tonic::Request, - ) -> Result, tonic::Status>; - async fn market_list( - &self, - request: tonic::Request, - ) -> Result, tonic::Status>; - async fn reload_markets( - &self, - request: tonic::Request, - ) -> Result, tonic::Status>; - async fn market_summary( - &self, - request: tonic::Request, - ) -> Result, tonic::Status>; - async fn transfer( - &self, - request: tonic::Request, - ) -> Result, tonic::Status>; - #[doc = " Used only in development"] - async fn debug_dump( - &self, - request: tonic::Request, - ) -> Result, tonic::Status>; - async fn debug_reset( - &self, - request: tonic::Request, - ) -> Result, tonic::Status>; - async fn debug_reload( - &self, - request: tonic::Request, - ) -> Result, tonic::Status>; - } - #[derive(Debug)] - pub struct MatchengineServer { - inner: _Inner, - } - struct _Inner(Arc, Option); - impl MatchengineServer { - pub fn new(inner: T) -> Self { - let inner = Arc::new(inner); - let inner = _Inner(inner, None); - Self { inner } - } - pub fn with_interceptor(inner: T, interceptor: impl Into) -> Self { - let inner = Arc::new(inner); - let inner = _Inner(inner, Some(interceptor.into())); - Self { inner } - } - } - impl Service> for MatchengineServer - where - T: Matchengine, - B: HttpBody + Send + Sync + 'static, - B::Error: Into + Send + 'static, - { - type Response = http::Response; - type Error = Never; - type Future = BoxFuture; - fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll> { - Poll::Ready(Ok(())) - } - fn call(&mut self, req: http::Request) -> Self::Future { - let inner = self.inner.clone(); - match req.uri().path() { - "/matchengine.Matchengine/RegisterUser" => { - #[allow(non_camel_case_types)] - struct RegisterUserSvc(pub Arc); - impl tonic::server::UnaryService for RegisterUserSvc { - type Response = super::UserInfo; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { - let inner = self.0.clone(); - let fut = async move { (*inner).register_user(request).await }; - Box::pin(fut) - } - } - let inner = self.inner.clone(); - let fut = async move { - let interceptor = inner.1.clone(); - let inner = inner.0; - let method = RegisterUserSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = if let Some(interceptor) = interceptor { - tonic::server::Grpc::with_interceptor(codec, interceptor) - } else { - tonic::server::Grpc::new(codec) - }; - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/matchengine.Matchengine/BalanceQuery" => { - #[allow(non_camel_case_types)] - struct BalanceQuerySvc(pub Arc); - impl tonic::server::UnaryService for BalanceQuerySvc { - type Response = super::BalanceQueryResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { - let inner = self.0.clone(); - let fut = async move { (*inner).balance_query(request).await }; - Box::pin(fut) - } - } - let inner = self.inner.clone(); - let fut = async move { - let interceptor = inner.1.clone(); - let inner = inner.0; - let method = BalanceQuerySvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = if let Some(interceptor) = interceptor { - tonic::server::Grpc::with_interceptor(codec, interceptor) - } else { - tonic::server::Grpc::new(codec) - }; - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/matchengine.Matchengine/BalanceUpdate" => { - #[allow(non_camel_case_types)] - struct BalanceUpdateSvc(pub Arc); - impl tonic::server::UnaryService for BalanceUpdateSvc { - type Response = super::BalanceUpdateResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { - let inner = self.0.clone(); - let fut = async move { (*inner).balance_update(request).await }; - Box::pin(fut) - } - } - let inner = self.inner.clone(); - let fut = async move { - let interceptor = inner.1.clone(); - let inner = inner.0; - let method = BalanceUpdateSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = if let Some(interceptor) = interceptor { - tonic::server::Grpc::with_interceptor(codec, interceptor) - } else { - tonic::server::Grpc::new(codec) - }; - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/matchengine.Matchengine/AssetList" => { - #[allow(non_camel_case_types)] - struct AssetListSvc(pub Arc); - impl tonic::server::UnaryService for AssetListSvc { - type Response = super::AssetListResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { - let inner = self.0.clone(); - let fut = async move { (*inner).asset_list(request).await }; - Box::pin(fut) - } - } - let inner = self.inner.clone(); - let fut = async move { - let interceptor = inner.1.clone(); - let inner = inner.0; - let method = AssetListSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = if let Some(interceptor) = interceptor { - tonic::server::Grpc::with_interceptor(codec, interceptor) - } else { - tonic::server::Grpc::new(codec) - }; - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/matchengine.Matchengine/OrderPut" => { - #[allow(non_camel_case_types)] - struct OrderPutSvc(pub Arc); - impl tonic::server::UnaryService for OrderPutSvc { - type Response = super::OrderInfo; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { - let inner = self.0.clone(); - let fut = async move { (*inner).order_put(request).await }; - Box::pin(fut) - } - } - let inner = self.inner.clone(); - let fut = async move { - let interceptor = inner.1.clone(); - let inner = inner.0; - let method = OrderPutSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = if let Some(interceptor) = interceptor { - tonic::server::Grpc::with_interceptor(codec, interceptor) - } else { - tonic::server::Grpc::new(codec) - }; - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/matchengine.Matchengine/OrderQuery" => { - #[allow(non_camel_case_types)] - struct OrderQuerySvc(pub Arc); - impl tonic::server::UnaryService for OrderQuerySvc { - type Response = super::OrderQueryResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { - let inner = self.0.clone(); - let fut = async move { (*inner).order_query(request).await }; - Box::pin(fut) - } - } - let inner = self.inner.clone(); - let fut = async move { - let interceptor = inner.1.clone(); - let inner = inner.0; - let method = OrderQuerySvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = if let Some(interceptor) = interceptor { - tonic::server::Grpc::with_interceptor(codec, interceptor) - } else { - tonic::server::Grpc::new(codec) - }; - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/matchengine.Matchengine/OrderCancel" => { - #[allow(non_camel_case_types)] - struct OrderCancelSvc(pub Arc); - impl tonic::server::UnaryService for OrderCancelSvc { - type Response = super::OrderInfo; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { - let inner = self.0.clone(); - let fut = async move { (*inner).order_cancel(request).await }; - Box::pin(fut) - } - } - let inner = self.inner.clone(); - let fut = async move { - let interceptor = inner.1.clone(); - let inner = inner.0; - let method = OrderCancelSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = if let Some(interceptor) = interceptor { - tonic::server::Grpc::with_interceptor(codec, interceptor) - } else { - tonic::server::Grpc::new(codec) - }; - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/matchengine.Matchengine/OrderCancelAll" => { - #[allow(non_camel_case_types)] - struct OrderCancelAllSvc(pub Arc); - impl tonic::server::UnaryService for OrderCancelAllSvc { - type Response = super::OrderCancelAllResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { - let inner = self.0.clone(); - let fut = async move { (*inner).order_cancel_all(request).await }; - Box::pin(fut) - } - } - let inner = self.inner.clone(); - let fut = async move { - let interceptor = inner.1.clone(); - let inner = inner.0; - let method = OrderCancelAllSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = if let Some(interceptor) = interceptor { - tonic::server::Grpc::with_interceptor(codec, interceptor) - } else { - tonic::server::Grpc::new(codec) - }; - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/matchengine.Matchengine/OrderBookDepth" => { - #[allow(non_camel_case_types)] - struct OrderBookDepthSvc(pub Arc); - impl tonic::server::UnaryService for OrderBookDepthSvc { - type Response = super::OrderBookDepthResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { - let inner = self.0.clone(); - let fut = async move { (*inner).order_book_depth(request).await }; - Box::pin(fut) - } - } - let inner = self.inner.clone(); - let fut = async move { - let interceptor = inner.1.clone(); - let inner = inner.0; - let method = OrderBookDepthSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = if let Some(interceptor) = interceptor { - tonic::server::Grpc::with_interceptor(codec, interceptor) - } else { - tonic::server::Grpc::new(codec) - }; - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/matchengine.Matchengine/OrderDetail" => { - #[allow(non_camel_case_types)] - struct OrderDetailSvc(pub Arc); - impl tonic::server::UnaryService for OrderDetailSvc { - type Response = super::OrderInfo; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { - let inner = self.0.clone(); - let fut = async move { (*inner).order_detail(request).await }; - Box::pin(fut) - } - } - let inner = self.inner.clone(); - let fut = async move { - let interceptor = inner.1.clone(); - let inner = inner.0; - let method = OrderDetailSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = if let Some(interceptor) = interceptor { - tonic::server::Grpc::with_interceptor(codec, interceptor) - } else { - tonic::server::Grpc::new(codec) - }; - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/matchengine.Matchengine/MarketList" => { - #[allow(non_camel_case_types)] - struct MarketListSvc(pub Arc); - impl tonic::server::UnaryService for MarketListSvc { - type Response = super::MarketListResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { - let inner = self.0.clone(); - let fut = async move { (*inner).market_list(request).await }; - Box::pin(fut) - } - } - let inner = self.inner.clone(); - let fut = async move { - let interceptor = inner.1.clone(); - let inner = inner.0; - let method = MarketListSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = if let Some(interceptor) = interceptor { - tonic::server::Grpc::with_interceptor(codec, interceptor) - } else { - tonic::server::Grpc::new(codec) - }; - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/matchengine.Matchengine/ReloadMarkets" => { - #[allow(non_camel_case_types)] - struct ReloadMarketsSvc(pub Arc); - impl tonic::server::UnaryService for ReloadMarketsSvc { - type Response = super::SimpleSuccessResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { - let inner = self.0.clone(); - let fut = async move { (*inner).reload_markets(request).await }; - Box::pin(fut) - } - } - let inner = self.inner.clone(); - let fut = async move { - let interceptor = inner.1.clone(); - let inner = inner.0; - let method = ReloadMarketsSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = if let Some(interceptor) = interceptor { - tonic::server::Grpc::with_interceptor(codec, interceptor) - } else { - tonic::server::Grpc::new(codec) - }; - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/matchengine.Matchengine/MarketSummary" => { - #[allow(non_camel_case_types)] - struct MarketSummarySvc(pub Arc); - impl tonic::server::UnaryService for MarketSummarySvc { - type Response = super::MarketSummaryResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { - let inner = self.0.clone(); - let fut = async move { (*inner).market_summary(request).await }; - Box::pin(fut) - } - } - let inner = self.inner.clone(); - let fut = async move { - let interceptor = inner.1.clone(); - let inner = inner.0; - let method = MarketSummarySvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = if let Some(interceptor) = interceptor { - tonic::server::Grpc::with_interceptor(codec, interceptor) - } else { - tonic::server::Grpc::new(codec) - }; - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/matchengine.Matchengine/Transfer" => { - #[allow(non_camel_case_types)] - struct TransferSvc(pub Arc); - impl tonic::server::UnaryService for TransferSvc { - type Response = super::TransferResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { - let inner = self.0.clone(); - let fut = async move { (*inner).transfer(request).await }; - Box::pin(fut) - } - } - let inner = self.inner.clone(); - let fut = async move { - let interceptor = inner.1.clone(); - let inner = inner.0; - let method = TransferSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = if let Some(interceptor) = interceptor { - tonic::server::Grpc::with_interceptor(codec, interceptor) - } else { - tonic::server::Grpc::new(codec) - }; - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/matchengine.Matchengine/DebugDump" => { - #[allow(non_camel_case_types)] - struct DebugDumpSvc(pub Arc); - impl tonic::server::UnaryService for DebugDumpSvc { - type Response = super::DebugDumpResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { - let inner = self.0.clone(); - let fut = async move { (*inner).debug_dump(request).await }; - Box::pin(fut) - } - } - let inner = self.inner.clone(); - let fut = async move { - let interceptor = inner.1.clone(); - let inner = inner.0; - let method = DebugDumpSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = if let Some(interceptor) = interceptor { - tonic::server::Grpc::with_interceptor(codec, interceptor) - } else { - tonic::server::Grpc::new(codec) - }; - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/matchengine.Matchengine/DebugReset" => { - #[allow(non_camel_case_types)] - struct DebugResetSvc(pub Arc); - impl tonic::server::UnaryService for DebugResetSvc { - type Response = super::DebugResetResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { - let inner = self.0.clone(); - let fut = async move { (*inner).debug_reset(request).await }; - Box::pin(fut) - } - } - let inner = self.inner.clone(); - let fut = async move { - let interceptor = inner.1.clone(); - let inner = inner.0; - let method = DebugResetSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = if let Some(interceptor) = interceptor { - tonic::server::Grpc::with_interceptor(codec, interceptor) - } else { - tonic::server::Grpc::new(codec) - }; - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/matchengine.Matchengine/DebugReload" => { - #[allow(non_camel_case_types)] - struct DebugReloadSvc(pub Arc); - impl tonic::server::UnaryService for DebugReloadSvc { - type Response = super::DebugReloadResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { - let inner = self.0.clone(); - let fut = async move { (*inner).debug_reload(request).await }; - Box::pin(fut) - } - } - let inner = self.inner.clone(); - let fut = async move { - let interceptor = inner.1.clone(); - let inner = inner.0; - let method = DebugReloadSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = if let Some(interceptor) = interceptor { - tonic::server::Grpc::with_interceptor(codec, interceptor) - } else { - tonic::server::Grpc::new(codec) - }; - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - _ => Box::pin(async move { - Ok(http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(tonic::body::BoxBody::empty()) - .unwrap()) - }), - } - } - } - impl Clone for MatchengineServer { - fn clone(&self) -> Self { - let inner = self.inner.clone(); - Self { inner } - } - } - impl Clone for _Inner { - fn clone(&self) -> Self { - Self(self.0.clone(), self.1.clone()) - } - } - impl std::fmt::Debug for _Inner { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{:?}", self.0) - } - } - impl tonic::transport::NamedService for MatchengineServer { - const NAME: &'static str = "matchengine.Matchengine"; - } -} diff --git a/src/matchengine/rpc/mod.rs b/src/matchengine/rpc/mod.rs deleted file mode 100644 index 6854dc1d..00000000 --- a/src/matchengine/rpc/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -mod matchengine; -pub use matchengine::*; diff --git a/src/matchengine/server.rs b/src/matchengine/server.rs index b4fa31b5..5e452a68 100644 --- a/src/matchengine/server.rs +++ b/src/matchengine/server.rs @@ -1,11 +1,11 @@ use crate::config::{OrderSignatrueCheck, Settings}; use crate::controller::Controller; -use crate::matchengine::rpc::*; use std::fmt::Debug; use std::pin::Pin; use std::sync::Arc; +use orchestra::rpc::exchange::*; use tokio::sync::{mpsc, oneshot, RwLock}; use tonic::{self, Request, Response, Status}; @@ -129,7 +129,7 @@ impl GrpcHandler { } #[tonic::async_trait] -impl super::rpc::matchengine_server::Matchengine for GrpcHandler { +impl matchengine_server::Matchengine for GrpcHandler { async fn asset_list(&self, request: Request) -> Result, Status> { let stub = self.stub.read().await; Ok(Response::new(stub.asset_list(request.into_inner())?)) diff --git a/src/restapi/manage.rs b/src/restapi/manage.rs index 8a6735bf..16b197ba 100644 --- a/src/restapi/manage.rs +++ b/src/restapi/manage.rs @@ -1,9 +1,9 @@ use actix_web::{http, web, Responder}; //use web::Json; use futures::future::OptionFuture; +use orchestra::rpc::exchange::*; use super::{state, types}; -use crate::matchengine::rpc; use crate::storage; pub mod market { @@ -11,9 +11,9 @@ pub mod market { use super::*; async fn do_reload(app_state: &state::AppState) -> (String, http::StatusCode) { - let mut rpc_cli = rpc::matchengine_client::MatchengineClient::new(app_state.manage_channel.as_ref().unwrap().clone()); + let mut rpc_cli = matchengine_client::MatchengineClient::new(app_state.manage_channel.as_ref().unwrap().clone()); - if let Err(e) = rpc_cli.reload_markets(rpc::ReloadMarketsRequest { from_scratch: false }).await { + if let Err(e) = rpc_cli.reload_markets(ReloadMarketsRequest { from_scratch: false }).await { return (e.to_string(), http::StatusCode::INTERNAL_SERVER_ERROR); }