mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-12 11:15:12 +00:00
149 lines
4.5 KiB
Go
149 lines
4.5 KiB
Go
// Code generated by protoc-gen-micro. DO NOT EDIT.
|
|
// source: proto/posts.proto
|
|
|
|
package posts
|
|
|
|
import (
|
|
fmt "fmt"
|
|
proto "github.com/golang/protobuf/proto"
|
|
math "math"
|
|
)
|
|
|
|
import (
|
|
context "context"
|
|
api "github.com/micro/micro/v3/service/api"
|
|
client "github.com/micro/micro/v3/service/client"
|
|
server "github.com/micro/micro/v3/service/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 {
|
|
// Index returns the posts index without content
|
|
Index(ctx context.Context, in *IndexRequest, opts ...client.CallOption) (*IndexResponse, error)
|
|
// 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) Index(ctx context.Context, in *IndexRequest, opts ...client.CallOption) (*IndexResponse, error) {
|
|
req := c.c.NewRequest(c.name, "Posts.Index", in)
|
|
out := new(IndexResponse)
|
|
err := c.c.Call(ctx, req, out, opts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
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 {
|
|
// Index returns the posts index without content
|
|
Index(context.Context, *IndexRequest, *IndexResponse) error
|
|
// 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 {
|
|
Index(ctx context.Context, in *IndexRequest, out *IndexResponse) error
|
|
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) Index(ctx context.Context, in *IndexRequest, out *IndexResponse) error {
|
|
return h.PostsHandler.Index(ctx, in, out)
|
|
}
|
|
|
|
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)
|
|
}
|