From 12953ad7bc6d5875ab27193605ccae7e107df0a4 Mon Sep 17 00:00:00 2001 From: ascandone Date: Wed, 2 Oct 2024 17:18:36 +0200 Subject: [PATCH 1/7] feat: Using numscript dependency in the ledger --- cmd/serve.go | 13 +- docs/api/README.md | 1184 ++++++++--------- go.mod | 11 +- go.sum | 30 +- internal/api/v2/controllers_bulk.go | 4 + .../api/v2/controllers_transactions_create.go | 6 + internal/api/v2/errors.go | 3 + internal/controller/ledger/errors.go | 31 + .../controller/ledger/numscript_runtime.go | 52 +- internal/controller/ledger/store.go | 40 + ledger | Bin 0 -> 47605090 bytes openapi.yaml | 388 +++--- openapi/v2.yaml | 309 ++--- .../docs/models/components/v2errorsenum.md | 33 +- pkg/client/models/components/v2errorsenum.go | 17 + test/e2e/api_bulk.go | 2 +- test/e2e/api_transactions_create.go | 19 +- 17 files changed, 1136 insertions(+), 1006 deletions(-) create mode 100755 ledger diff --git a/cmd/serve.go b/cmd/serve.go index 5c6f30ff7..6e7a727bc 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -1,6 +1,10 @@ package cmd import ( + "net/http" + "net/http/pprof" + "time" + apilib "github.com/formancehq/go-libs/v2/api" "github.com/formancehq/go-libs/v2/health" "github.com/formancehq/go-libs/v2/httpserver" @@ -8,9 +12,8 @@ import ( "github.com/formancehq/ledger/internal/storage/driver" "github.com/go-chi/chi/v5" "go.opentelemetry.io/otel/sdk/metric" - "net/http" - "net/http/pprof" - "time" + + "github.com/formancehq/ledger/internal/bus" "github.com/formancehq/go-libs/v2/auth" "github.com/formancehq/go-libs/v2/aws/iam" @@ -19,7 +22,7 @@ import ( "github.com/formancehq/go-libs/v2/otlp/otlptraces" "github.com/formancehq/go-libs/v2/publish" "github.com/formancehq/ledger/internal/api" - "github.com/formancehq/ledger/internal/bus" + ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" systemcontroller "github.com/formancehq/ledger/internal/controller/system" "github.com/formancehq/ledger/internal/storage" @@ -37,6 +40,7 @@ const ( AutoUpgradeFlag = "auto-upgrade" ExperimentalFeaturesFlag = "experimental-features" BulkMaxSizeFlag = "bulk-max-size" + NumscriptInterpreterFlag = "numscript-interpreter" ) func NewServeCommand() *cobra.Command { @@ -120,6 +124,7 @@ func NewServeCommand() *cobra.Command { cmd.Flags().String(BindFlag, "0.0.0.0:3068", "API bind address") cmd.Flags().Bool(ExperimentalFeaturesFlag, false, "Enable features configurability") cmd.Flags().Int(BulkMaxSizeFlag, api.DefaultBulkMaxSize, "Bulk max size (default 100)") + cmd.Flags().Bool(NumscriptInterpreterFlag, false, "Enable experimental numscript rewrite") service.AddFlags(cmd.Flags()) bunconnect.AddFlags(cmd.Flags()) diff --git a/docs/api/README.md b/docs/api/README.md index 7cd5c29c8..7464bde45 100644 --- a/docs/api/README.md +++ b/docs/api/README.md @@ -6,18 +6,18 @@ Base URLs: -* http://localhost:8080/ +- http://localhost:8080/ # Authentication -- oAuth2 authentication. +- oAuth2 authentication. - - Flow: clientCredentials + - Flow: clientCredentials - - Token URL = [/api/auth/oauth/token](/api/auth/oauth/token) + - Token URL = [/api/auth/oauth/token](/api/auth/oauth/token) -|Scope|Scope Description| -|---|---| +| Scope | Scope Description | +| ----- | ----------------- |

ledger

@@ -49,11 +49,11 @@ Accept: application/json

Responses

-|Status|Meaning|Description|Schema| -|---|---|---|---| -|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|OK|[V2ConfigInfo](#schemav2configinfo)| -|default|Default|Error|[V2ErrorResponse](#schemav2errorresponse)| -|5XX|Unknown|Error|[V2ErrorResponse](#schemav2errorresponse)| +| Status | Meaning | Description | Schema | +| ------- | ------------------------------------------------------- | ----------- | ----------------------------------------- | +| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | [V2ConfigInfo](#schemav2configinfo) | +| default | Default | Error | [V2ErrorResponse](#schemav2errorresponse) | +| 5XX | Unknown | Error | [V2ErrorResponse](#schemav2errorresponse) |