mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-20 06:25:07 +00:00
One
This commit is contained in:
380
blog/posts/proto/posts/post.pb.go
Normal file
380
blog/posts/proto/posts/post.pb.go
Normal file
@@ -0,0 +1,380 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: blog/posts/proto/posts/post.proto
|
||||
|
||||
package posts
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
math "math"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
type Post struct {
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
Title string `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"`
|
||||
Slug string `protobuf:"bytes,3,opt,name=slug,proto3" json:"slug,omitempty"`
|
||||
Content string `protobuf:"bytes,4,opt,name=content,proto3" json:"content,omitempty"`
|
||||
Timestamp int64 `protobuf:"varint,5,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
|
||||
TagNames []string `protobuf:"bytes,6,rep,name=tagNames,proto3" json:"tagNames,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *Post) Reset() { *m = Post{} }
|
||||
func (m *Post) String() string { return proto.CompactTextString(m) }
|
||||
func (*Post) ProtoMessage() {}
|
||||
func (*Post) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_2d32cca1c2f74735, []int{0}
|
||||
}
|
||||
|
||||
func (m *Post) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_Post.Unmarshal(m, b)
|
||||
}
|
||||
func (m *Post) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_Post.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *Post) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Post.Merge(m, src)
|
||||
}
|
||||
func (m *Post) XXX_Size() int {
|
||||
return xxx_messageInfo_Post.Size(m)
|
||||
}
|
||||
func (m *Post) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Post.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Post proto.InternalMessageInfo
|
||||
|
||||
func (m *Post) GetId() string {
|
||||
if m != nil {
|
||||
return m.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Post) GetTitle() string {
|
||||
if m != nil {
|
||||
return m.Title
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Post) GetSlug() string {
|
||||
if m != nil {
|
||||
return m.Slug
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Post) GetContent() string {
|
||||
if m != nil {
|
||||
return m.Content
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Post) GetTimestamp() int64 {
|
||||
if m != nil {
|
||||
return m.Timestamp
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *Post) GetTagNames() []string {
|
||||
if m != nil {
|
||||
return m.TagNames
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type QueryRequest struct {
|
||||
Slug string `protobuf:"bytes,1,opt,name=slug,proto3" json:"slug,omitempty"`
|
||||
Offset int64 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"`
|
||||
Limit int64 `protobuf:"varint,3,opt,name=limit,proto3" json:"limit,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *QueryRequest) Reset() { *m = QueryRequest{} }
|
||||
func (m *QueryRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*QueryRequest) ProtoMessage() {}
|
||||
func (*QueryRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_2d32cca1c2f74735, []int{1}
|
||||
}
|
||||
|
||||
func (m *QueryRequest) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_QueryRequest.Unmarshal(m, b)
|
||||
}
|
||||
func (m *QueryRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_QueryRequest.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *QueryRequest) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_QueryRequest.Merge(m, src)
|
||||
}
|
||||
func (m *QueryRequest) XXX_Size() int {
|
||||
return xxx_messageInfo_QueryRequest.Size(m)
|
||||
}
|
||||
func (m *QueryRequest) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_QueryRequest.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_QueryRequest proto.InternalMessageInfo
|
||||
|
||||
func (m *QueryRequest) GetSlug() string {
|
||||
if m != nil {
|
||||
return m.Slug
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *QueryRequest) GetOffset() int64 {
|
||||
if m != nil {
|
||||
return m.Offset
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *QueryRequest) GetLimit() int64 {
|
||||
if m != nil {
|
||||
return m.Limit
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type QueryResponse struct {
|
||||
Posts []*Post `protobuf:"bytes,1,rep,name=posts,proto3" json:"posts,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *QueryResponse) Reset() { *m = QueryResponse{} }
|
||||
func (m *QueryResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*QueryResponse) ProtoMessage() {}
|
||||
func (*QueryResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_2d32cca1c2f74735, []int{2}
|
||||
}
|
||||
|
||||
func (m *QueryResponse) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_QueryResponse.Unmarshal(m, b)
|
||||
}
|
||||
func (m *QueryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_QueryResponse.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *QueryResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_QueryResponse.Merge(m, src)
|
||||
}
|
||||
func (m *QueryResponse) XXX_Size() int {
|
||||
return xxx_messageInfo_QueryResponse.Size(m)
|
||||
}
|
||||
func (m *QueryResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_QueryResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_QueryResponse proto.InternalMessageInfo
|
||||
|
||||
func (m *QueryResponse) GetPosts() []*Post {
|
||||
if m != nil {
|
||||
return m.Posts
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type SaveRequest struct {
|
||||
Post *Post `protobuf:"bytes,1,opt,name=post,proto3" json:"post,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *SaveRequest) Reset() { *m = SaveRequest{} }
|
||||
func (m *SaveRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*SaveRequest) ProtoMessage() {}
|
||||
func (*SaveRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_2d32cca1c2f74735, []int{3}
|
||||
}
|
||||
|
||||
func (m *SaveRequest) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_SaveRequest.Unmarshal(m, b)
|
||||
}
|
||||
func (m *SaveRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_SaveRequest.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *SaveRequest) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_SaveRequest.Merge(m, src)
|
||||
}
|
||||
func (m *SaveRequest) XXX_Size() int {
|
||||
return xxx_messageInfo_SaveRequest.Size(m)
|
||||
}
|
||||
func (m *SaveRequest) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_SaveRequest.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_SaveRequest proto.InternalMessageInfo
|
||||
|
||||
func (m *SaveRequest) GetPost() *Post {
|
||||
if m != nil {
|
||||
return m.Post
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type SaveResponse struct {
|
||||
Post *Post `protobuf:"bytes,1,opt,name=post,proto3" json:"post,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *SaveResponse) Reset() { *m = SaveResponse{} }
|
||||
func (m *SaveResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*SaveResponse) ProtoMessage() {}
|
||||
func (*SaveResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_2d32cca1c2f74735, []int{4}
|
||||
}
|
||||
|
||||
func (m *SaveResponse) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_SaveResponse.Unmarshal(m, b)
|
||||
}
|
||||
func (m *SaveResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_SaveResponse.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *SaveResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_SaveResponse.Merge(m, src)
|
||||
}
|
||||
func (m *SaveResponse) XXX_Size() int {
|
||||
return xxx_messageInfo_SaveResponse.Size(m)
|
||||
}
|
||||
func (m *SaveResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_SaveResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_SaveResponse proto.InternalMessageInfo
|
||||
|
||||
func (m *SaveResponse) GetPost() *Post {
|
||||
if m != nil {
|
||||
return m.Post
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type DeleteRequest struct {
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *DeleteRequest) Reset() { *m = DeleteRequest{} }
|
||||
func (m *DeleteRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*DeleteRequest) ProtoMessage() {}
|
||||
func (*DeleteRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_2d32cca1c2f74735, []int{5}
|
||||
}
|
||||
|
||||
func (m *DeleteRequest) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_DeleteRequest.Unmarshal(m, b)
|
||||
}
|
||||
func (m *DeleteRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_DeleteRequest.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *DeleteRequest) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_DeleteRequest.Merge(m, src)
|
||||
}
|
||||
func (m *DeleteRequest) XXX_Size() int {
|
||||
return xxx_messageInfo_DeleteRequest.Size(m)
|
||||
}
|
||||
func (m *DeleteRequest) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_DeleteRequest.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_DeleteRequest proto.InternalMessageInfo
|
||||
|
||||
func (m *DeleteRequest) GetId() string {
|
||||
if m != nil {
|
||||
return m.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type DeleteResponse struct {
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *DeleteResponse) Reset() { *m = DeleteResponse{} }
|
||||
func (m *DeleteResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*DeleteResponse) ProtoMessage() {}
|
||||
func (*DeleteResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_2d32cca1c2f74735, []int{6}
|
||||
}
|
||||
|
||||
func (m *DeleteResponse) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_DeleteResponse.Unmarshal(m, b)
|
||||
}
|
||||
func (m *DeleteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_DeleteResponse.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *DeleteResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_DeleteResponse.Merge(m, src)
|
||||
}
|
||||
func (m *DeleteResponse) XXX_Size() int {
|
||||
return xxx_messageInfo_DeleteResponse.Size(m)
|
||||
}
|
||||
func (m *DeleteResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_DeleteResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_DeleteResponse proto.InternalMessageInfo
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*Post)(nil), "posts.Post")
|
||||
proto.RegisterType((*QueryRequest)(nil), "posts.QueryRequest")
|
||||
proto.RegisterType((*QueryResponse)(nil), "posts.QueryResponse")
|
||||
proto.RegisterType((*SaveRequest)(nil), "posts.SaveRequest")
|
||||
proto.RegisterType((*SaveResponse)(nil), "posts.SaveResponse")
|
||||
proto.RegisterType((*DeleteRequest)(nil), "posts.DeleteRequest")
|
||||
proto.RegisterType((*DeleteResponse)(nil), "posts.DeleteResponse")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("blog/posts/proto/posts/post.proto", fileDescriptor_2d32cca1c2f74735) }
|
||||
|
||||
var fileDescriptor_2d32cca1c2f74735 = []byte{
|
||||
// 343 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0x4d, 0x4e, 0xc3, 0x30,
|
||||
0x10, 0x85, 0x71, 0xf3, 0x03, 0x9d, 0xfe, 0x08, 0x4d, 0x0b, 0xb2, 0x22, 0xa4, 0xa6, 0x59, 0x65,
|
||||
0x95, 0x8a, 0x82, 0xc4, 0x05, 0x58, 0xa3, 0x62, 0x4e, 0x90, 0x52, 0xb7, 0x8a, 0x94, 0xd4, 0xa1,
|
||||
0x9e, 0x22, 0x71, 0x0f, 0x2e, 0xc1, 0x2d, 0x51, 0xec, 0x24, 0xb4, 0xd9, 0xb0, 0xf3, 0xfb, 0xec,
|
||||
0x79, 0xf3, 0x66, 0x12, 0x98, 0xaf, 0x73, 0xb5, 0x5b, 0x94, 0x4a, 0x93, 0x5e, 0x94, 0x07, 0x45,
|
||||
0xaa, 0x39, 0x2b, 0x4d, 0x89, 0x01, 0xe8, 0x19, 0x12, 0x7d, 0x33, 0x70, 0x57, 0x4a, 0x13, 0x8e,
|
||||
0xa1, 0x97, 0x6d, 0x38, 0x0b, 0x59, 0xdc, 0x17, 0xbd, 0x6c, 0x83, 0x53, 0xf0, 0x28, 0xa3, 0x5c,
|
||||
0xf2, 0x9e, 0x41, 0x56, 0x20, 0x82, 0xab, 0xf3, 0xe3, 0x8e, 0x3b, 0x06, 0x9a, 0x33, 0x72, 0xb8,
|
||||
0x7c, 0x57, 0x7b, 0x92, 0x7b, 0xe2, 0xae, 0xc1, 0x8d, 0xc4, 0x3b, 0xe8, 0x53, 0x56, 0x48, 0x4d,
|
||||
0x69, 0x51, 0x72, 0x2f, 0x64, 0xb1, 0x23, 0xfe, 0x00, 0x06, 0x70, 0x45, 0xe9, 0xee, 0x25, 0x2d,
|
||||
0xa4, 0xe6, 0x7e, 0xe8, 0xc4, 0x7d, 0xd1, 0xea, 0x68, 0x05, 0xc3, 0xd7, 0xa3, 0x3c, 0x7c, 0x09,
|
||||
0xf9, 0x71, 0x94, 0x9a, 0xda, 0xbe, 0xec, 0xa4, 0xef, 0x2d, 0xf8, 0x6a, 0xbb, 0xd5, 0x92, 0x4c,
|
||||
0x44, 0x47, 0xd4, 0xaa, 0x4a, 0x9e, 0x67, 0x45, 0x46, 0x26, 0xa4, 0x23, 0xac, 0x88, 0x96, 0x30,
|
||||
0xaa, 0x1d, 0x75, 0xa9, 0xf6, 0x5a, 0xe2, 0x1c, 0xec, 0x0a, 0x38, 0x0b, 0x9d, 0x78, 0xb0, 0x1c,
|
||||
0x24, 0x46, 0x25, 0xd5, 0x32, 0x44, 0xbd, 0x9c, 0x04, 0x06, 0x6f, 0xe9, 0xa7, 0x6c, 0x42, 0xcc,
|
||||
0xc0, 0xad, 0xb8, 0x09, 0xd1, 0x29, 0x30, 0x17, 0xd1, 0x02, 0x86, 0xf6, 0x7d, 0xdd, 0xe2, 0xdf,
|
||||
0x82, 0x19, 0x8c, 0x9e, 0x65, 0x2e, 0xa9, 0x6d, 0xd1, 0xf9, 0x0a, 0xd1, 0x35, 0x8c, 0x9b, 0x07,
|
||||
0xd6, 0x73, 0xf9, 0xc3, 0xc0, 0xab, 0x1c, 0x34, 0x3e, 0x82, 0x67, 0x26, 0xc2, 0x49, 0x6d, 0x7c,
|
||||
0xba, 0xb1, 0x60, 0x7a, 0x0e, 0x6d, 0x75, 0x74, 0x81, 0xf7, 0xe0, 0x56, 0x19, 0x11, 0xeb, 0xfb,
|
||||
0x93, 0x01, 0x83, 0xc9, 0x19, 0x6b, 0x4b, 0x9e, 0xc0, 0xb7, 0x21, 0xb0, 0x31, 0x3d, 0x0b, 0x1d,
|
||||
0xdc, 0x74, 0x68, 0x53, 0xb8, 0xf6, 0xcd, 0xaf, 0xf6, 0xf0, 0x1b, 0x00, 0x00, 0xff, 0xff, 0xd5,
|
||||
0xd2, 0x06, 0xac, 0x8f, 0x02, 0x00, 0x00,
|
||||
}
|
||||
129
blog/posts/proto/posts/post.pb.micro.go
Normal file
129
blog/posts/proto/posts/post.pb.micro.go
Normal file
@@ -0,0 +1,129 @@
|
||||
// Code generated by protoc-gen-micro. DO NOT EDIT.
|
||||
// source: blog/posts/proto/posts/post.proto
|
||||
|
||||
package posts
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
math "math"
|
||||
)
|
||||
|
||||
import (
|
||||
context "context"
|
||||
api "github.com/micro/go-micro/v3/api"
|
||||
client "github.com/micro/go-micro/v3/client"
|
||||
server "github.com/micro/go-micro/v3/server"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ api.Endpoint
|
||||
var _ context.Context
|
||||
var _ client.Option
|
||||
var _ server.Option
|
||||
|
||||
// Api Endpoints for Posts service
|
||||
|
||||
func NewPostsEndpoints() []*api.Endpoint {
|
||||
return []*api.Endpoint{}
|
||||
}
|
||||
|
||||
// Client API for Posts service
|
||||
|
||||
type PostsService interface {
|
||||
// Query currently only supports read by slug or timestamp, no listing.
|
||||
Query(ctx context.Context, in *QueryRequest, opts ...client.CallOption) (*QueryResponse, error)
|
||||
Save(ctx context.Context, in *SaveRequest, opts ...client.CallOption) (*SaveResponse, error)
|
||||
Delete(ctx context.Context, in *DeleteRequest, opts ...client.CallOption) (*DeleteResponse, error)
|
||||
}
|
||||
|
||||
type postsService struct {
|
||||
c client.Client
|
||||
name string
|
||||
}
|
||||
|
||||
func NewPostsService(name string, c client.Client) PostsService {
|
||||
return &postsService{
|
||||
c: c,
|
||||
name: name,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *postsService) Query(ctx context.Context, in *QueryRequest, opts ...client.CallOption) (*QueryResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "Posts.Query", in)
|
||||
out := new(QueryResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *postsService) Save(ctx context.Context, in *SaveRequest, opts ...client.CallOption) (*SaveResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "Posts.Save", in)
|
||||
out := new(SaveResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *postsService) Delete(ctx context.Context, in *DeleteRequest, opts ...client.CallOption) (*DeleteResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "Posts.Delete", in)
|
||||
out := new(DeleteResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Server API for Posts service
|
||||
|
||||
type PostsHandler interface {
|
||||
// Query currently only supports read by slug or timestamp, no listing.
|
||||
Query(context.Context, *QueryRequest, *QueryResponse) error
|
||||
Save(context.Context, *SaveRequest, *SaveResponse) error
|
||||
Delete(context.Context, *DeleteRequest, *DeleteResponse) error
|
||||
}
|
||||
|
||||
func RegisterPostsHandler(s server.Server, hdlr PostsHandler, opts ...server.HandlerOption) error {
|
||||
type posts interface {
|
||||
Query(ctx context.Context, in *QueryRequest, out *QueryResponse) error
|
||||
Save(ctx context.Context, in *SaveRequest, out *SaveResponse) error
|
||||
Delete(ctx context.Context, in *DeleteRequest, out *DeleteResponse) error
|
||||
}
|
||||
type Posts struct {
|
||||
posts
|
||||
}
|
||||
h := &postsHandler{hdlr}
|
||||
return s.Handle(s.NewHandler(&Posts{h}, opts...))
|
||||
}
|
||||
|
||||
type postsHandler struct {
|
||||
PostsHandler
|
||||
}
|
||||
|
||||
func (h *postsHandler) Query(ctx context.Context, in *QueryRequest, out *QueryResponse) error {
|
||||
return h.PostsHandler.Query(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *postsHandler) Save(ctx context.Context, in *SaveRequest, out *SaveResponse) error {
|
||||
return h.PostsHandler.Save(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *postsHandler) Delete(ctx context.Context, in *DeleteRequest, out *DeleteResponse) error {
|
||||
return h.PostsHandler.Delete(ctx, in, out)
|
||||
}
|
||||
45
blog/posts/proto/posts/post.proto
Normal file
45
blog/posts/proto/posts/post.proto
Normal file
@@ -0,0 +1,45 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package posts;
|
||||
|
||||
service Posts {
|
||||
// Query currently only supports read by slug or timestamp, no listing.
|
||||
rpc Query(QueryRequest) returns (QueryResponse) {}
|
||||
rpc Save(SaveRequest) returns (SaveResponse) {}
|
||||
rpc Delete(DeleteRequest) returns (DeleteResponse) {}
|
||||
}
|
||||
|
||||
message Post {
|
||||
string id = 1;
|
||||
string title = 2;
|
||||
string slug = 3;
|
||||
string content = 4;
|
||||
int64 timestamp = 5;
|
||||
repeated string tagNames = 6;
|
||||
}
|
||||
|
||||
message QueryRequest {
|
||||
string slug = 1;
|
||||
int64 offset = 2;
|
||||
int64 limit = 3;
|
||||
}
|
||||
|
||||
message QueryResponse {
|
||||
repeated Post posts = 1;
|
||||
}
|
||||
|
||||
message SaveRequest {
|
||||
Post post = 1;
|
||||
}
|
||||
|
||||
message SaveResponse {
|
||||
Post post = 1;
|
||||
}
|
||||
|
||||
message DeleteRequest {
|
||||
string id = 1;
|
||||
}
|
||||
|
||||
message DeleteResponse {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user