Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attempt at using temporalserver #2905

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions backend/internal/temporal/clientmanager/client_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ type ClientFactory interface {

type TemporalClientFactory struct{}

var _ ClientFactory = (*TemporalClientFactory)(nil)

func NewTemporalClientFactory() *TemporalClientFactory {
return &TemporalClientFactory{}
}
Expand Down
47 changes: 47 additions & 0 deletions backend/pkg/integration-test/integration-test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ import (
promapiv1mock "github.com/nucleuscloud/neosync/internal/mocks/github.com/prometheus/client_golang/api/prometheus/v1"
tcpostgres "github.com/nucleuscloud/neosync/internal/testutil/testcontainers/postgres"
http_client "github.com/nucleuscloud/neosync/worker/pkg/http/client"
temporalclient "go.temporal.io/sdk/client"
"go.temporal.io/server/temporaltest"
)

var (
Expand Down Expand Up @@ -81,6 +83,9 @@ type NeosyncApiTestClient struct {

httpsrv *httptest.Server

temporalServer *temporaltest.TestServer
temporalManager *clientmanager.ClientManager

UnauthdClients *UnauthdClients
NeosyncCloudClients *NeosyncCloudClients
AuthdClients *AuthdClients
Expand Down Expand Up @@ -150,6 +155,16 @@ func (s *NeosyncApiTestClient) Setup(ctx context.Context, t *testing.T) error {
s.NeosyncQuerier = db_queries.New()
s.systemQuerier = pg_queries.New()

s.temporalServer = temporaltest.NewServer(
temporaltest.WithT(t),
)

temporalConfigProvider := clientmanager.NewDBConfigProvider(&clientmanager.TemporalConfig{
Namespace: s.temporalServer.GetDefaultNamespace(),
}, s.NeosyncQuerier, pgcontainer.DB)
temporalFactory := NewTemporalTestClientFactory(s.temporalServer)
s.temporalManager = clientmanager.NewClientManager(temporalConfigProvider, temporalFactory)

s.Mocks = &Mocks{
TemporalClientManager: clientmanager.NewMockInterface(t),
TemporalConfigProvider: clientmanager.NewMockConfigProvider(t),
Expand Down Expand Up @@ -430,6 +445,9 @@ func (s *NeosyncApiTestClient) TearDown(ctx context.Context) error {
}
}
}
if s.temporalServer != nil {
s.temporalServer.Stop()
}
return nil
}

Expand All @@ -450,3 +468,32 @@ func NewTestSqlManagerClient() *sqlmanager.SqlManager {
&sqlconnect.SqlOpenConnector{},
)
}

type TemporalTestClientFactory struct {
server *temporaltest.TestServer
}

func NewTemporalTestClientFactory(server *temporaltest.TestServer) *TemporalTestClientFactory {
return &TemporalTestClientFactory{server: server}
}

var _ clientmanager.ClientFactory = (*TemporalTestClientFactory)(nil)

func (f *TemporalTestClientFactory) CreateNamespaceClient(
ctx context.Context,
config *clientmanager.TemporalConfig,
logger *slog.Logger,
) (temporalclient.NamespaceClient, error) {
return temporalclient.NewNamespaceClient(temporalclient.Options{
Namespace: f.server.GetDefaultNamespace(),
// HostPort: , // todo
})
}

func (f *TemporalTestClientFactory) CreateWorkflowClient(
ctx context.Context,
config *clientmanager.TemporalConfig,
logger *slog.Logger,
) (temporalclient.Client, error) {
return f.server.GetDefaultClient(), nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ var (
func (s *IntegrationTestSuite) Test_UserAccountService_GetAccountTemporalConfig() {
accountId := s.createPersonalAccount(s.ctx, s.UnauthdClients.Users)

s.Mocks.TemporalConfigProvider.On("GetConfig", mock.Anything, mock.Anything).
Return(validTemporalConfig, nil)
// s.Mocks.TemporalConfigProvider.On("GetConfig", mock.Anything, mock.Anything).
// Return(validTemporalConfig, nil)

resp, err := s.UnauthdClients.Users.GetAccountTemporalConfig(s.ctx, connect.NewRequest(&mgmtv1alpha1.GetAccountTemporalConfigRequest{AccountId: accountId}))
requireNoErrResp(s.T(), resp, err)
Expand Down
58 changes: 40 additions & 18 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/nucleuscloud/neosync

go 1.22.2
go 1.22.3

toolchain go1.23.2

require (
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.35.1-20240920164238-5a7b106cbb87.1
Expand Down Expand Up @@ -77,9 +79,10 @@ require (
go.opentelemetry.io/otel/sdk v1.31.0
go.opentelemetry.io/otel/sdk/metric v1.31.0
go.opentelemetry.io/otel/trace v1.31.0
go.temporal.io/api v1.40.0
go.temporal.io/api v1.41.0
go.temporal.io/sdk v1.30.0
go.temporal.io/sdk/contrib/opentelemetry v0.6.0
go.temporal.io/server v1.25.1
golang.org/x/crypto v0.28.0
golang.org/x/net v0.30.0
golang.org/x/sync v0.8.0
Expand Down Expand Up @@ -146,7 +149,7 @@ require (
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aws/aws-lambda-go v1.46.0 // indirect
github.com/aws/aws-sdk-go v1.50.31 // indirect
github.com/aws/aws-sdk-go v1.53.15 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.6 // indirect
github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.12.16 // indirect
github.com/aws/aws-sdk-go-v2/feature/dynamodb/expression v1.6.16 // indirect
Expand All @@ -172,10 +175,14 @@ require (
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.3 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/benbjohnson/clock v1.1.0 // indirect
github.com/benhoyt/goawk v1.25.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/bufbuild/protocompile v0.8.0 // indirect
github.com/bwmarrin/snowflake v0.3.0 // indirect
github.com/cactus/go-statsd-client/statsd v0.0.0-20200423205355-cb0885a1018c // indirect
github.com/cactus/go-statsd-client/v5 v5.1.0 // indirect
github.com/census-instrumentation/opencensus-proto v0.4.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/charmbracelet/x/ansi v0.4.2 // indirect
Expand All @@ -195,6 +202,7 @@ require (
github.com/cznic/mathutil v0.0.0-20180504122225-ca4c9f2c1369 // indirect
github.com/danieljoos/wincred v1.2.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/dlclark/regexp2 v1.10.0 // indirect
Expand All @@ -208,6 +216,7 @@ require (
github.com/eapache/queue v1.1.0 // indirect
github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/envoyproxy/go-control-plane v0.13.0 // indirect
github.com/envoyproxy/protoc-gen-validate v1.1.0 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
Expand All @@ -219,7 +228,7 @@ require (
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/generikvault/gvalstrings v0.0.0-20180926130504-471f38f0112a // indirect
github.com/getkin/kin-openapi v0.128.0 // indirect
github.com/go-faker/faker/v4 v4.3.0 // indirect
github.com/go-faker/faker/v4 v4.4.1 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
Expand All @@ -236,7 +245,7 @@ require (
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
github.com/golang-sql/sqlexp v0.1.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/mock v1.7.0-rc.1 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/cel-go v0.21.0 // indirect
Expand Down Expand Up @@ -267,6 +276,7 @@ require (
github.com/hashicorp/golang-lru/arc/v2 v2.0.7 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/iancoleman/strcase v0.3.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/influxdata/go-syslog/v3 v3.0.0 // indirect
github.com/invopop/yaml v0.3.1 // indirect
Expand All @@ -288,14 +298,14 @@ require (
github.com/jcmturner/rpc/v2 v2.0.3 // indirect
github.com/jhump/protoreflect v1.15.6 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jmoiron/sqlx v1.3.4 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/k0kubun/pp v2.3.0+incompatible // indirect
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/klauspost/pgzip v1.2.6 // indirect
github.com/ktrysmt/go-bitbucket v0.6.4 // indirect
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
Expand Down Expand Up @@ -333,6 +343,7 @@ require (
github.com/mutecomm/go-sqlcipher/v4 v4.4.0 // indirect
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
github.com/nakagami/firebirdsql v0.0.0-20190310045651-3c02a58cfed8 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/neo4j/neo4j-go-driver v1.8.1-0.20200803113522-b626aa943eba // indirect
github.com/nexus-rpc/sdk-go v0.0.11 // indirect
github.com/nsf/jsondiff v0.0.0-20210926074059-1e845ec5d249 // indirect
Expand All @@ -343,6 +354,7 @@ require (
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/opensearch-project/opensearch-go/v3 v3.0.0 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/parquet-go/parquet-go v0.23.0 // indirect
github.com/pborman/uuid v1.2.1 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
Expand Down Expand Up @@ -376,6 +388,7 @@ require (
github.com/shopspring/decimal v1.3.1 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/snowflakedb/gosnowflake v1.7.2 // indirect
github.com/sony/gobreaker v1.0.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/speakeasy-api/openapi-overlay v0.9.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
Expand All @@ -384,12 +397,18 @@ require (
github.com/stoewer/go-strcase v1.3.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/temporalio/ringpop-go v0.0.0-20240718232345-e2a435d149b6 // indirect
github.com/temporalio/sqlparser v0.0.0-20231115171017-f4060bcfa6cb // indirect
github.com/temporalio/tchannel-go v1.22.1-0.20240528171429-1db37fdea938 // indirect
github.com/tetratelabs/wazero v1.8.0 // indirect
github.com/tilinna/z85 v1.0.0 // indirect
github.com/tklauser/go-sysconf v0.3.13 // indirect
github.com/tklauser/numcpus v0.7.0 // indirect
github.com/twmb/franz-go v1.16.1 // indirect
github.com/twmb/franz-go/pkg/kmsg v1.7.0 // indirect
github.com/twmb/murmur3 v1.1.8 // indirect
github.com/uber-common/bark v1.0.0 // indirect
github.com/uber-go/tally/v4 v4.1.17-0.20240412215630-22fe011f5ff0 // indirect
github.com/urfave/cli/v2 v2.27.1 // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
Expand All @@ -414,10 +433,15 @@ require (
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.31.0 // indirect
go.opentelemetry.io/otel/exporters/prometheus v0.49.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.temporal.io/version v0.3.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/dig v1.17.1 // indirect
go.uber.org/fx v1.22.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sys v0.26.0 // indirect
Expand All @@ -433,27 +457,25 @@ require (
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/validator.v2 v2.0.1 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect
lukechampine.com/uint128 v1.3.0 // indirect
modernc.org/b v1.0.0 // indirect
modernc.org/cc/v3 v3.40.0 // indirect
modernc.org/ccgo/v3 v3.16.13 // indirect
modernc.org/db v1.0.0 // indirect
modernc.org/file v1.0.0 // indirect
modernc.org/fileutil v1.0.0 // indirect
modernc.org/fileutil v1.3.0 // indirect
modernc.org/gc/v3 v3.0.0-20240304020402-f0dba7c97c2b // indirect
modernc.org/golex v1.0.0 // indirect
modernc.org/internal v1.0.0 // indirect
modernc.org/libc v1.29.0 // indirect
modernc.org/libc v1.50.9 // indirect
modernc.org/lldb v1.0.0 // indirect
modernc.org/mathutil v1.6.0 // indirect
modernc.org/memory v1.7.2 // indirect
modernc.org/opt v0.1.3 // indirect
modernc.org/memory v1.8.0 // indirect
modernc.org/ql v1.0.0 // indirect
modernc.org/sortutil v1.1.0 // indirect
modernc.org/sqlite v1.28.0 // indirect
modernc.org/strutil v1.1.3 // indirect
modernc.org/sortutil v1.2.0 // indirect
modernc.org/sqlite v1.30.0 // indirect
modernc.org/strutil v1.2.0 // indirect
modernc.org/token v1.1.0 // indirect
modernc.org/zappy v1.0.0 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
Expand Down
Loading
Loading