Skip to content

Commit

Permalink
Refactor config passing to XP plugin (#47)
Browse files Browse the repository at this point in the history
* Add treatment service config api to management service

* Add tests for configuration controller and service

* Fix appcontext unit test

* Update management service clients

* Rename api that serves treatment service config

* Update experiment manager to ping the treatment service plugin api for configs

* Add additional configs to experiment manager

* Refactor plugin to use its own treatment service config struct

* Remove unnecessary validate tags and add unit test to verify validation for exp manager

* Replace deprecated methods

* Add test set up to create mock google credentials

* Refactor tests to use the same mock google credentials generator

* Regenerate api schemas

* Rename treatment service config endpoint and make segmenterconfig an interface

* Refactor schema and client method names

* Bump go dependencies

* Refactor plugin to utilise config structs of treatment service

* Remove new relic and sentry config from being served via the mgmt svc

* Remove new relic and sentry configs from struct expected from the mgmt service in plugin

* Remove unsused schema from api specs

* Remove redundant code block in configuration service

* Add additional validation steps to treatment service config struct

* Add pubsub timeout seconds to config

* Add debug config to config
  • Loading branch information
deadlycoconuts authored Nov 11, 2022
1 parent e91f0bd commit 4313a38
Show file tree
Hide file tree
Showing 39 changed files with 2,905 additions and 748 deletions.
1 change: 1 addition & 0 deletions api/clients/management.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ output:
clients/management/managementclient.go
package: management
include-tags:
- configuration
- experiment
- project
- settings
Expand Down
22 changes: 22 additions & 0 deletions api/experiments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ servers:
- url: /v1
tags: []
paths:
/treatment-service-config:
get:
operationId: GetTreatmentServiceConfig
tags:
- configuration
summary: retrieves treatment service configuration driven by the management service
responses:
200:
$ref: '#/components/responses/GetTreatmentServiceConfigSuccess'
500:
$ref: '#/components/responses/InternalServerError'
/validate:
post:
operationId: ValidateEntity
Expand Down Expand Up @@ -1263,6 +1274,17 @@ components:
application/json:
schema:
$ref: 'schema.yaml#/components/schemas/Error'
GetTreatmentServiceConfigSuccess:
description: Returns treatment service configuration driven by the management service
content:
application/json:
schema:
required:
- data
type: object
properties:
data:
$ref: 'schema.yaml#/components/schemas/TreatmentServiceConfig'
ListProjectsSuccess:
description: Returns details of all projects set up for experimentation
content:
Expand Down
1 change: 1 addition & 0 deletions api/management/server.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ output:
management-service/api/api.go
package: api
include-tags:
- configuration
- experiment
- project
- settings
Expand Down
18 changes: 18 additions & 0 deletions api/schema.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
components:
schemas:
PubSub:
type: object
properties:
project:
type: string
description: Project name of the PubSub subscription
topic_name:
type: string
description: Topic name of the PubSub subscription
SegmenterConfig:
type: object
TreatmentServiceConfig:
type: object
properties:
pub_sub:
$ref: '#/components/schemas/PubSub'
segmenter_config:
$ref: '#/components/schemas/SegmenterConfig'
SelectedTreatmentData:
required:
- configuration
Expand Down
16 changes: 9 additions & 7 deletions clients/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@ go 1.18

require (
github.com/caraml-dev/xp/common v0.0.0
github.com/deepmap/oapi-codegen v1.8.2
github.com/deepmap/oapi-codegen v1.11.0
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.7.0
github.com/stretchr/testify v1.8.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/getkin/kin-openapi v0.75.0 // indirect
github.com/getkin/kin-openapi v0.94.0 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/swag v0.19.5 // indirect
github.com/mailru/easyjson v0.7.0 // indirect
github.com/go-openapi/swag v0.21.1 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/objx v0.2.0 // indirect
github.com/stretchr/objx v0.4.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/caraml-dev/xp/common => ../common
162 changes: 120 additions & 42 deletions clients/go.sum

Large diffs are not rendered by default.

119 changes: 119 additions & 0 deletions clients/management/managementclient.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions clients/testutils/mocks/management/ManagementClientInterface.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4313a38

Please sign in to comment.