diff --git a/api/formance.com/v1beta1/broker_types.go b/api/formance.com/v1beta1/broker_types.go index c10ad52d..79ef4969 100644 --- a/api/formance.com/v1beta1/broker_types.go +++ b/api/formance.com/v1beta1/broker_types.go @@ -40,8 +40,8 @@ type BrokerStatus struct { //+kubebuilder:validation:Enum:={OneStreamByService, OneStreamByStack} // Mode indicating the configuration of the nats streams // Two modes are defined : - // * OneStreamByService: In this case, each service will have a dedicated stream created - // * OneStreamByStack: In this case, a stream will be created for the stack and each service will use a specific subject inside this stream + // * ModeOneStreamByService: In this case, each service will have a dedicated stream created + // * ModeOneStreamByStack: In this case, a stream will be created for the stack and each service will use a specific subject inside this stream Mode Mode `json:"mode"` // Streams list streams created when Mode == ModeOneStreamByService //+optional diff --git a/config/crd/bases/formance.com_brokers.yaml b/config/crd/bases/formance.com_brokers.yaml index 1dd199ad..7fd222c5 100644 --- a/config/crd/bases/formance.com_brokers.yaml +++ b/config/crd/bases/formance.com_brokers.yaml @@ -131,8 +131,8 @@ spec: description: |- Mode indicating the configuration of the nats streams Two modes are defined : - * OneStreamByService: In this case, each service will have a dedicated stream created - * OneStreamByStack: In this case, a stream will be created for the stack and each service will use a specific subject inside this stream + * ModeOneStreamByService: In this case, each service will have a dedicated stream created + * ModeOneStreamByStack: In this case, a stream will be created for the stack and each service will use a specific subject inside this stream enum: - OneStreamByService - OneStreamByStack diff --git a/docs/09-Configuration reference/01-Settings.md b/docs/09-Configuration reference/01-Settings.md index 810016c9..88a21c4c 100644 --- a/docs/09-Configuration reference/01-Settings.md +++ b/docs/09-Configuration reference/01-Settings.md @@ -8,41 +8,43 @@ While we have some basic types (string, number, bool ...), we also have some com ## Available settings -| Key | Type | Example | Description | -|------------------------------------------------------------------------------------------|--------|--------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------| -| aws.service-account | string | | AWS Role | -| postgres.``.uri | URI | | Postgres database configuration | -| elasticsearch.dsn | URI | | Elasticsearch connection URI | -| temporal.dsn | URI | | Temporal URI | -| temporal.tls.crt | string | | Temporal certificate | -| temporal.tls.key | string | | Temporal certificate key | -| broker.dsn | URI | | Broker URI | -| opentelemetry.traces.dsn | URI | | OpenTelemetry collector URI | -| opentelemetry.traces.resource-attributes | Map | key1=value1,key2=value2 | Opentelemetry additional resource attributes | -| clear-database | bool | true | Whether to remove databases on stack deletion | -| ledger.deployment-strategy | string | single | Ledger deployment type | -| ledger.logs.max-batch-size | Int | 1024 | Ledger logs batching max size | -| ledger.api.bulk-max-size | Int | 100 | Max bulk size | -| ledger.experimental-features | Bool | true | Enable experimental features | -| ledger.experimental-numscript-interpreter | Bool | true | Enable new numscript interpreter | -| payments.encryption-key | string | | Payments data encryption key | -| deployments.``.init-containers.``.resource-requirements | Map | cpu=X, mem=X | | -| deployments.``.containers.``.resource-requirements | Map | cpu=X, mem=X | | -| deployments.``.init-containers.``.run-as | Map | user=X, group=X | | -| deployments.``.containers.``.run-as | Map | user=X, group=X | | -| deployments.``.replicas | string | 2 | | -| caddy.image | string | | Caddy image | -+| jobs.``.init-containers.``.run-as | Map | user=X, group=X | Configure the security context for init containers in jobs by specifying the user and group IDs to run as | -| jobs.``.containers.``.run-as | Map | user=X, group=X | Configure the security context for containers in jobs by specifying the user and group IDs to run as | -| registries.``.endpoint | string | | Specify a custom endpoint for a specific docker repository | -| registries.``.images.``.rewrite | string | formancehq/example | Allow to rewrite the image path | -| search.batching | Map | period=1s, count=10 | Override default batching parameters | -| services.``.annotations | Map | | Allow to specify custom annotations to apply on created k8s services | -| gateway.ingress.annotations | Map | | Allow to specify custom annotations to apply on the gateway ingress | -| logging.json | bool | | Configure services to log as json | -| modules.``.database.connection-pool | Map | max-idle=10, max-idle-time=10, max-open=10 | Configure database connection pool for each module. See [Golang documentation](https://go.dev/doc/database/manage-connections) | -| orchestration.max-parallel-activities | Int | 10 | Configure max parallel temporal activities on orchestration workers | -| modules.``.grace-period | string | 5s | Defer application shutdown | +| Key | Type | Example | Description | +|------------------------------------------------------------------------------------------|---------------------------------------------------------------|--------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------| +| aws.service-account | string | | AWS Role | +| postgres.``.uri | URI | | Postgres database configuration | +| elasticsearch.dsn | URI | | Elasticsearch connection URI | +| temporal.dsn | URI | | Temporal URI | +| temporal.tls.crt | string | | Temporal certificate | +| temporal.tls.key | string | | Temporal certificate key | +| broker.dsn | URI | | Broker URI | +| opentelemetry.traces.dsn | URI | | OpenTelemetry collector URI | +| opentelemetry.traces.resource-attributes | Map | key1=value1,key2=value2 | Opentelemetry additional resource attributes | +| clear-database | bool | true | Whether to remove databases on stack deletion | +| ledger.deployment-strategy | string | single | Ledger deployment type | +| ledger.logs.max-batch-size | Int | 1024 | Ledger logs batching max size | +| ledger.api.bulk-max-size | Int | 100 | Max bulk size | +| ledger.api.default-page-size | Int | | Default api page size | +| ledger.api.max-page-size | Int | | Max page size | +| ledger.experimental-features | Bool | true | Enable experimental features | +| ledger.experimental-numscript-interpreter | Bool | true | Enable new numscript interpreter | +| payments.encryption-key | string | | Payments data encryption key | +| deployments.``.init-containers.``.resource-requirements | Map | cpu=X, mem=X | | +| deployments.``.containers.``.resource-requirements | Map | cpu=X, mem=X | | +| deployments.``.init-containers.``.run-as | Map | user=X, group=X | | +| deployments.``.containers.``.run-as | Map | user=X, group=X | | +| deployments.``.replicas | string | 2 | | +| caddy.image | string | | Caddy image | + + | jobs.``.init-containers.``.run-as | Map | user=X, group=X | Configure the security context for init containers in jobs by specifying the user and group IDs to run as | +| jobs.``.containers.``.run-as | Map | user=X, group=X | Configure the security context for containers in jobs by specifying the user and group IDs to run as | +| registries.``.endpoint | string | | Specify a custom endpoint for a specific docker repository | +| registries.``.images.``.rewrite | string | formancehq/example | Allow to rewrite the image path | +| search.batching | Map | period=1s, count=10 | Override default batching parameters | +| services.``.annotations | Map | | Allow to specify custom annotations to apply on created k8s services | +| gateway.ingress.annotations | Map | | Allow to specify custom annotations to apply on the gateway ingress | +| logging.json | bool | | Configure services to log as json | +| modules.``.database.connection-pool | Map | max-idle=10, max-idle-time=10, max-open=10 | Configure database connection pool for each module. See [Golang documentation](https://go.dev/doc/database/manage-connections) | +| orchestration.max-parallel-activities | Int | 10 | Configure max parallel temporal activities on orchestration workers | +| modules.``.grace-period | string | 5s | Defer application shutdown | ### Postgres URI format diff --git a/docs/09-Configuration reference/02-Custom Resource Definitions.md b/docs/09-Configuration reference/02-Custom Resource Definitions.md index 63dc789a..f392e2d6 100644 --- a/docs/09-Configuration reference/02-Custom Resource Definitions.md +++ b/docs/09-Configuration reference/02-Custom Resource Definitions.md @@ -1961,7 +1961,7 @@ Broker is the Schema for the brokers API | `ready` _boolean_ | Ready indicates if the resource is seen as completely reconciled | | | | `info` _string_ | Info can contain any additional like reconciliation errors | | | | `uri` _string_ | | | Type: string
| -| `mode` _[Mode](#mode)_ | Mode indicating the configuration of the nats streams
Two modes are defined :
* OneStreamByService: In this case, each service will have a dedicated stream created
* OneStreamByStack: In this case, a stream will be created for the stack and each service will use a specific subject inside this stream | | Enum: [OneStreamByService OneStreamByStack]
| +| `mode` _[Mode](#mode)_ | Mode indicating the configuration of the nats streams
Two modes are defined :
* ModeOneStreamByService: In this case, each service will have a dedicated stream created
* ModeOneStreamByStack: In this case, a stream will be created for the stack and each service will use a specific subject inside this stream | | Enum: [OneStreamByService OneStreamByStack]
| | `streams` _string array_ | Streams list streams created when Mode == ModeOneStreamByService | | | ###### Mode diff --git a/helm/crds/templates/crds/apiextensions.k8s.io_v1_customresourcedefinition_brokers.formance.com.yaml b/helm/crds/templates/crds/apiextensions.k8s.io_v1_customresourcedefinition_brokers.formance.com.yaml index 4faf7b5f..3d2a526e 100644 --- a/helm/crds/templates/crds/apiextensions.k8s.io_v1_customresourcedefinition_brokers.formance.com.yaml +++ b/helm/crds/templates/crds/apiextensions.k8s.io_v1_customresourcedefinition_brokers.formance.com.yaml @@ -131,8 +131,8 @@ spec: description: |- Mode indicating the configuration of the nats streams Two modes are defined : - * OneStreamByService: In this case, each service will have a dedicated stream created - * OneStreamByStack: In this case, a stream will be created for the stack and each service will use a specific subject inside this stream + * ModeOneStreamByService: In this case, each service will have a dedicated stream created + * ModeOneStreamByStack: In this case, a stream will be created for the stack and each service will use a specific subject inside this stream enum: - OneStreamByService - OneStreamByStack diff --git a/internal/resources/ledgers/deployments.go b/internal/resources/ledgers/deployments.go index 3b456a9a..2c284ef8 100644 --- a/internal/resources/ledgers/deployments.go +++ b/internal/resources/ledgers/deployments.go @@ -171,6 +171,26 @@ func installLedgerStateless(ctx core.Context, stack *v1beta1.Stack, ) } + defaultPageSize, err := settings.GetInt(ctx, stack.Name, "ledger", "api", "default-page-size") + if err != nil { + return fmt.Errorf("failed to get default page size: %w", err) + } + if defaultPageSize != nil { + container.Env = append(container.Env, + core.Env("DEFAULT_PAGE_SIZE", fmt.Sprint(*defaultPageSize)), + ) + } + + maxPageSize, err := settings.GetInt(ctx, stack.Name, "ledger", "api", "max-page-size") + if err != nil { + return fmt.Errorf("failed to get max page size: %w", err) + } + if maxPageSize != nil { + container.Env = append(container.Env, + core.Env("MAX_PAGE_SIZE", fmt.Sprint(*maxPageSize)), + ) + } + var broker *v1beta1.Broker if t, err := brokertopics.Find(ctx, stack, "ledger"); err != nil { return err