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

feat: split writer to pipeline #4

Merged
merged 1 commit into from
Aug 1, 2023
Merged
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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ proto:
api/grpc/limits/*.proto \
api/grpc/permits/*.proto \
api/grpc/reader/*.proto \
api/grpc/resolver/*.proto \
api/grpc/subject/*.proto \
api/grpc/subscriptions/*.proto \
api/grpc/writer/*.proto
api/grpc/subscriptions/*.proto

vet: proto
go vet
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func main() {
NewClientBuilder().
ReaderUri("core-reader:50051"). // skip this line if reader API is not used
SubscriptionsUri("core-subscriptionsproxy:50051"). // skip this line if subscriptions API is not used
WriterUri("core-writer:50051"). // skip this line if writer API is not used
WriterUri("core-resolver:50051"). // skip this line if writer API is not used
Build()
if err != nil {
panic(err)
Expand Down
8 changes: 4 additions & 4 deletions api/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"github.com/awakari/client-sdk-go/api/grpc/limits"
"github.com/awakari/client-sdk-go/api/grpc/permits"
"github.com/awakari/client-sdk-go/api/grpc/reader"
"github.com/awakari/client-sdk-go/api/grpc/resolver"
"github.com/awakari/client-sdk-go/api/grpc/subscriptions"
"github.com/awakari/client-sdk-go/api/grpc/writer"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
Expand Down Expand Up @@ -162,10 +162,10 @@ func (b *builder) Build() (c Client, err error) {
} else if b.apiUri != "" {
connWriter, err = grpc.Dial(b.apiUri, optsDial...)
}
var svcWriter writer.Service
var svcWriter resolver.Service
if connWriter != nil {
clientWriter := writer.NewServiceClient(connWriter)
svcWriter = writer.NewService(clientWriter)
clientWriter := resolver.NewServiceClient(connWriter)
svcWriter = resolver.NewService(clientWriter)
}
//
c = client{
Expand Down
4 changes: 2 additions & 2 deletions api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"github.com/awakari/client-sdk-go/api/grpc/limits"
"github.com/awakari/client-sdk-go/api/grpc/permits"
"github.com/awakari/client-sdk-go/api/grpc/reader"
"github.com/awakari/client-sdk-go/api/grpc/resolver"
"github.com/awakari/client-sdk-go/api/grpc/subscriptions"
"github.com/awakari/client-sdk-go/api/grpc/writer"
"github.com/awakari/client-sdk-go/model"
"github.com/awakari/client-sdk-go/model/subscription"
"github.com/awakari/client-sdk-go/model/usage"
Expand Down Expand Up @@ -65,7 +65,7 @@ type client struct {
svcReader reader.Service
svcPermits permits.Service
svcSubs subscriptions.Service
svcWriter writer.Service
svcWriter resolver.Service
}

var ErrApiDisabled = errors.New("the API call is not enabled for this client")
Expand Down
18 changes: 9 additions & 9 deletions api/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"github.com/awakari/client-sdk-go/api/grpc/limits"
"github.com/awakari/client-sdk-go/api/grpc/permits"
"github.com/awakari/client-sdk-go/api/grpc/reader"
"github.com/awakari/client-sdk-go/api/grpc/resolver"
"github.com/awakari/client-sdk-go/api/grpc/subject"
"github.com/awakari/client-sdk-go/api/grpc/subscriptions"
"github.com/awakari/client-sdk-go/api/grpc/writer"
"github.com/awakari/client-sdk-go/model/subscription"
"github.com/awakari/client-sdk-go/model/subscription/condition"
"github.com/awakari/client-sdk-go/model/usage"
Expand Down Expand Up @@ -243,7 +243,7 @@ func TestClient_ReadMessages(t *testing.T) {

func TestClient_WriteMessages(t *testing.T) {
cases := map[string]struct {
svcWriter writer.Service
svcWriter resolver.Service
userId string
err0 error
msgs []*pb.CloudEvent
Expand All @@ -255,17 +255,17 @@ func TestClient_WriteMessages(t *testing.T) {
err0: ErrApiDisabled,
},
"fail open stream": {
svcWriter: writer.NewServiceMock(),
svcWriter: resolver.NewServiceMock(),
userId: "fail",
err0: writer.ErrInternal,
err0: resolver.ErrInternal,
},
"fail auth": {
svcWriter: writer.NewServiceMock(),
svcWriter: resolver.NewServiceMock(),
userId: "fail_auth",
err0: auth.ErrAuth,
},
"fail write": {
svcWriter: writer.NewServiceMock(),
svcWriter: resolver.NewServiceMock(),
userId: "user0",
msgs: []*pb.CloudEvent{
{
Expand All @@ -276,10 +276,10 @@ func TestClient_WriteMessages(t *testing.T) {
},
},
ackCount: 1,
err1: writer.ErrInternal,
err1: resolver.ErrInternal,
},
"limit reached": {
svcWriter: writer.NewServiceMock(),
svcWriter: resolver.NewServiceMock(),
userId: "user0",
msgs: []*pb.CloudEvent{
{
Expand All @@ -296,7 +296,7 @@ func TestClient_WriteMessages(t *testing.T) {
err1: limits.ErrReached,
},
"ok": {
svcWriter: writer.NewServiceMock(),
svcWriter: resolver.NewServiceMock(),
userId: "user0",
msgs: []*pb.CloudEvent{
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package writer
package resolver

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package writer
package resolver

import (
"context"
Expand Down
126 changes: 63 additions & 63 deletions api/grpc/writer/service.pb.go → api/grpc/resolver/service.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
syntax = "proto3";

package awakari.writer;
package awakari.resolver;

option go_package = "api/grpc/writer";
option go_package = "api/grpc/resolver";

import "api/grpc/cloudevents/cloudevent.proto";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package writer
package resolver

import (
"context"
Expand Down
Loading
Loading