Skip to content

Commit

Permalink
Bump sms version to 4.0.0 and use hexkit v4 (GSI-1337) (#16)
Browse files Browse the repository at this point in the history
* Bump sms version to 4.0.0 and use hexkit v4

* Ruff formatting
  • Loading branch information
TheByronHimes authored Feb 11, 2025
1 parent 8f623dc commit a8a4ac8
Show file tree
Hide file tree
Showing 16 changed files with 1,584 additions and 1,435 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/.dev_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ vault_secret_id: dummy-secret
vault_verify: True
vault_kube_role: dummy-role

db_connection_str: mongodb://mongodb:27017
mongo_dsn: mongodb://mongodb:27017
db_prefix: "test_"
db_permissions:
- "*.*:*"
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ repos:
- id: no-commit-to-branch
args: [--branch, dev, --branch, int, --branch, main]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.0
rev: v0.9.4
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
rev: v1.15.0
hooks:
- id: mypy
args: [--no-warn-unused-ignores]
6 changes: 3 additions & 3 deletions .pyproject_generation/pyproject_custom.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[project]
name = "sms"
version = "3.0.1"
version = "4.0.0"
description = "State Management Service - Provides a REST API for basic infrastructure technology state management."
dependencies = [
"typer >= 0.12",
"ghga-service-commons[api] >= 3.1",
"hexkit[mongodb,s3,akafka] >= 3.7",
"ghga-service-commons[api] >= 3.3",
"hexkit[mongodb,s3,akafka] >= 4.0",
"hvac>=2",
]

Expand Down
2 changes: 2 additions & 0 deletions .pyproject_generation/pyproject_template.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ fixable = [
"UP", # e.g. List -> list
"I", # sort imports
"D", # pydocstyle
"RUF022", # sort items in __all__
]
ignore = [
"E111", # indentation with invalid multiple (for formatter)
Expand All @@ -59,6 +60,7 @@ ignore = [
"D206", # indent-with-spaces (for formatter)
"D300", # triple-single-quotes (for formatter)
"UP040", # type statement (not yet supported by mypy)
"PLC0206", # Extracting value from dictionary without calling `.items()`
]
select = [
"C90", # McCabe Complexity
Expand Down
93 changes: 89 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ We recommend using the provided Docker container.

A pre-build version is available at [docker hub](https://hub.docker.com/repository/docker/ghga/state-management-service):
```bash
docker pull ghga/state-management-service:3.0.1
docker pull ghga/state-management-service:4.0.0
```

Or you can build the container yourself from the [`./Dockerfile`](./Dockerfile):
```bash
# Execute in the repo's root dir:
docker build -t ghga/state-management-service:3.0.1 .
docker build -t ghga/state-management-service:4.0.0 .
```

For production-ready deployment, we recommend using Kubernetes, however,
for simple use cases, you could execute the service using docker
on a single server:
```bash
# The entrypoint is preconfigured:
docker run -p 8080:8080 ghga/state-management-service:3.0.1 --help
docker run -p 8080:8080 ghga/state-management-service:4.0.0 --help
```

If you prefer not to use containers, you may install the service from source:
Expand Down Expand Up @@ -121,6 +121,91 @@ The service requires the following configuration parameters:
```


- **`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`.


Examples:

```json
0
```


```json
1
```


```json
2
```


```json
3
```


```json
5
```


- **`kafka_enable_dlq`** *(boolean)*: A flag to toggle the dead letter queue. If set to False, the service will crash upon exhausting retries instead of publishing events to the DLQ. If set to True, the service will publish events to the DLQ topic after exhausting all retries. Default: `false`.


Examples:

```json
true
```


```json
false
```


- **`kafka_dlq_topic`** *(string)*: The name of the topic used to resolve error-causing events. Default: `"dlq"`.


Examples:

```json
"dlq"
```


- **`kafka_retry_backoff`** *(integer)*: The number of seconds to wait before retrying a failed event. The backoff time is doubled for each retry attempt. Minimum: `0`. Default: `0`.


Examples:

```json
0
```


```json
1
```


```json
2
```


```json
3
```


```json
5
```


- **`object_storages`** *(object, required)*: Can contain additional properties.

- **Additional properties**: Refer to *[#/$defs/S3ObjectStorageNodeConfig](#%24defs/S3ObjectStorageNodeConfig)*.
Expand Down Expand Up @@ -323,7 +408,7 @@ The service requires the following configuration parameters:
```


- **`db_connection_str`** *(string, format: password, required)*: MongoDB connection string. Might include credentials. For more information see: https://naiveskill.com/mongodb-connection-string/.
- **`mongo_dsn`** *(string, format: multi-host-uri, required)*: MongoDB connection string. Might include credentials. For more information see: https://naiveskill.com/mongodb-connection-string/.


Examples:
Expand Down
59 changes: 53 additions & 6 deletions config_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,53 @@
"title": "Kafka Max Message Size",
"type": "integer"
},
"kafka_max_retries": {
"default": 0,
"description": "The maximum number of times to immediately retry consuming an event upon failure. Works independently of the dead letter queue.",
"examples": [
0,
1,
2,
3,
5
],
"minimum": 0,
"title": "Kafka Max Retries",
"type": "integer"
},
"kafka_enable_dlq": {
"default": false,
"description": "A flag to toggle the dead letter queue. If set to False, the service will crash upon exhausting retries instead of publishing events to the DLQ. If set to True, the service will publish events to the DLQ topic after exhausting all retries",
"examples": [
true,
false
],
"title": "Kafka Enable DLQ",
"type": "boolean"
},
"kafka_dlq_topic": {
"default": "dlq",
"description": "The name of the topic used to resolve error-causing events.",
"examples": [
"dlq"
],
"title": "Kafka DLQ Topic",
"type": "string"
},
"kafka_retry_backoff": {
"default": 0,
"description": "The number of seconds to wait before retrying a failed event. The backoff time is doubled for each retry attempt.",
"examples": [
0,
1,
2,
3,
5
],
"minimum": 0,
"title": "Kafka Retry Backoff",
"type": "integer"
},
"object_storages": {
"additionalProperties": {
"$ref": "#/$defs/S3ObjectStorageNodeConfig"
Expand Down Expand Up @@ -351,15 +398,15 @@
"title": "Db Permissions",
"type": "array"
},
"db_connection_str": {
"mongo_dsn": {
"description": "MongoDB connection string. Might include credentials. For more information see: https://naiveskill.com/mongodb-connection-string/",
"examples": [
"mongodb://localhost:27017"
],
"format": "password",
"title": "Db Connection Str",
"type": "string",
"writeOnly": true
"format": "multi-host-uri",
"minLength": 1,
"title": "Mongo Dsn",
"type": "string"
},
"log_level": {
"default": "INFO",
Expand Down Expand Up @@ -530,7 +577,7 @@
"vault_path",
"token_hashes",
"db_prefix",
"db_connection_str"
"mongo_dsn"
],
"title": "ModSettings",
"type": "object"
Expand Down
6 changes: 5 additions & 1 deletion example_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ cors_allow_credentials: null
cors_allowed_headers: null
cors_allowed_methods: null
cors_allowed_origins: null
db_connection_str: '**********'
db_permissions:
- '*.*:rw'
db_prefix: test_
docs_url: /docs
generate_correlation_id: true
host: 127.0.0.1
kafka_dlq_topic: dlq
kafka_enable_dlq: false
kafka_max_message_size: 1048576
kafka_max_retries: 0
kafka_retry_backoff: 0
kafka_security_protocol: PLAINTEXT
kafka_servers:
- kafka:9092
Expand All @@ -23,6 +26,7 @@ kafka_ssl_password: ''
log_format: null
log_level: INFO
log_traceback: true
mongo_dsn: '**********'
object_storages:
primary:
bucket: permanent
Expand Down
Loading

0 comments on commit a8a4ac8

Please sign in to comment.