Skip to content

Commit 0ff6afb

Browse files
Hexkit v6 (GSI-1790) (#21)
* Bump version to `4.1.0` and update dependencies * Use ConfiguredMongoClient for docs handler * Add optional event_id field for publishing events * Update config and readme
1 parent 768f8f9 commit 0ff6afb

File tree

18 files changed

+1457
-955
lines changed

18 files changed

+1457
-955
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ repos:
4545
- id: no-commit-to-branch
4646
args: [--branch, dev, --branch, int, --branch, main]
4747
- repo: https://github.com/astral-sh/ruff-pre-commit
48-
rev: v0.11.11
48+
rev: v0.12.7
4949
hooks:
5050
- id: ruff
5151
args: [--fix, --exit-non-zero-on-fix]
5252
- id: ruff-format
5353
- repo: https://github.com/pre-commit/mirrors-mypy
54-
rev: v1.15.0
54+
rev: v1.17.1
5555
hooks:
5656
- id: mypy
5757
args: [--no-warn-unused-ignores]

.pyproject_generation/pyproject_custom.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[project]
22
name = "sms"
3-
version = "4.0.2"
3+
version = "4.1.0"
44
description = "State Management Service - Provides a REST API for basic infrastructure technology state management."
55
dependencies = [
66
"typer >= 0.12",
7-
"ghga-service-commons[api] >= 4.1",
8-
"hexkit[mongodb,s3,akafka] >= 5.1",
7+
"ghga-service-commons[api] >= 5.0",
8+
"hexkit[mongodb,s3,akafka] >= 6.0",
99
"hvac>=2",
1010
]
1111

.readme_generation/readme_template.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ $config_description
5151
### Usage:
5252

5353
A template YAML for configuring the service can be found at
54-
[`./example-config.yaml`](./example-config.yaml).
54+
[`./example_config.yaml`](./example_config.yaml).
5555
Please adapt it, rename it to `.$shortname.yaml`, and place it in one of the following locations:
5656
- in the current working directory where you execute the service (on Linux: `./.$shortname.yaml`)
5757
- in your home directory (on Linux: `~/.$shortname.yaml`)
@@ -60,7 +60,7 @@ The config yaml will be automatically parsed by the service.
6060

6161
**Important: If you are using containers, the locations refer to paths within the container.**
6262

63-
All parameters mentioned in the [`./example-config.yaml`](./example-config.yaml)
63+
All parameters mentioned in the [`./example_config.yaml`](./example_config.yaml)
6464
could also be set using environment variables or file secrets.
6565

6666
For naming the environment variables, just prefix the parameter name with `${shortname}_`,
@@ -100,7 +100,7 @@ It installs the service with all development dependencies, and it installs pre-c
100100

101101
The installation is performed automatically when you build the devcontainer. However,
102102
if you update dependencies in the [`./pyproject.toml`](./pyproject.toml) or the
103-
[`./requirements-dev.txt`](./requirements-dev.txt), please run it again.
103+
[`lock/requirements-dev.txt`](./lock/requirements-dev.txt), please run it again.
104104

105105
## License
106106

@@ -109,5 +109,5 @@ This repository is free to use and modify according to the
109109

110110
## README Generation
111111

112-
This README file is auto-generated, please see [`readme_generation.md`](./readme_generation.md)
112+
This README file is auto-generated, please see [.readme_generation/README.md](./.readme_generation/README.md)
113113
for details.

README.md

Lines changed: 93 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,21 @@ We recommend using the provided Docker container.
2424

2525
A pre-built version is available at [docker hub](https://hub.docker.com/repository/docker/ghga/state-management-service):
2626
```bash
27-
docker pull ghga/state-management-service:4.0.2
27+
docker pull ghga/state-management-service:4.1.0
2828
```
2929

3030
Or you can build the container yourself from the [`./Dockerfile`](./Dockerfile):
3131
```bash
3232
# Execute in the repo's root dir:
33-
docker build -t ghga/state-management-service:4.0.2 .
33+
docker build -t ghga/state-management-service:4.1.0 .
3434
```
3535

3636
For production-ready deployment, we recommend using Kubernetes, however,
3737
for simple use cases, you could execute the service using docker
3838
on a single server:
3939
```bash
4040
# The entrypoint is preconfigured:
41-
docker run -p 8080:8080 ghga/state-management-service:4.0.2 --help
41+
docker run -p 8080:8080 ghga/state-management-service:4.1.0 --help
4242
```
4343

4444
If you prefer not to use containers, you may install the service from source:
@@ -81,7 +81,7 @@ The service requires the following configuration parameters:
8181
```
8282

8383

84-
- <a id="properties/kafka_security_protocol"></a>**`kafka_security_protocol`** *(string)*: Protocol used to communicate with brokers. Valid values are: PLAINTEXT, SSL. Must be one of: `["PLAINTEXT", "SSL"]`. Default: `"PLAINTEXT"`.
84+
- <a id="properties/kafka_security_protocol"></a>**`kafka_security_protocol`** *(string)*: Protocol used to communicate with brokers. Valid values are: PLAINTEXT, SSL. Must be one of: "PLAINTEXT" or "SSL". Default: `"PLAINTEXT"`.
8585

8686
- <a id="properties/kafka_ssl_cafile"></a>**`kafka_ssl_cafile`** *(string)*: Certificate Authority file path containing certificates used to sign broker certificates. If a CA is not specified, the default system CA will be used if found by OpenSSL. Default: `""`.
8787

@@ -106,7 +106,7 @@ The service requires the following configuration parameters:
106106
```
107107

108108

109-
- <a id="properties/kafka_max_message_size"></a>**`kafka_max_message_size`** *(integer)*: The largest message size that can be transmitted, in bytes. Only services that have a need to send/receive larger messages should set this. Exclusive minimum: `0`. Default: `1048576`.
109+
- <a id="properties/kafka_max_message_size"></a>**`kafka_max_message_size`** *(integer)*: The largest message size that can be transmitted, in bytes, before compression. Only services that have a need to send/receive larger messages should set this. When used alongside compression, this value can be set to something greater than the broker's `message.max.bytes` field, which effectively concerns the compressed message size. Exclusive minimum: `0`. Default: `1048576`.
110110

111111

112112
Examples:
@@ -121,6 +121,42 @@ The service requires the following configuration parameters:
121121
```
122122

123123

124+
- <a id="properties/kafka_compression_type"></a>**`kafka_compression_type`**: The compression type used for messages. Valid values are: None, gzip, snappy, lz4, and zstd. If None, no compression is applied. This setting is only relevant for the producer and has no effect on the consumer. If set to a value, the producer will compress messages before sending them to the Kafka broker. If unsure, zstd provides a good balance between speed and compression ratio. Default: `null`.
125+
126+
- **Any of**
127+
128+
- <a id="properties/kafka_compression_type/anyOf/0"></a>*string*: Must be one of: "gzip", "snappy", "lz4", or "zstd".
129+
130+
- <a id="properties/kafka_compression_type/anyOf/1"></a>*null*
131+
132+
133+
Examples:
134+
135+
```json
136+
null
137+
```
138+
139+
140+
```json
141+
"gzip"
142+
```
143+
144+
145+
```json
146+
"snappy"
147+
```
148+
149+
150+
```json
151+
"lz4"
152+
```
153+
154+
155+
```json
156+
"zstd"
157+
```
158+
159+
124160
- <a id="properties/kafka_max_retries"></a>**`kafka_max_retries`** *(integer)*: The maximum number of times to immediately retry consuming an event upon failure. Works independently of the dead letter queue. Minimum: `0`. Default: `0`.
125161

126162

@@ -418,7 +454,33 @@ The service requires the following configuration parameters:
418454
```
419455

420456

421-
- <a id="properties/log_level"></a>**`log_level`** *(string)*: The minimum log level to capture. Must be one of: `["CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG", "TRACE"]`. Default: `"INFO"`.
457+
- <a id="properties/mongo_timeout"></a>**`mongo_timeout`**: Timeout in seconds for API calls to MongoDB. The timeout applies to all steps needed to complete the operation, including server selection, connection checkout, serialization, and server-side execution. When the timeout expires, PyMongo raises a timeout exception. If set to None, the operation will not time out (default MongoDB behavior). Default: `null`.
458+
459+
- **Any of**
460+
461+
- <a id="properties/mongo_timeout/anyOf/0"></a>*integer*: Exclusive minimum: `0`.
462+
463+
- <a id="properties/mongo_timeout/anyOf/1"></a>*null*
464+
465+
466+
Examples:
467+
468+
```json
469+
300
470+
```
471+
472+
473+
```json
474+
600
475+
```
476+
477+
478+
```json
479+
null
480+
```
481+
482+
483+
- <a id="properties/log_level"></a>**`log_level`** *(string)*: The minimum log level to capture. Must be one of: "CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG", or "TRACE". Default: `"INFO"`.
422484

423485
- <a id="properties/log_format"></a>**`log_format`**: If set, will replace JSON formatting with the specified string format. If not set, has no effect. In addition to the standard attributes, the following can also be specified: timestamp, service, instance, level, correlation_id, and details. Default: `null`.
424486

@@ -517,7 +579,7 @@ The service requires the following configuration parameters:
517579
```
518580

519581

520-
- <a id="properties/cors_allowed_headers"></a>**`cors_allowed_headers`**: A list of HTTP request headers that should be supported for cross-origin requests. Defaults to []. You can use ['*'] to allow all headers. The Accept, Accept-Language, Content-Language and Content-Type headers are always allowed for CORS requests. Default: `null`.
582+
- <a id="properties/cors_allowed_headers"></a>**`cors_allowed_headers`**: A list of HTTP request headers that should be supported for cross-origin requests. Defaults to []. You can use ['*'] to allow all request headers. The Accept, Accept-Language, Content-Language, Content-Type and some are always allowed for CORS requests. Default: `null`.
521583

522584
- **Any of**
523585

@@ -535,6 +597,24 @@ The service requires the following configuration parameters:
535597
```
536598

537599

600+
- <a id="properties/cors_exposed_headers"></a>**`cors_exposed_headers`**: A list of HTTP response headers that should be exposed for cross-origin responses. Defaults to []. Note that you can NOT use ['*'] to expose all response headers. The Cache-Control, Content-Language, Content-Length, Content-Type, Expires, Last-Modified and Pragma headers are always exposed for CORS responses. Default: `null`.
601+
602+
- **Any of**
603+
604+
- <a id="properties/cors_exposed_headers/anyOf/0"></a>*array*
605+
606+
- <a id="properties/cors_exposed_headers/anyOf/0/items"></a>**Items** *(string)*
607+
608+
- <a id="properties/cors_exposed_headers/anyOf/1"></a>*null*
609+
610+
611+
Examples:
612+
613+
```json
614+
[]
615+
```
616+
617+
538618
## Definitions
539619

540620

@@ -577,7 +657,7 @@ to talk to an S3 service in the backend.<br> Args:
577657
```
578658

579659

580-
- <a id="%24defs/S3Config/properties/s3_secret_access_key"></a>**`s3_secret_access_key`** *(string, format: password, required, write-only)*: Part of credentials for login into the S3 service. See: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html.
660+
- <a id="%24defs/S3Config/properties/s3_secret_access_key"></a>**`s3_secret_access_key`** *(string, format: password, required and write-only)*: Part of credentials for login into the S3 service. See: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html.
581661

582662

583663
Examples:
@@ -623,13 +703,13 @@ to talk to an S3 service in the backend.<br> Args:
623703

624704
- <a id="%24defs/S3ObjectStorageNodeConfig/properties/bucket"></a>**`bucket`** *(string, required)*
625705

626-
- <a id="%24defs/S3ObjectStorageNodeConfig/properties/credentials"></a>**`credentials`**: Refer to *[#/$defs/S3Config](#%24defs/S3Config)*.
706+
- <a id="%24defs/S3ObjectStorageNodeConfig/properties/credentials"></a>**`credentials`** *(required)*: Refer to *[#/$defs/S3Config](#%24defs/S3Config)*.
627707

628708

629709
### Usage:
630710

631711
A template YAML for configuring the service can be found at
632-
[`./example-config.yaml`](./example-config.yaml).
712+
[`./example_config.yaml`](./example_config.yaml).
633713
Please adapt it, rename it to `.sms.yaml`, and place it in one of the following locations:
634714
- in the current working directory where you execute the service (on Linux: `./.sms.yaml`)
635715
- in your home directory (on Linux: `~/.sms.yaml`)
@@ -638,7 +718,7 @@ The config yaml will be automatically parsed by the service.
638718

639719
**Important: If you are using containers, the locations refer to paths within the container.**
640720

641-
All parameters mentioned in the [`./example-config.yaml`](./example-config.yaml)
721+
All parameters mentioned in the [`./example_config.yaml`](./example_config.yaml)
642722
could also be set using environment variables or file secrets.
643723

644724
For naming the environment variables, just prefix the parameter name with `sms_`,
@@ -695,7 +775,7 @@ It installs the service with all development dependencies, and it installs pre-c
695775

696776
The installation is performed automatically when you build the devcontainer. However,
697777
if you update dependencies in the [`./pyproject.toml`](./pyproject.toml) or the
698-
[`./requirements-dev.txt`](./requirements-dev.txt), please run it again.
778+
[`lock/requirements-dev.txt`](./lock/requirements-dev.txt), please run it again.
699779

700780
## License
701781

@@ -704,5 +784,5 @@ This repository is free to use and modify according to the
704784

705785
## README Generation
706786

707-
This README file is auto-generated, please see [`readme_generation.md`](./readme_generation.md)
787+
This README file is auto-generated, please see [.readme_generation/README.md](./.readme_generation/README.md)
708788
for details.

config_schema.json

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@
172172
},
173173
"kafka_max_message_size": {
174174
"default": 1048576,
175-
"description": "The largest message size that can be transmitted, in bytes. Only services that have a need to send/receive larger messages should set this.",
175+
"description": "The largest message size that can be transmitted, in bytes, before compression. Only services that have a need to send/receive larger messages should set this. When used alongside compression, this value can be set to something greater than the broker's `message.max.bytes` field, which effectively concerns the compressed message size.",
176176
"examples": [
177177
1048576,
178178
16777216
@@ -181,6 +181,32 @@
181181
"title": "Kafka Max Message Size",
182182
"type": "integer"
183183
},
184+
"kafka_compression_type": {
185+
"anyOf": [
186+
{
187+
"enum": [
188+
"gzip",
189+
"snappy",
190+
"lz4",
191+
"zstd"
192+
],
193+
"type": "string"
194+
},
195+
{
196+
"type": "null"
197+
}
198+
],
199+
"default": null,
200+
"description": "The compression type used for messages. Valid values are: None, gzip, snappy, lz4, and zstd. If None, no compression is applied. This setting is only relevant for the producer and has no effect on the consumer. If set to a value, the producer will compress messages before sending them to the Kafka broker. If unsure, zstd provides a good balance between speed and compression ratio.",
201+
"examples": [
202+
null,
203+
"gzip",
204+
"snappy",
205+
"lz4",
206+
"zstd"
207+
],
208+
"title": "Kafka Compression Type"
209+
},
184210
"kafka_max_retries": {
185211
"default": 0,
186212
"description": "The maximum number of times to immediately retry consuming an event upon failure. Works independently of the dead letter queue.",
@@ -408,6 +434,25 @@
408434
"title": "Mongo Dsn",
409435
"type": "string"
410436
},
437+
"mongo_timeout": {
438+
"anyOf": [
439+
{
440+
"exclusiveMinimum": 0,
441+
"type": "integer"
442+
},
443+
{
444+
"type": "null"
445+
}
446+
],
447+
"default": null,
448+
"description": "Timeout in seconds for API calls to MongoDB. The timeout applies to all steps needed to complete the operation, including server selection, connection checkout, serialization, and server-side execution. When the timeout expires, PyMongo raises a timeout exception. If set to None, the operation will not time out (default MongoDB behavior).",
449+
"examples": [
450+
300,
451+
600,
452+
null
453+
],
454+
"title": "Mongo Timeout"
455+
},
411456
"log_level": {
412457
"default": "INFO",
413458
"description": "The minimum log level to capture.",
@@ -562,11 +607,30 @@
562607
}
563608
],
564609
"default": null,
565-
"description": "A list of HTTP request headers that should be supported for cross-origin requests. Defaults to []. You can use ['*'] to allow all headers. The Accept, Accept-Language, Content-Language and Content-Type headers are always allowed for CORS requests.",
610+
"description": "A list of HTTP request headers that should be supported for cross-origin requests. Defaults to []. You can use ['*'] to allow all request headers. The Accept, Accept-Language, Content-Language, Content-Type and some are always allowed for CORS requests.",
566611
"examples": [
567612
[]
568613
],
569614
"title": "Cors Allowed Headers"
615+
},
616+
"cors_exposed_headers": {
617+
"anyOf": [
618+
{
619+
"items": {
620+
"type": "string"
621+
},
622+
"type": "array"
623+
},
624+
{
625+
"type": "null"
626+
}
627+
],
628+
"default": null,
629+
"description": "A list of HTTP response headers that should be exposed for cross-origin responses. Defaults to []. Note that you can NOT use ['*'] to expose all response headers. The Cache-Control, Content-Language, Content-Length, Content-Type, Expires, Last-Modified and Pragma headers are always exposed for CORS responses.",
630+
"examples": [
631+
[]
632+
],
633+
"title": "Cors Exposed Headers"
570634
}
571635
},
572636
"required": [

example_config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ cors_allow_credentials: null
55
cors_allowed_headers: null
66
cors_allowed_methods: null
77
cors_allowed_origins: null
8+
cors_exposed_headers: null
89
db_permissions:
910
- '*.*:rw'
1011
db_prefix: test_
1112
docs_url: /docs
1213
generate_correlation_id: true
1314
host: 127.0.0.1
15+
kafka_compression_type: null
1416
kafka_dlq_topic: dlq
1517
kafka_enable_dlq: false
1618
kafka_max_message_size: 1048576
@@ -27,6 +29,7 @@ log_format: null
2729
log_level: INFO
2830
log_traceback: true
2931
mongo_dsn: '**********'
32+
mongo_timeout: null
3033
object_storages:
3134
primary:
3235
bucket: permanent

0 commit comments

Comments
 (0)