Skip to content

Commit 91e9ed8

Browse files
authored
fix: OECO cleanup 22 (#54)
* fix: found bug when using remote connectors * fix: adding exists to the CQRS check --------- Co-authored-by: Dimy Jeannot <>
1 parent 799b119 commit 91e9ed8

File tree

33 files changed

+266
-162
lines changed

33 files changed

+266
-162
lines changed

libs/partner/go/zap/main.go

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ type Binding struct {
1717
Logger *zap.Logger
1818
SugaredLogger *zap.SugaredLogger
1919

20+
LoggerWrapper *ZapLoggerWrapper
21+
SugaredLoggerWrapper *ZapSugaredLoggerWrapper
22+
2023
configuration *Configuration
2124
}
2225

@@ -53,8 +56,10 @@ func (b *Binding) Bind(_ context.Context, bindings *sdkv2alphalib.Bindings) *sdk
5356
defer b.Logger.Sync() //nolint:errcheck
5457

5558
Bound = &Binding{
56-
Logger: b.Logger,
57-
SugaredLogger: b.Logger.Sugar(),
59+
Logger: b.Logger,
60+
SugaredLogger: b.Logger.Sugar(),
61+
LoggerWrapper: NewZapLoggerWrapper(b.Logger),
62+
SugaredLoggerWrapper: NewZapSugaredLoggerWrapper(b.Logger.Sugar()),
5863

5964
configuration: b.configuration,
6065
}
@@ -78,3 +83,41 @@ func (b *Binding) Close() error {
7883
fmt.Println("Closing the Uber Zap Logger Binding")
7984
return nil
8085
}
86+
87+
// ZapLoggerWrapper wraps a zap.Logger to implement log-compatible interfaces like Printf for structured logging.
88+
// It provides a convenient way to integrate zap.Logger into libraries expecting standard logging interfaces.
89+
type ZapLoggerWrapper struct {
90+
logger *zap.Logger
91+
}
92+
93+
// NewZapLoggerWrapper creates and returns a new instance of ZapLoggerWrapper using the provided zap.Logger instance.
94+
func NewZapLoggerWrapper(z *zap.Logger) *ZapLoggerWrapper {
95+
return &ZapLoggerWrapper{
96+
logger: z,
97+
}
98+
}
99+
100+
// Printf logs a formatted message at the INFO level using the zap.Logger instance.
101+
func (z *ZapLoggerWrapper) Printf(format string, v ...any) {
102+
msg := fmt.Sprintf(format, v...)
103+
z.logger.Info(msg)
104+
}
105+
106+
// ZapSugaredLoggerWrapper is a wrapper around zap.SugaredLogger to provide custom logging functionalities.
107+
// It includes methods for structured and formatted logging leveraging the underlying zap.SugaredLogger instance.
108+
type ZapSugaredLoggerWrapper struct {
109+
logger *zap.SugaredLogger
110+
}
111+
112+
// NewZapSugaredLoggerWrapper initializes and returns a new ZapSugaredLoggerWrapper using the provided SugaredLogger instance.
113+
func NewZapSugaredLoggerWrapper(z *zap.SugaredLogger) *ZapSugaredLoggerWrapper {
114+
return &ZapSugaredLoggerWrapper{
115+
logger: z,
116+
}
117+
}
118+
119+
// Printf logs a formatted message at the Info level using the provided format and arguments.
120+
func (z *ZapSugaredLoggerWrapper) Printf(format string, v ...any) {
121+
msg := fmt.Sprintf(format, v...)
122+
z.logger.Info(msg)
123+
}

libs/plugins/protoc-gen-platform/languages/go/plugins/cli_methods/templates/file.go.tmpl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,12 @@ import (
1616
"github.com/spf13/cobra"
1717
{{ if ne (getApiOptionsNetwork . ) "overlay" -}}
1818
"net/http"
19-
"github.com/openecosystems/ecosystem/libs/{{ $apiType }}/go/sdk/gen/platform/{{ $system.LowerCamelCase }}/{{ $versionLower }}"
20-
"github.com/openecosystems/ecosystem/libs/{{ $apiType }}/go/sdk/gen/platform/{{ $system.LowerCamelCase }}/{{ $versionLower }}/{{ $system.LowerCamelCase }}{{ $versionLower }}pbconnect"
2119
{{ else -}}
22-
"github.com/openecosystems/ecosystem/libs/{{ $apiType }}/go/sdk/gen/platform/{{ $system.LowerCamelCase }}/{{ $versionLower }}"
23-
"github.com/openecosystems/ecosystem/libs/{{ $apiType }}/go/sdk/gen/platform/{{ $system.LowerCamelCase }}/{{ $versionLower }}/{{ $system.LowerCamelCase }}{{ $versionLower }}pbconnect"
2420
{{ end }}
2521

2622
{{ range getImportPackages .File }}
27-
//"{{ . }}"
23+
"{{ . }}"
24+
"{{ . }}/{{ $system.LowerCamelCase }}{{ $versionLower }}pbconnect"
2825
{{ end }}
2926
)
3027

libs/plugins/protoc-gen-platform/shared/functions_cqrs.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ func (fns Functions) IsCQRSType(method pgs.Method) string {
139139
return "query"
140140
case options.CQRSType_CQRS_TYPE_QUERY_GET:
141141
return "query"
142+
case options.CQRSType_CQRS_TYPE_QUERY_EXISTS:
143+
return "query"
142144
case options.CQRSType_CQRS_TYPE_QUERY_CLIENT_STREAM:
143145
return "query-client-stream"
144146
case options.CQRSType_CQRS_TYPE_QUERY_SERVER_STREAM:
@@ -188,6 +190,8 @@ func (fns Functions) GetCQRSType(method pgs.Method) string {
188190
return "list"
189191
case options.CQRSType_CQRS_TYPE_QUERY_GET:
190192
return "get"
193+
case options.CQRSType_CQRS_TYPE_QUERY_EXISTS:
194+
return "exists"
191195
case options.CQRSType_CQRS_TYPE_QUERY_CLIENT_STREAM:
192196
return "stream-client"
193197
case options.CQRSType_CQRS_TYPE_QUERY_SERVER_STREAM:
@@ -216,6 +220,8 @@ func (fns Functions) ConvertCQRSTypeToString(t options.CQRSType) string {
216220
return "Mutation"
217221
case options.CQRSType_CQRS_TYPE_QUERY_LIST:
218222
fallthrough
223+
case options.CQRSType_CQRS_TYPE_QUERY_EXISTS:
224+
fallthrough
219225
case options.CQRSType_CQRS_TYPE_QUERY_STREAM:
220226
fallthrough
221227
case options.CQRSType_CQRS_TYPE_QUERY_CLIENT_STREAM:

libs/public/go/sdk/gen/platform/communication/v1alpha/communicationv1alphapbcli/create_or_update_preference.cmd.go

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/public/go/sdk/gen/platform/communication/v1alpha/communicationv1alphapbcli/delete_preference.cmd.go

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/public/go/sdk/gen/platform/communication/v1alpha/communicationv1alphapbcli/get_preference.cmd.go

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/public/go/sdk/gen/platform/communication/v1alpha/communicationv1alphapbcli/get_preference_options.cmd.go

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/public/go/sdk/gen/platform/communication/v1beta/communicationv1betapbcli/create_or_update_preference.cmd.go

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/public/go/sdk/gen/platform/communication/v1beta/communicationv1betapbcli/delete_preference.cmd.go

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/public/go/sdk/gen/platform/communication/v1beta/communicationv1betapbcli/get_preference.cmd.go

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)