Skip to content

Commit

Permalink
start payer service
Browse files Browse the repository at this point in the history
  • Loading branch information
neekolas committed Oct 18, 2024
1 parent 8d4b9bf commit cc91aa8
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
31 changes: 31 additions & 0 deletions pkg/api/payer/service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package payer

import (
"context"

"github.com/xmtp/xmtpd/pkg/proto/xmtpv4/payer_api"
"go.uber.org/zap"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)

type Service struct {
payer_api.UnimplementedPayerApiServer

ctx context.Context
log *zap.Logger
}

func NewPayerApiService(ctx context.Context, log *zap.Logger) (*Service, error) {
return &Service{
ctx: ctx,
log: log,
}, nil
}

func (s *Service) PublishClientEnvelopes(
ctx context.Context,
req *payer_api.PublishClientEnvelopesRequest,
) (*payer_api.PublishClientEnvelopesResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method PublishClientEnvelopes not implemented")
}
13 changes: 10 additions & 3 deletions pkg/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ import (

"github.com/pires/go-proxyproto"
"github.com/xmtp/xmtpd/pkg/api/message"
"github.com/xmtp/xmtpd/pkg/api/payer"
"github.com/xmtp/xmtpd/pkg/blockchain"
"github.com/xmtp/xmtpd/pkg/proto/xmtpv4/message_api"
"github.com/xmtp/xmtpd/pkg/proto/xmtpv4/payer_api"
"github.com/xmtp/xmtpd/pkg/registrant"
"github.com/xmtp/xmtpd/pkg/tracing"
"go.uber.org/zap"
Expand All @@ -32,7 +34,6 @@ type ApiServer struct {
grpcServer *grpc.Server
log *zap.Logger
registrant *registrant.Registrant
service message_api.ReplicationApiServer
wg sync.WaitGroup
}

Expand Down Expand Up @@ -97,8 +98,14 @@ func NewAPIServer(
if err != nil {
return nil, err
}
s.service = replicationService
message_api.RegisterReplicationApiServer(s.grpcServer, s.service)

message_api.RegisterReplicationApiServer(s.grpcServer, replicationService)

payerService, err := payer.NewPayerApiService(ctx, log)
if err != nil {
return nil, err
}
payer_api.RegisterPayerApiServer(s.grpcServer, payerService)

tracing.GoPanicWrap(s.ctx, &s.wg, "grpc", func(ctx context.Context) {
s.log.Info("serving grpc", zap.String("address", s.grpcListener.Addr().String()))
Expand Down

0 comments on commit cc91aa8

Please sign in to comment.