Page MenuHomePhabricator

[services][backup] Introduce cmdline args config
ClosedPublic

Authored by bartek on Jan 4 2023, 6:16 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 30, 10:08 AM
Unknown Object (File)
Sat, Nov 30, 10:08 AM
Unknown Object (File)
Thu, Nov 28, 11:29 AM
Unknown Object (File)
Thu, Nov 28, 11:29 AM
Unknown Object (File)
Thu, Nov 28, 11:29 AM
Unknown Object (File)
Thu, Nov 28, 11:29 AM
Unknown Object (File)
Nov 18 2024, 5:45 AM
Unknown Object (File)
Nov 16 2024, 2:52 PM
Subscribers

Details

Summary

Leveraged clap library to configure the service via command line args. I find this extremely useful when running the service in various environments: nix or docker, localstack/sandbox or real aws, or together with other services outside docker.

Added possibility to configure the following:

  • gRPC listening port (defaults to 50051)
  • to run in sandbox mode (previously (and still) available via the COMM_SERVICES_SANDBOX env var)
  • localstack url (useful because it differs inside/outside docker). Defaults to localhost:4566
  • blob service url (also differs inside/outside docker). Defaults to localhost:50053.

Related linear issue (for blob service, but the same applies here): https://linear.app/comm/issue/ENG-2310/make-blob-service-configurable

Depends on D5843

Test Plan
  • cargo run -- --help should display this help screen:
Backup service

Usage: backup [OPTIONS]

Options:
      --port <LISTENING_PORT>
          gRPC server listening port [default: 50051]
      --sandbox
          Run the service in sandbox [env: COMM_SERVICES_SANDBOX=]
      --localstack-url <LOCALSTACK_URL>
          AWS Localstack service URL, applicable in sandbox mode [default: http://localhost:4566]
      --blob-service-url <BLOB_SERVICE_URL>
          Blob service URL [default: http://localhost:50053]
  -h, --help
          Print help information
  -V, --version
          Print version information
  • cargo run without args should start service on default port 50051
  • cargo run -- --port 50052 should start service on port 50052 (or any other specified unless already used)

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

bartek held this revision as a draft.
bartek published this revision for review.Jan 4 2023, 9:17 AM
jon requested changes to this revision.Jan 9 2023, 7:07 AM

otherwise LGTM

services/backup/src/constants.rs
5 ↗(On Diff #20604)

Really dislike the use docker-compose conventions of localstack and blob-server domains.

I think we should be defaulting to a localhost, and in the docker-compose file specifying through environment variables that we would rather point to the endpoints which only exist in the docker compose environment.

This revision now requires changes to proceed.Jan 9 2023, 7:07 AM
services/backup/src/constants.rs
5 ↗(On Diff #20604)

Personally, I totally agree with you as defaulting to localhost would make my job less cumbersome ;)

The only reason I defaulted to docker is to keep it as a drop-in replacement for the C++ service. But anyway I'll change this as you suggest.

Changed defaults to localhost instead of docker-specific domains.

bartek edited the test plan for this revision. (Show Details)
This revision is now accepted and ready to land.Jan 9 2023, 7:03 PM