Skip to content

Commit

Permalink
feat: remove usage of unified sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyrag committed Oct 16, 2024
1 parent b6c10b6 commit 129f97e
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 26 deletions.
5 changes: 0 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ toolchain go1.22.7

replace github.com/formancehq/stack/ledger/client => ./pkg/client

replace github.com/formancehq/formance-sdk-go/v2 => ../../releases/sdks/go

replace google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215 => google.golang.org/genproto v0.0.0-20240903143218-8af14fe29dc1

require (
github.com/ThreeDotsLabs/watermill v1.3.7
github.com/alitto/pond v1.9.2
github.com/antlr/antlr4/runtime/Go/antlr v1.4.10
github.com/bluele/gcache v0.0.2
github.com/formancehq/formance-sdk-go/v2 v2.3.1
github.com/formancehq/go-libs v1.7.2-0.20240924160248-25cc3741eba3
github.com/formancehq/stack/ledger/client v0.0.0-00010101000000-000000000000
github.com/go-chi/chi/v5 v5.1.0
Expand All @@ -30,7 +27,6 @@ require (
github.com/onsi/gomega v1.34.2
github.com/pborman/uuid v1.2.1
github.com/pkg/errors v0.9.1
github.com/shomali11/xsql v0.0.0-20190608141458-bf76292144df
github.com/spf13/cobra v1.8.1
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.9.0
Expand Down Expand Up @@ -138,7 +134,6 @@ require (
github.com/rs/cors v1.11.1 // indirect
github.com/shirou/gopsutil/v4 v4.24.8 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/shomali11/util v0.0.0-20180607005212-e0f70fd665ff // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/tklauser/go-sysconf v0.3.14 // indirect
github.com/tklauser/numcpus v0.8.0 // indirect
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,6 @@ github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFt
github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ=
github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU=
github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k=
github.com/shomali11/util v0.0.0-20180607005212-e0f70fd665ff h1:A47HTOEURe8GFXu/9ztnUzVgBBo0NlWoKmVPmfJ4LR8=
github.com/shomali11/util v0.0.0-20180607005212-e0f70fd665ff/go.mod h1:WWE2GJM9B5UpdOiwH2val10w/pvJ2cUUQOOA/4LgOng=
github.com/shomali11/xsql v0.0.0-20190608141458-bf76292144df h1:SVCDTuzM3KEk8WBwSSw7RTPLw9ajzBaXDg39Bo6xIeU=
github.com/shomali11/xsql v0.0.0-20190608141458-bf76292144df/go.mod h1:K8jR5lDI2MGs9Ky+X2jIF4MwIslI0L8o8ijIlEq7/Vw=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
Expand Down
2 changes: 1 addition & 1 deletion internal/storage/ledger/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type Volumes struct {

type AggregatedAccountVolume struct {
Volumes
Asset string `bun:"asset"`
Asset string `bun:"asset"`
}

type AggregatedAccountVolumes []AggregatedAccountVolume
Expand Down
1 change: 1 addition & 0 deletions internal/storage/ledger/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"database/sql/driver"
"encoding/json"
"fmt"

"github.com/formancehq/ledger/internal/tracing"

"github.com/formancehq/go-libs/bun/bunpaginate"
Expand Down
8 changes: 4 additions & 4 deletions internal/storage/ledger/moves.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ type Move struct {
AccountSeq int `bun:"accounts_seq,type:int"`
InsertionDate time.Time `bun:"insertion_date,type:timestamp"`
EffectiveDate time.Time `bun:"effective_date,type:timestamp"`
PostCommitVolumes *Volumes `bun:"post_commit_volumes,type:jsonb,scanonly"`
PostCommitEffectiveVolumes *Volumes `bun:"post_commit_effective_volumes,type:jsonb,scanonly"`
PostCommitVolumes *Volumes `bun:"post_commit_volumes,type:jsonb,scanonly"`
PostCommitEffectiveVolumes *Volumes `bun:"post_commit_effective_volumes,type:jsonb,scanonly"`
}

type Moves []*Move
Expand Down Expand Up @@ -117,7 +117,7 @@ func (m Moves) ComputePostCommitVolumes() TransactionsPostCommitVolumes {
Volumes: *move.PostCommitVolumes,
Asset: move.Asset,
},
Account: move.Account,
Account: move.Account,
})
}
return ret
Expand All @@ -131,7 +131,7 @@ func (m Moves) ComputePostCommitEffectiveVolumes() TransactionsPostCommitVolumes
Volumes: *move.PostCommitEffectiveVolumes,
Asset: move.Asset,
},
Account: move.Account,
Account: move.Account,
})
}
return ret
Expand Down
24 changes: 12 additions & 12 deletions test/performance/env_remote_stack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ package performance_test

import (
"context"
formance "github.com/formancehq/formance-sdk-go/v2"
"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
"github.com/formancehq/go-libs/collectionutils"
"github.com/formancehq/go-libs/time"
ledger "github.com/formancehq/ledger/internal"
ledgerclient "github.com/formancehq/stack/ledger/client"
"github.com/formancehq/stack/ledger/client/models/components"
"github.com/formancehq/stack/ledger/client/models/operations"
"github.com/pkg/errors"
"github.com/stretchr/testify/require"
"net/http"
Expand All @@ -23,13 +23,13 @@ type RemoteStackEnvFactory struct {

func (r *RemoteStackEnvFactory) Create(ctx context.Context, b *testing.B, ledger ledger.Ledger) Env {

client := formance.New(
formance.WithClient(r.httpClient),
formance.WithServerURL(r.stackURL),
client := ledgerclient.New(
ledgerclient.WithClient(r.httpClient),
ledgerclient.WithServerURL(r.stackURL + "/api/ledger"),
)

_, err := client.Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{
V2CreateLedgerRequest: &shared.V2CreateLedgerRequest{
V2CreateLedgerRequest: &components.V2CreateLedgerRequest{
Bucket: &ledger.Bucket,
Metadata: ledger.Metadata,
Features: ledger.Features,
Expand All @@ -52,7 +52,7 @@ func NewRemoteStackEnvFactory(httpClient *http.Client, stackURL string) *RemoteS

type RemoteStackEnv struct {
ledger ledger.Ledger
client *formance.Formance
client *ledgerclient.Formance
}

func (r *RemoteStackEnv) Executor() TransactionExecutor {
Expand All @@ -62,8 +62,8 @@ func (r *RemoteStackEnv) Executor() TransactionExecutor {
varsAsMapAny[k] = v
}
response, err := r.client.Ledger.V2.CreateTransaction(ctx, operations.V2CreateTransactionRequest{
V2PostTransaction: shared.V2PostTransaction{
Script: &shared.V2PostTransactionScript{
V2PostTransaction: components.V2PostTransaction{
Script: &components.V2PostTransactionScript{
Plain: script,
Vars: varsAsMapAny,
},
Expand All @@ -76,7 +76,7 @@ func (r *RemoteStackEnv) Executor() TransactionExecutor {

return &ledger.Transaction{
TransactionData: ledger.TransactionData{
Postings: collectionutils.Map(response.V2CreateTransactionResponse.Data.Postings, func(from shared.V2Posting) ledger.Posting {
Postings: collectionutils.Map(response.V2CreateTransactionResponse.Data.Postings, func(from components.V2Posting) ledger.Posting {
return ledger.Posting{
Source: from.Source,
Destination: from.Destination,
Expand Down Expand Up @@ -105,7 +105,7 @@ func (r *RemoteStackEnv) Stop() error {
return nil
}

func NewRemoveStackEnv(client *formance.Formance, ledger ledger.Ledger) *RemoteStackEnv {
func NewRemoveStackEnv(client *ledgerclient.Formance, ledger ledger.Ledger) *RemoteStackEnv {
return &RemoteStackEnv{
client: client,
ledger: ledger,
Expand Down

0 comments on commit 129f97e

Please sign in to comment.