Skip to content

Commit

Permalink
Issue 44 remove deprecated var (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonioYuen authored Jul 29, 2020
1 parent 9cff638 commit 8504a03
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 30 deletions.
4 changes: 2 additions & 2 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ services:
COS_READ_SIDE_OFFSET_DB_PASSWORD: "changeme"
COS_READ_SIDE_OFFSET_DB: "postgres"
COS_READ_SIDE_OFFSET_DB_SCHEMA: "public"
READ_SIDE_HANDLER_SERVICE_HOST: host.docker.internal
READ_SIDE_HANDLER_SERVICE_PORT: 50053
COS_READ_SIDE_CONFIG__HOST__RS1: host.docker.internal
COS_READ_SIDE_CONFIG__PORT__RS1: 50053
JAVA_OPTS: "-Dconfig.resource=docker.conf"
14 changes: 12 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,24 @@ Chief-Of-State heavily relies on the robustness of [lagom-pb](https://github.com
| COS_ENCRYPTION_CLASS | java class to use for encryption | io.superflat.lagompb.encryption.NoEncryption |
| WRITE_SIDE_HANDLER_SERVICE_HOST | address of the gRPC writeSide handler service | <none> |
| WRITE_SIDE_HANDLER_SERVICE_PORT | port for the gRPC writeSide handler service | <none> |
| READ_SIDE_HANDLER_SERVICE_HOST | address of the gRPC readSide handler service. This must be set when readSide is turned on | <none> |
| READ_SIDE_HANDLER_SERVICE_PORT | port for the gRPC readSide handler service. This must be set when readSide is turned on | <none> |
| HANDLER_SERVICE_STATES_PROTO | handler service states proto message FQN (fully qualified typeUrl). Format: `packagename.messagename`. This will be a comma separated list of values | <none> |
| HANDLER_SERVICE_EVENTS_PROTOS | handler service events proto message FQN (fully qualified typeUrl). Format: `packagename.messagename`. This will be a comma separated list of values | <none> |
| COS_SERVICE_NAME | service name | chiefofstate |
| TEAM_NAME | |
| TRACE_HOST | Jaeger collector/agent host | localhost |
| TRACE_PORT | Jaeger collector/agent port | 14268 |

### Read side configurations

- SETTING_NAME - Supported setting names:
- HOST - Read side host
- PORT - Read side port
- READSIDE_ID - Unique id for the read side instance

| environment variable | description | default |
|--- | --- | --- |
| COS_READ_SIDE_CONFIG_<SETTING_NAME>_<READSIDE_ID> | readside configuration settings | <none> |

### Local dev options

| environment variable | description | default |
Expand Down Expand Up @@ -147,3 +156,4 @@ env:
todo:
- think about scaling out replicas in k8s (don't want to break the k8s replica)
- add more read_side_config settings
6 changes: 0 additions & 6 deletions service/src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,6 @@ akka {
connection-attempts = -1
}
"chief_of_state.ReadSideHandlerService" {
# Host to use if service-discovery-mechanism is set to static or grpc-dns
host = ${READ_SIDE_HANDLER_SERVICE_HOST}

# port to use if service-discovery-mechism is static or service discovery does not return a port
port = ${READ_SIDE_HANDLER_SERVICE_PORT}

service-discovery {
mechanism = "static"
# Service name to use if a service-discovery.mechanism other than static or grpc-dns
Expand Down
2 changes: 1 addition & 1 deletion service/src/main/scala/com/namely/chiefofstate/Util.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ object Util {
def getReadSideConfigs: Seq[ReadSideConfig] = {

val envVars: Map[String, String] = sys.env
.filter(_._1.startsWith("COS_READSIDE_CONFIG__"))
.filter(_._1.startsWith("COS_READ_SIDE_CONFIG__"))

if (envVars.exists(_._1.split("__").length != 3)) {
throw new Exception("One or more of the read side configurations is invalid")
Expand Down
38 changes: 19 additions & 19 deletions service/src/test/scala/com/namely/chiefofstate/UtilSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ class UtilSpec extends LagompbSpec {
"handle only read side configs" in {

EnvironmentHelper.setEnv("control_config", "not-a-valid-config")
EnvironmentHelper.setEnv("cos_readside_config__host__rs0", "not-a-valid-config")
EnvironmentHelper.setEnv("COS_READSIDE_CONFIG__HOST__RS1", "host1")
EnvironmentHelper.setEnv("COS_READSIDE_CONFIG__PORT__RS1", "1")
EnvironmentHelper.setEnv("COS_READSIDE_CONFIG__GRPC_SOME_SETTING__RS1", "setting1")
EnvironmentHelper.setEnv("COS_READSIDE_CONFIG__HOST__RS2", "host2")
EnvironmentHelper.setEnv("COS_READSIDE_CONFIG__PORT__RS2", "2")
EnvironmentHelper.setEnv("COS_READSIDE_CONFIG__GRPC_SOME_SETTING__RS2", "setting2")
EnvironmentHelper.setEnv("cos_read_side_config__host__rs0", "not-a-valid-config")
EnvironmentHelper.setEnv("COS_READ_SIDE_CONFIG__HOST__RS1", "host1")
EnvironmentHelper.setEnv("COS_READ_SIDE_CONFIG__PORT__RS1", "1")
EnvironmentHelper.setEnv("COS_READ_SIDE_CONFIG__GRPC_SOME_SETTING__RS1", "setting1")
EnvironmentHelper.setEnv("COS_READ_SIDE_CONFIG__HOST__RS2", "host2")
EnvironmentHelper.setEnv("COS_READ_SIDE_CONFIG__PORT__RS2", "2")
EnvironmentHelper.setEnv("COS_READ_SIDE_CONFIG__GRPC_SOME_SETTING__RS2", "setting2")

val grpcReadSideConfig1: ReadSideConfig = ReadSideConfig("RS1", Some("host1"), Some(1))
.addSetting("GRPC_SOME_SETTING", "setting1")
Expand All @@ -42,38 +42,38 @@ class UtilSpec extends LagompbSpec {

"throw an exception if one or more of the read side configurations is invalid" in {

EnvironmentHelper.setEnv("COS_READSIDE_CONFIG__HOST__", "not-a-valid-config")
EnvironmentHelper.setEnv("COS_READSIDE_CONFIG__PORT__", "0")
EnvironmentHelper.setEnv("COS_READ_SIDE_CONFIG__HOST__", "not-a-valid-config")
EnvironmentHelper.setEnv("COS_READ_SIDE_CONFIG__PORT__", "0")

val exception: Exception = intercept[Exception](Util.getReadSideConfigs)
exception.getMessage shouldBe ("One or more of the read side configurations is invalid")
}

"throw an exception if one or more of the read side configurations does not contain a host" in {
EnvironmentHelper.setEnv("COS_READSIDE_CONFIG__HOST__RS1", "host1")
EnvironmentHelper.setEnv("COS_READSIDE_CONFIG__PORT__RS1", "1")
EnvironmentHelper.setEnv("COS_READSIDE_CONFIG__PORT__RS2", "2")
EnvironmentHelper.setEnv("COS_READ_SIDE_CONFIG__HOST__RS1", "host1")
EnvironmentHelper.setEnv("COS_READ_SIDE_CONFIG__PORT__RS1", "1")
EnvironmentHelper.setEnv("COS_READ_SIDE_CONFIG__PORT__RS2", "2")

val exception: Exception = intercept[Exception](Util.getReadSideConfigs)
exception.getMessage shouldBe ("requirement failed: ProcessorId RS2 is missing a HOST")
}

"throw an exception if one or more of the read side configurations does not contain a port" in {
EnvironmentHelper.setEnv("COS_READSIDE_CONFIG__HOST__RS1", "host1")
EnvironmentHelper.setEnv("COS_READSIDE_CONFIG__PORT__RS1", "1")
EnvironmentHelper.setEnv("COS_READSIDE_CONFIG__HOST__RS2", "host2")
EnvironmentHelper.setEnv("COS_READ_SIDE_CONFIG__HOST__RS1", "host1")
EnvironmentHelper.setEnv("COS_READ_SIDE_CONFIG__PORT__RS1", "1")
EnvironmentHelper.setEnv("COS_READ_SIDE_CONFIG__HOST__RS2", "host2")

val exception: Exception = intercept[Exception](Util.getReadSideConfigs)
exception.getMessage shouldBe ("requirement failed: ProcessorId RS2 is missing a PORT")
}

"throw an exception on an invalid setting name" in {
EnvironmentHelper.setEnv("COS_READSIDE_CONFIG__HOST__RS1", "host1")
EnvironmentHelper.setEnv("COS_READSIDE_CONFIG__PORT__RS1", "1")
EnvironmentHelper.setEnv("COS_READSIDE_CONFIG____RS1", "setting1")
EnvironmentHelper.setEnv("COS_READ_SIDE_CONFIG__HOST__RS1", "host1")
EnvironmentHelper.setEnv("COS_READ_SIDE_CONFIG__PORT__RS1", "1")
EnvironmentHelper.setEnv("COS_READ_SIDE_CONFIG____RS1", "setting1")

val exception: Exception = intercept[Exception](Util.getReadSideConfigs)
exception.getMessage shouldBe ("requirement failed: Setting must be defined in COS_READSIDE_CONFIG____RS1")
exception.getMessage shouldBe ("requirement failed: Setting must be defined in COS_READ_SIDE_CONFIG____RS1")
}
}
}
Expand Down

0 comments on commit 8504a03

Please sign in to comment.