move messages to mail (#56)

This commit is contained in:
Asim Aslam
2021-02-01 11:20:52 +00:00
committed by GitHub
parent 39c77b9aeb
commit 226a595590
10 changed files with 137 additions and 114 deletions

27
mail/Makefile Normal file
View File

@@ -0,0 +1,27 @@
GOPATH:=$(shell go env GOPATH)
.PHONY: init
init:
go get -u github.com/golang/protobuf/proto
go get -u github.com/golang/protobuf/protoc-gen-go
go get github.com/micro/micro/v3/cmd/protoc-gen-micro
.PHONY: proto
proto:
protoc --openapi_out=. --proto_path=. --micro_out=. --go_out=:. proto/mail.proto
.PHONY: docs
docs:
protoc --openapi_out=. --proto_path=. --micro_out=. --go_out=:. proto/mail.proto
@redoc-cli bundle api-protobuf.json
.PHONY: build
build:
go build -o mail *.go
.PHONY: test
test:
go test -v ./... -cover
.PHONY: docker
docker:
docker build . -t mail:latest

View File

@@ -1,23 +1,23 @@
The messages service is a simplified service for sending messages, much like email. The mail service is a simplified service for sending mail, much like email.
# Messages Service # Mail Service
## Send a message ## Send a message
### CLI ### CLI
```bash ```bash
> micro messages send --to=John --from=Barry --subject=HelloWorld --text="Hello John" > micro mail send --to=John --from=Barry --subject=HelloWorld --text="Hello John"
``` ```
## List the messages a user has received ## List the mail a user has received
### CLI ### CLI
```bash ```bash
> micro messages list --user=John > micro mail list --user=John
{ {
"messages": [ "mail": [
{ {
"id": "78efd836-ca51-4163-af43-65985f7c6587", "id": "78efd836-ca51-4163-af43-65985f7c6587",
"to": "John", "to": "John",
@@ -35,7 +35,7 @@ The messages service is a simplified service for sending messages, much like ema
### CLI ### CLI
```bash ```bash
> micro messages read --id=78efd836-ca51-4163-af43-65985f7c6587 > micro mail read --id=78efd836-ca51-4163-af43-65985f7c6587
{ {
"message": { "message": {
"id": "78efd836-ca51-4163-af43-65985f7c6587", "id": "78efd836-ca51-4163-af43-65985f7c6587",

View File

@@ -9,7 +9,7 @@ import (
"github.com/google/uuid" "github.com/google/uuid"
"github.com/micro/micro/v3/service/errors" "github.com/micro/micro/v3/service/errors"
"github.com/micro/micro/v3/service/store" "github.com/micro/micro/v3/service/store"
pb "github.com/micro/services/messages/proto" pb "github.com/micro/services/mail/proto"
) )
const ( const (
@@ -17,19 +17,19 @@ const (
joinKey = "/" joinKey = "/"
) )
type Messages struct{} type Mail struct{}
// Send a message // Send a message
func (m *Messages) Send(ctx context.Context, req *pb.SendRequest, rsp *pb.SendResponse) error { func (m *Mail) Send(ctx context.Context, req *pb.SendRequest, rsp *pb.SendResponse) error {
// validate the request // validate the request
if len(req.To) == 0 { if len(req.To) == 0 {
return errors.BadRequest("messages.Send.MissingTo", "Missing to") return errors.BadRequest("mail.Send.MissingTo", "Missing to")
} }
if len(req.From) == 0 { if len(req.From) == 0 {
return errors.BadRequest("messages.Send.MissingFrom", "Missing from") return errors.BadRequest("mail.Send.MissingFrom", "Missing from")
} }
if len(req.Text) == 0 { if len(req.Text) == 0 {
return errors.BadRequest("messages.Send.MissingText", "Missing text") return errors.BadRequest("mail.Send.MissingText", "Missing text")
} }
// construct the message and marshal it to json // construct the message and marshal it to json
@@ -43,57 +43,57 @@ func (m *Messages) Send(ctx context.Context, req *pb.SendRequest, rsp *pb.SendRe
} }
bytes, err := json.Marshal(msg) bytes, err := json.Marshal(msg)
if err != nil { if err != nil {
return errors.BadRequest("messages.Send.Unknown", "Error encoding message") return errors.BadRequest("mail.Send.Unknown", "Error encoding message")
} }
// write the message to the store under the recipients key // write the message to the store under the recipients key
key := strings.Join([]string{messagePrefix, req.To, msg.Id}, joinKey) key := strings.Join([]string{messagePrefix, req.To, msg.Id}, joinKey)
if err := store.Write(&store.Record{Key: key, Value: bytes}); err != nil { if err := store.Write(&store.Record{Key: key, Value: bytes}); err != nil {
return errors.BadRequest("messages.Send.Unknown", "Error writing to the store") return errors.BadRequest("mail.Send.Unknown", "Error writing to the store")
} }
// write the message to the store under the id (so it can be looked up without needing to know // write the message to the store under the id (so it can be looked up without needing to know
// the users id) // the users id)
key = strings.Join([]string{messagePrefix, msg.Id}, joinKey) key = strings.Join([]string{messagePrefix, msg.Id}, joinKey)
if err := store.Write(&store.Record{Key: key, Value: bytes}); err != nil { if err := store.Write(&store.Record{Key: key, Value: bytes}); err != nil {
return errors.BadRequest("messages.Send.Unknown", "Error writing to the store") return errors.BadRequest("mail.Send.Unknown", "Error writing to the store")
} }
return nil return nil
} }
// List messages for a user // List mail for a user
func (m *Messages) List(ctx context.Context, req *pb.ListRequest, rsp *pb.ListResponse) error { func (m *Mail) List(ctx context.Context, req *pb.ListRequest, rsp *pb.ListResponse) error {
// validate the request // validate the request
if len(req.User) == 0 { if len(req.User) == 0 {
return errors.BadRequest("messages.List.MissingUser", "Missing user") return errors.BadRequest("mail.List.MissingUser", "Missing user")
} }
// query the store for any messages sent to the user // query the store for any mail sent to the user
prefix := strings.Join([]string{messagePrefix, req.User}, joinKey) prefix := strings.Join([]string{messagePrefix, req.User}, joinKey)
recs, err := store.Read(prefix, store.ReadPrefix()) recs, err := store.Read(prefix, store.ReadPrefix())
if err != nil { if err != nil {
return errors.BadRequest("messages.List.Unknown", "Error reading from the store") return errors.BadRequest("mail.List.Unknown", "Error reading from the store")
} }
// serialize the result // serialize the result
rsp.Messages = make([]*pb.Message, len(recs)) rsp.Mail = make([]*pb.Message, len(recs))
for i, r := range recs { for i, r := range recs {
var msg pb.Message var msg pb.Message
if err := json.Unmarshal(r.Value, &msg); err != nil { if err := json.Unmarshal(r.Value, &msg); err != nil {
return errors.BadRequest("messages.List.Unknown", "Error decoding message") return errors.BadRequest("mail.List.Unknown", "Error decoding message")
} }
rsp.Messages[i] = &msg rsp.Mail[i] = &msg
} }
return nil return nil
} }
// Read a message // Read a message
func (m *Messages) Read(ctx context.Context, req *pb.ReadRequest, rsp *pb.ReadResponse) error { func (m *Mail) Read(ctx context.Context, req *pb.ReadRequest, rsp *pb.ReadResponse) error {
// validate the request // validate the request
if len(req.Id) == 0 { if len(req.Id) == 0 {
return errors.BadRequest("messages.Read.MissingUser", "Missing user") return errors.BadRequest("mail.Read.MissingUser", "Missing user")
} }
// query the store // query the store
@@ -102,13 +102,13 @@ func (m *Messages) Read(ctx context.Context, req *pb.ReadRequest, rsp *pb.ReadRe
if err == store.ErrNotFound { if err == store.ErrNotFound {
return errors.NotFound("message.Read.InvalidID", "Message not found with ID") return errors.NotFound("message.Read.InvalidID", "Message not found with ID")
} else if err != nil { } else if err != nil {
return errors.BadRequest("messages.Read.Unknown", "Error reading from the store") return errors.BadRequest("mail.Read.Unknown", "Error reading from the store")
} }
// serialize the response // serialize the response
var msg pb.Message var msg pb.Message
if err := json.Unmarshal(recs[0].Value, &msg); err != nil { if err := json.Unmarshal(recs[0].Value, &msg); err != nil {
return errors.BadRequest("messages.Read.Unknown", "Error decoding message") return errors.BadRequest("mail.Read.Unknown", "Error decoding message")
} }
rsp.Message = &msg rsp.Message = &msg

View File

@@ -4,19 +4,19 @@ import (
"github.com/micro/micro/v3/service" "github.com/micro/micro/v3/service"
"github.com/micro/micro/v3/service/logger" "github.com/micro/micro/v3/service/logger"
"github.com/micro/services/messages/handler" "github.com/micro/services/mail/handler"
pb "github.com/micro/services/messages/proto" pb "github.com/micro/services/mail/proto"
) )
func main() { func main() {
// Create the service // Create the service
srv := service.New( srv := service.New(
service.Name("messages"), service.Name("mail"),
service.Version("latest"), service.Version("latest"),
) )
// Register the handler against the server // Register the handler against the server
pb.RegisterMessagesHandler(srv.Server(), new(handler.Messages)) pb.RegisterMailHandler(srv.Server(), new(handler.Mail))
// Run the service // Run the service
if err := srv.Run(); err != nil { if err := srv.Run(); err != nil {

1
mail/micro.mu Normal file
View File

@@ -0,0 +1 @@
service mail

View File

@@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// source: github.com/micro/services/messages/proto/messages.proto // source: proto/mail.proto
package messages package mail
import ( import (
fmt "fmt" fmt "fmt"
@@ -36,7 +36,7 @@ func (m *Message) Reset() { *m = Message{} }
func (m *Message) String() string { return proto.CompactTextString(m) } func (m *Message) String() string { return proto.CompactTextString(m) }
func (*Message) ProtoMessage() {} func (*Message) ProtoMessage() {}
func (*Message) Descriptor() ([]byte, []int) { func (*Message) Descriptor() ([]byte, []int) {
return fileDescriptor_926763a275409928, []int{0} return fileDescriptor_92689585a3f577ba, []int{0}
} }
func (m *Message) XXX_Unmarshal(b []byte) error { func (m *Message) XXX_Unmarshal(b []byte) error {
@@ -113,7 +113,7 @@ func (m *SendRequest) Reset() { *m = SendRequest{} }
func (m *SendRequest) String() string { return proto.CompactTextString(m) } func (m *SendRequest) String() string { return proto.CompactTextString(m) }
func (*SendRequest) ProtoMessage() {} func (*SendRequest) ProtoMessage() {}
func (*SendRequest) Descriptor() ([]byte, []int) { func (*SendRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_926763a275409928, []int{1} return fileDescriptor_92689585a3f577ba, []int{1}
} }
func (m *SendRequest) XXX_Unmarshal(b []byte) error { func (m *SendRequest) XXX_Unmarshal(b []byte) error {
@@ -172,7 +172,7 @@ func (m *SendResponse) Reset() { *m = SendResponse{} }
func (m *SendResponse) String() string { return proto.CompactTextString(m) } func (m *SendResponse) String() string { return proto.CompactTextString(m) }
func (*SendResponse) ProtoMessage() {} func (*SendResponse) ProtoMessage() {}
func (*SendResponse) Descriptor() ([]byte, []int) { func (*SendResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_926763a275409928, []int{2} return fileDescriptor_92689585a3f577ba, []int{2}
} }
func (m *SendResponse) XXX_Unmarshal(b []byte) error { func (m *SendResponse) XXX_Unmarshal(b []byte) error {
@@ -204,7 +204,7 @@ func (m *ListRequest) Reset() { *m = ListRequest{} }
func (m *ListRequest) String() string { return proto.CompactTextString(m) } func (m *ListRequest) String() string { return proto.CompactTextString(m) }
func (*ListRequest) ProtoMessage() {} func (*ListRequest) ProtoMessage() {}
func (*ListRequest) Descriptor() ([]byte, []int) { func (*ListRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_926763a275409928, []int{3} return fileDescriptor_92689585a3f577ba, []int{3}
} }
func (m *ListRequest) XXX_Unmarshal(b []byte) error { func (m *ListRequest) XXX_Unmarshal(b []byte) error {
@@ -233,7 +233,7 @@ func (m *ListRequest) GetUser() string {
} }
type ListResponse struct { type ListResponse struct {
Messages []*Message `protobuf:"bytes,1,rep,name=messages,proto3" json:"messages,omitempty"` Mail []*Message `protobuf:"bytes,1,rep,name=mail,proto3" json:"mail,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@@ -243,7 +243,7 @@ func (m *ListResponse) Reset() { *m = ListResponse{} }
func (m *ListResponse) String() string { return proto.CompactTextString(m) } func (m *ListResponse) String() string { return proto.CompactTextString(m) }
func (*ListResponse) ProtoMessage() {} func (*ListResponse) ProtoMessage() {}
func (*ListResponse) Descriptor() ([]byte, []int) { func (*ListResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_926763a275409928, []int{4} return fileDescriptor_92689585a3f577ba, []int{4}
} }
func (m *ListResponse) XXX_Unmarshal(b []byte) error { func (m *ListResponse) XXX_Unmarshal(b []byte) error {
@@ -264,9 +264,9 @@ func (m *ListResponse) XXX_DiscardUnknown() {
var xxx_messageInfo_ListResponse proto.InternalMessageInfo var xxx_messageInfo_ListResponse proto.InternalMessageInfo
func (m *ListResponse) GetMessages() []*Message { func (m *ListResponse) GetMail() []*Message {
if m != nil { if m != nil {
return m.Messages return m.Mail
} }
return nil return nil
} }
@@ -282,7 +282,7 @@ func (m *ReadRequest) Reset() { *m = ReadRequest{} }
func (m *ReadRequest) String() string { return proto.CompactTextString(m) } func (m *ReadRequest) String() string { return proto.CompactTextString(m) }
func (*ReadRequest) ProtoMessage() {} func (*ReadRequest) ProtoMessage() {}
func (*ReadRequest) Descriptor() ([]byte, []int) { func (*ReadRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_926763a275409928, []int{5} return fileDescriptor_92689585a3f577ba, []int{5}
} }
func (m *ReadRequest) XXX_Unmarshal(b []byte) error { func (m *ReadRequest) XXX_Unmarshal(b []byte) error {
@@ -321,7 +321,7 @@ func (m *ReadResponse) Reset() { *m = ReadResponse{} }
func (m *ReadResponse) String() string { return proto.CompactTextString(m) } func (m *ReadResponse) String() string { return proto.CompactTextString(m) }
func (*ReadResponse) ProtoMessage() {} func (*ReadResponse) ProtoMessage() {}
func (*ReadResponse) Descriptor() ([]byte, []int) { func (*ReadResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_926763a275409928, []int{6} return fileDescriptor_92689585a3f577ba, []int{6}
} }
func (m *ReadResponse) XXX_Unmarshal(b []byte) error { func (m *ReadResponse) XXX_Unmarshal(b []byte) error {
@@ -350,41 +350,37 @@ func (m *ReadResponse) GetMessage() *Message {
} }
func init() { func init() {
proto.RegisterType((*Message)(nil), "messages.Message") proto.RegisterType((*Message)(nil), "mail.Message")
proto.RegisterType((*SendRequest)(nil), "messages.SendRequest") proto.RegisterType((*SendRequest)(nil), "mail.SendRequest")
proto.RegisterType((*SendResponse)(nil), "messages.SendResponse") proto.RegisterType((*SendResponse)(nil), "mail.SendResponse")
proto.RegisterType((*ListRequest)(nil), "messages.ListRequest") proto.RegisterType((*ListRequest)(nil), "mail.ListRequest")
proto.RegisterType((*ListResponse)(nil), "messages.ListResponse") proto.RegisterType((*ListResponse)(nil), "mail.ListResponse")
proto.RegisterType((*ReadRequest)(nil), "messages.ReadRequest") proto.RegisterType((*ReadRequest)(nil), "mail.ReadRequest")
proto.RegisterType((*ReadResponse)(nil), "messages.ReadResponse") proto.RegisterType((*ReadResponse)(nil), "mail.ReadResponse")
} }
func init() { func init() { proto.RegisterFile("proto/mail.proto", fileDescriptor_92689585a3f577ba) }
proto.RegisterFile("github.com/micro/services/messages/proto/messages.proto", fileDescriptor_926763a275409928)
}
var fileDescriptor_926763a275409928 = []byte{ var fileDescriptor_92689585a3f577ba = []byte{
// 347 bytes of a gzipped FileDescriptorProto // 317 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xcf, 0x4a, 0xf3, 0x40, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x52, 0xb1, 0x4e, 0xc3, 0x30,
0x14, 0xc5, 0x99, 0x64, 0xbe, 0xa6, 0xdf, 0x4d, 0x29, 0x38, 0xa0, 0x0e, 0x82, 0x50, 0xb3, 0x2a, 0x14, 0x94, 0x13, 0xd3, 0x88, 0x97, 0x50, 0x81, 0x17, 0x2c, 0x24, 0xa4, 0xd6, 0x0b, 0x59, 0x52,
0x88, 0x0d, 0xb6, 0x14, 0x17, 0xc5, 0x85, 0xae, 0x75, 0x13, 0x77, 0x6e, 0x4a, 0x9b, 0x8e, 0x35, 0x44, 0x19, 0x18, 0x98, 0x60, 0xa6, 0x4b, 0xd8, 0x58, 0xaa, 0x94, 0x18, 0x14, 0xd4, 0xc4, 0x25,
0x42, 0x3a, 0x35, 0x77, 0x22, 0x3e, 0x80, 0xef, 0xe3, 0x2b, 0xca, 0xfc, 0x49, 0x3b, 0x6a, 0x16, 0x7e, 0x91, 0xf8, 0x00, 0xfe, 0x80, 0x1f, 0x46, 0xb6, 0x63, 0x61, 0xd4, 0x6e, 0x77, 0xef, 0x9d,
0xee, 0xee, 0xef, 0xf6, 0x9e, 0x39, 0x3d, 0x87, 0xc0, 0xd5, 0xba, 0x50, 0xcf, 0xf5, 0x72, 0x94, 0x7d, 0xbe, 0x93, 0xe1, 0x74, 0xd7, 0x2b, 0x54, 0xd7, 0x6d, 0xd5, 0x6c, 0x17, 0x16, 0x32, 0x6a,
0xcb, 0x32, 0x2d, 0x8b, 0xbc, 0x92, 0x29, 0x8a, 0xea, 0xad, 0xc8, 0x05, 0xa6, 0xa5, 0x40, 0x5c, 0xb0, 0xf8, 0x26, 0x90, 0xac, 0xa4, 0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d0, 0x75, 0x4b, 0x64, 0x53, 0xa0, 0x3a, 0x1a, 0x3b, 0x89, 0xe0, 0xe5, 0x41, 0x62, 0x2f, 0xff, 0x97, 0xb0, 0x00, 0x6a, 0xde, 0xe7, 0xe5, 0x41, 0x14,
0xdc, 0x0b, 0xbc, 0x2e, 0x4f, 0x8e, 0x7e, 0xae, 0x9d, 0xe1, 0x14, 0xa8, 0x8e, 0xe7, 0xcb, 0xbc, 0x2f, 0x0f, 0x9f, 0xff, 0x98, 0xbd, 0x80, 0xfd, 0x4a, 0xf7, 0x66, 0xb5, 0x99, 0x58, 0x7c, 0xfb,
0x46, 0x7c, 0xd9, 0xb7, 0x16, 0xa6, 0x40, 0xf5, 0xff, 0xf6, 0x65, 0x5e, 0x4c, 0x5f, 0xe6, 0xc7, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x7b, 0xb1, 0x5f, 0x20, 0x6a, 0x02, 0x00, 0x00,
0xbb, 0x9d, 0x3c, 0x5e, 0xfe, 0xf5, 0x63, 0x9d, 0x35, 0xb8, 0xec, 0x18, 0x9e, 0x7c, 0x05, 0x00,
0x00, 0xff, 0xff, 0x90, 0x20, 0xa1, 0xca, 0xe8, 0x02, 0x00, 0x00,
} }

View File

@@ -1,7 +1,7 @@
// Code generated by protoc-gen-micro. DO NOT EDIT. // Code generated by protoc-gen-micro. DO NOT EDIT.
// source: github.com/micro/services/messages/proto/messages.proto // source: proto/mail.proto
package messages package mail
import ( import (
fmt "fmt" fmt "fmt"
@@ -33,34 +33,34 @@ var _ context.Context
var _ client.Option var _ client.Option
var _ server.Option var _ server.Option
// Api Endpoints for Messages service // Api Endpoints for Mail service
func NewMessagesEndpoints() []*api.Endpoint { func NewMailEndpoints() []*api.Endpoint {
return []*api.Endpoint{} return []*api.Endpoint{}
} }
// Client API for Messages service // Client API for Mail service
type MessagesService interface { type MailService interface {
Send(ctx context.Context, in *SendRequest, opts ...client.CallOption) (*SendResponse, error) Send(ctx context.Context, in *SendRequest, opts ...client.CallOption) (*SendResponse, error)
List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error) List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error)
Read(ctx context.Context, in *ReadRequest, opts ...client.CallOption) (*ReadResponse, error) Read(ctx context.Context, in *ReadRequest, opts ...client.CallOption) (*ReadResponse, error)
} }
type messagesService struct { type mailService struct {
c client.Client c client.Client
name string name string
} }
func NewMessagesService(name string, c client.Client) MessagesService { func NewMailService(name string, c client.Client) MailService {
return &messagesService{ return &mailService{
c: c, c: c,
name: name, name: name,
} }
} }
func (c *messagesService) Send(ctx context.Context, in *SendRequest, opts ...client.CallOption) (*SendResponse, error) { func (c *mailService) Send(ctx context.Context, in *SendRequest, opts ...client.CallOption) (*SendResponse, error) {
req := c.c.NewRequest(c.name, "Messages.Send", in) req := c.c.NewRequest(c.name, "Mail.Send", in)
out := new(SendResponse) out := new(SendResponse)
err := c.c.Call(ctx, req, out, opts...) err := c.c.Call(ctx, req, out, opts...)
if err != nil { if err != nil {
@@ -69,8 +69,8 @@ func (c *messagesService) Send(ctx context.Context, in *SendRequest, opts ...cli
return out, nil return out, nil
} }
func (c *messagesService) List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error) { func (c *mailService) List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error) {
req := c.c.NewRequest(c.name, "Messages.List", in) req := c.c.NewRequest(c.name, "Mail.List", in)
out := new(ListResponse) out := new(ListResponse)
err := c.c.Call(ctx, req, out, opts...) err := c.c.Call(ctx, req, out, opts...)
if err != nil { if err != nil {
@@ -79,8 +79,8 @@ func (c *messagesService) List(ctx context.Context, in *ListRequest, opts ...cli
return out, nil return out, nil
} }
func (c *messagesService) Read(ctx context.Context, in *ReadRequest, opts ...client.CallOption) (*ReadResponse, error) { func (c *mailService) Read(ctx context.Context, in *ReadRequest, opts ...client.CallOption) (*ReadResponse, error) {
req := c.c.NewRequest(c.name, "Messages.Read", in) req := c.c.NewRequest(c.name, "Mail.Read", in)
out := new(ReadResponse) out := new(ReadResponse)
err := c.c.Call(ctx, req, out, opts...) err := c.c.Call(ctx, req, out, opts...)
if err != nil { if err != nil {
@@ -89,39 +89,39 @@ func (c *messagesService) Read(ctx context.Context, in *ReadRequest, opts ...cli
return out, nil return out, nil
} }
// Server API for Messages service // Server API for Mail service
type MessagesHandler interface { type MailHandler interface {
Send(context.Context, *SendRequest, *SendResponse) error Send(context.Context, *SendRequest, *SendResponse) error
List(context.Context, *ListRequest, *ListResponse) error List(context.Context, *ListRequest, *ListResponse) error
Read(context.Context, *ReadRequest, *ReadResponse) error Read(context.Context, *ReadRequest, *ReadResponse) error
} }
func RegisterMessagesHandler(s server.Server, hdlr MessagesHandler, opts ...server.HandlerOption) error { func RegisterMailHandler(s server.Server, hdlr MailHandler, opts ...server.HandlerOption) error {
type messages interface { type mail interface {
Send(ctx context.Context, in *SendRequest, out *SendResponse) error Send(ctx context.Context, in *SendRequest, out *SendResponse) error
List(ctx context.Context, in *ListRequest, out *ListResponse) error List(ctx context.Context, in *ListRequest, out *ListResponse) error
Read(ctx context.Context, in *ReadRequest, out *ReadResponse) error Read(ctx context.Context, in *ReadRequest, out *ReadResponse) error
} }
type Messages struct { type Mail struct {
messages mail
} }
h := &messagesHandler{hdlr} h := &mailHandler{hdlr}
return s.Handle(s.NewHandler(&Messages{h}, opts...)) return s.Handle(s.NewHandler(&Mail{h}, opts...))
} }
type messagesHandler struct { type mailHandler struct {
MessagesHandler MailHandler
} }
func (h *messagesHandler) Send(ctx context.Context, in *SendRequest, out *SendResponse) error { func (h *mailHandler) Send(ctx context.Context, in *SendRequest, out *SendResponse) error {
return h.MessagesHandler.Send(ctx, in, out) return h.MailHandler.Send(ctx, in, out)
} }
func (h *messagesHandler) List(ctx context.Context, in *ListRequest, out *ListResponse) error { func (h *mailHandler) List(ctx context.Context, in *ListRequest, out *ListResponse) error {
return h.MessagesHandler.List(ctx, in, out) return h.MailHandler.List(ctx, in, out)
} }
func (h *messagesHandler) Read(ctx context.Context, in *ReadRequest, out *ReadResponse) error { func (h *mailHandler) Read(ctx context.Context, in *ReadRequest, out *ReadResponse) error {
return h.MessagesHandler.Read(ctx, in, out) return h.MailHandler.Read(ctx, in, out)
} }

View File

@@ -1,9 +1,9 @@
syntax = "proto3"; syntax = "proto3";
package messages; package mail;
option go_package = "proto;messages"; option go_package = "proto;mail";
service Messages { service Mail {
rpc Send(SendRequest) returns (SendResponse); rpc Send(SendRequest) returns (SendResponse);
rpc List(ListRequest) returns (ListResponse); rpc List(ListRequest) returns (ListResponse);
rpc Read(ReadRequest) returns (ReadResponse); rpc Read(ReadRequest) returns (ReadResponse);
@@ -32,7 +32,7 @@ message ListRequest {
} }
message ListResponse { message ListResponse {
repeated Message messages = 1; repeated Message mail = 1;
} }
message ReadRequest { message ReadRequest {

View File

@@ -1 +0,0 @@
service messages