feat: import services and standardize Go 1.26.5

This commit is contained in:
2026-08-09 10:43:45 +08:00
parent 689c74b28f
commit 86024fa81d
1456 changed files with 220765 additions and 2 deletions

View File

@@ -0,0 +1,706 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.8
// protoc (unknown)
// source: blocks.proto
package feed
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type FetchRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
PageNo int64 `protobuf:"varint,1,opt,name=page_no,json=pageNo,proto3" json:"page_no,omitempty"` // 页数
PageSize int64 `protobuf:"varint,2,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"` // 每页记录数
Params map[string]string `protobuf:"bytes,3,rep,name=params,proto3" json:"params,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` // 条件参数,key=val,eg key:category_id=?,vlaue=11
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *FetchRequest) Reset() {
*x = FetchRequest{}
mi := &file_blocks_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *FetchRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*FetchRequest) ProtoMessage() {}
func (x *FetchRequest) ProtoReflect() protoreflect.Message {
mi := &file_blocks_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use FetchRequest.ProtoReflect.Descriptor instead.
func (*FetchRequest) Descriptor() ([]byte, []int) {
return file_blocks_proto_rawDescGZIP(), []int{0}
}
func (x *FetchRequest) GetPageNo() int64 {
if x != nil {
return x.PageNo
}
return 0
}
func (x *FetchRequest) GetPageSize() int64 {
if x != nil {
return x.PageSize
}
return 0
}
func (x *FetchRequest) GetParams() map[string]string {
if x != nil {
return x.Params
}
return nil
}
type IdentRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // 唯一ID
Identity string `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"` // 唯一码
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *IdentRequest) Reset() {
*x = IdentRequest{}
mi := &file_blocks_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *IdentRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*IdentRequest) ProtoMessage() {}
func (x *IdentRequest) ProtoReflect() protoreflect.Message {
mi := &file_blocks_proto_msgTypes[1]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use IdentRequest.ProtoReflect.Descriptor instead.
func (*IdentRequest) Descriptor() ([]byte, []int) {
return file_blocks_proto_rawDescGZIP(), []int{1}
}
func (x *IdentRequest) GetId() int64 {
if x != nil {
return x.Id
}
return 0
}
func (x *IdentRequest) GetIdentity() string {
if x != nil {
return x.Identity
}
return ""
}
type VersionRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Version int64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` // 时序版本号
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *VersionRequest) Reset() {
*x = VersionRequest{}
mi := &file_blocks_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *VersionRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*VersionRequest) ProtoMessage() {}
func (x *VersionRequest) ProtoReflect() protoreflect.Message {
mi := &file_blocks_proto_msgTypes[2]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use VersionRequest.ProtoReflect.Descriptor instead.
func (*VersionRequest) Descriptor() ([]byte, []int) {
return file_blocks_proto_rawDescGZIP(), []int{2}
}
func (x *VersionRequest) GetVersion() int64 {
if x != nil {
return x.Version
}
return 0
}
type SearchRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Keyword string `protobuf:"bytes,1,opt,name=keyword,proto3" json:"keyword,omitempty"` //关键词
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *SearchRequest) Reset() {
*x = SearchRequest{}
mi := &file_blocks_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *SearchRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SearchRequest) ProtoMessage() {}
func (x *SearchRequest) ProtoReflect() protoreflect.Message {
mi := &file_blocks_proto_msgTypes[3]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use SearchRequest.ProtoReflect.Descriptor instead.
func (*SearchRequest) Descriptor() ([]byte, []int) {
return file_blocks_proto_rawDescGZIP(), []int{3}
}
func (x *SearchRequest) GetKeyword() string {
if x != nil {
return x.Keyword
}
return ""
}
type StatusReply struct {
state protoimpl.MessageState `protogen:"open.v1"`
Data string `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` // 数据
Timeseq int64 `protobuf:"varint,2,opt,name=timeseq,proto3" json:"timeseq,omitempty"` // 响应时间序列
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *StatusReply) Reset() {
*x = StatusReply{}
mi := &file_blocks_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *StatusReply) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*StatusReply) ProtoMessage() {}
func (x *StatusReply) ProtoReflect() protoreflect.Message {
mi := &file_blocks_proto_msgTypes[4]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use StatusReply.ProtoReflect.Descriptor instead.
func (*StatusReply) Descriptor() ([]byte, []int) {
return file_blocks_proto_rawDescGZIP(), []int{4}
}
func (x *StatusReply) GetData() string {
if x != nil {
return x.Data
}
return ""
}
func (x *StatusReply) GetTimeseq() int64 {
if x != nil {
return x.Timeseq
}
return 0
}
type Empty struct {
state protoimpl.MessageState `protogen:"open.v1"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *Empty) Reset() {
*x = Empty{}
mi := &file_blocks_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Empty) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Empty) ProtoMessage() {}
func (x *Empty) ProtoReflect() protoreflect.Message {
mi := &file_blocks_proto_msgTypes[5]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Empty.ProtoReflect.Descriptor instead.
func (*Empty) Descriptor() ([]byte, []int) {
return file_blocks_proto_rawDescGZIP(), []int{5}
}
// 推文列表
type PostListReply struct {
state protoimpl.MessageState `protogen:"open.v1"`
List []*PostItem `protobuf:"bytes,1,rep,name=list,proto3" json:"list,omitempty"`
Cnt int64 `protobuf:"varint,2,opt,name=cnt,proto3" json:"cnt,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *PostListReply) Reset() {
*x = PostListReply{}
mi := &file_blocks_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *PostListReply) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PostListReply) ProtoMessage() {}
func (x *PostListReply) ProtoReflect() protoreflect.Message {
mi := &file_blocks_proto_msgTypes[6]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use PostListReply.ProtoReflect.Descriptor instead.
func (*PostListReply) Descriptor() ([]byte, []int) {
return file_blocks_proto_rawDescGZIP(), []int{6}
}
func (x *PostListReply) GetList() []*PostItem {
if x != nil {
return x.List
}
return nil
}
func (x *PostListReply) GetCnt() int64 {
if x != nil {
return x.Cnt
}
return 0
}
// 推文
type PostItem struct {
state protoimpl.MessageState `protogen:"open.v1"`
Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` // 唯一标识
Content string `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"` // 内容
FeedId int64 `protobuf:"varint,3,opt,name=feed_id,json=feedId,proto3" json:"feed_id,omitempty"` // 通行证ID
FeedIdentity string `protobuf:"bytes,4,opt,name=feed_identity,json=feedIdentity,proto3" json:"feed_identity,omitempty"` // 通行证Identity
IsOpen bool `protobuf:"varint,5,opt,name=is_open,json=isOpen,proto3" json:"is_open,omitempty"` // 是否公开默认为0-公开1-不公开
CntUnlike int64 `protobuf:"varint,6,opt,name=cnt_unlike,json=cntUnlike,proto3" json:"cnt_unlike,omitempty"` // 点踩数量
CntComment int64 `protobuf:"varint,7,opt,name=cnt_comment,json=cntComment,proto3" json:"cnt_comment,omitempty"` // 评论数量
CntLike int64 `protobuf:"varint,8,opt,name=cnt_like,json=cntLike,proto3" json:"cnt_like,omitempty"` // 点赞数量
Attachs []*AttachItem `protobuf:"bytes,9,rep,name=attachs,proto3" json:"attachs,omitempty"` // 附件信息
Tags []*TagItem `protobuf:"bytes,10,rep,name=tags,proto3" json:"tags,omitempty"` // 所属话题
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *PostItem) Reset() {
*x = PostItem{}
mi := &file_blocks_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *PostItem) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PostItem) ProtoMessage() {}
func (x *PostItem) ProtoReflect() protoreflect.Message {
mi := &file_blocks_proto_msgTypes[7]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use PostItem.ProtoReflect.Descriptor instead.
func (*PostItem) Descriptor() ([]byte, []int) {
return file_blocks_proto_rawDescGZIP(), []int{7}
}
func (x *PostItem) GetIdentity() string {
if x != nil {
return x.Identity
}
return ""
}
func (x *PostItem) GetContent() string {
if x != nil {
return x.Content
}
return ""
}
func (x *PostItem) GetFeedId() int64 {
if x != nil {
return x.FeedId
}
return 0
}
func (x *PostItem) GetFeedIdentity() string {
if x != nil {
return x.FeedIdentity
}
return ""
}
func (x *PostItem) GetIsOpen() bool {
if x != nil {
return x.IsOpen
}
return false
}
func (x *PostItem) GetCntUnlike() int64 {
if x != nil {
return x.CntUnlike
}
return 0
}
func (x *PostItem) GetCntComment() int64 {
if x != nil {
return x.CntComment
}
return 0
}
func (x *PostItem) GetCntLike() int64 {
if x != nil {
return x.CntLike
}
return 0
}
func (x *PostItem) GetAttachs() []*AttachItem {
if x != nil {
return x.Attachs
}
return nil
}
func (x *PostItem) GetTags() []*TagItem {
if x != nil {
return x.Tags
}
return nil
}
// 附件
type AttachItem struct {
state protoimpl.MessageState `protogen:"open.v1"`
Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` // 唯一标识
AttachType string `protobuf:"bytes,2,opt,name=attach_type,json=attachType,proto3" json:"attach_type,omitempty"` // 文件类型
Url string `protobuf:"bytes,3,opt,name=url,proto3" json:"url,omitempty"` // 文件路径
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *AttachItem) Reset() {
*x = AttachItem{}
mi := &file_blocks_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AttachItem) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AttachItem) ProtoMessage() {}
func (x *AttachItem) ProtoReflect() protoreflect.Message {
mi := &file_blocks_proto_msgTypes[8]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AttachItem.ProtoReflect.Descriptor instead.
func (*AttachItem) Descriptor() ([]byte, []int) {
return file_blocks_proto_rawDescGZIP(), []int{8}
}
func (x *AttachItem) GetIdentity() string {
if x != nil {
return x.Identity
}
return ""
}
func (x *AttachItem) GetAttachType() string {
if x != nil {
return x.AttachType
}
return ""
}
func (x *AttachItem) GetUrl() string {
if x != nil {
return x.Url
}
return ""
}
// 标签
type TagItem struct {
state protoimpl.MessageState `protogen:"open.v1"`
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` // 标签唯一码
Content string `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"` // 标签内容
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *TagItem) Reset() {
*x = TagItem{}
mi := &file_blocks_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *TagItem) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*TagItem) ProtoMessage() {}
func (x *TagItem) ProtoReflect() protoreflect.Message {
mi := &file_blocks_proto_msgTypes[9]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use TagItem.ProtoReflect.Descriptor instead.
func (*TagItem) Descriptor() ([]byte, []int) {
return file_blocks_proto_rawDescGZIP(), []int{9}
}
func (x *TagItem) GetKey() string {
if x != nil {
return x.Key
}
return ""
}
func (x *TagItem) GetContent() string {
if x != nil {
return x.Content
}
return ""
}
var File_blocks_proto protoreflect.FileDescriptor
const file_blocks_proto_rawDesc = "" +
"\n" +
"\x11feed/blocks.proto\x12\x04feed\"\xb7\x01\n" +
"\fFetchRequest\x12\x17\n" +
"\apage_no\x18\x01 \x01(\x03R\x06pageNo\x12\x1b\n" +
"\tpage_size\x18\x02 \x01(\x03R\bpageSize\x126\n" +
"\x06params\x18\x03 \x03(\v2\x1e.feed.FetchRequest.ParamsEntryR\x06params\x1a9\n" +
"\vParamsEntry\x12\x10\n" +
"\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" +
"\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\":\n" +
"\fIdentRequest\x12\x0e\n" +
"\x02id\x18\x01 \x01(\x03R\x02id\x12\x1a\n" +
"\bidentity\x18\x02 \x01(\tR\bidentity\"*\n" +
"\x0eVersionRequest\x12\x18\n" +
"\aversion\x18\x01 \x01(\x03R\aversion\")\n" +
"\rSearchRequest\x12\x18\n" +
"\akeyword\x18\x01 \x01(\tR\akeyword\";\n" +
"\vStatusReply\x12\x12\n" +
"\x04data\x18\x01 \x01(\tR\x04data\x12\x18\n" +
"\atimeseq\x18\x02 \x01(\x03R\atimeseq\"\a\n" +
"\x05Empty\"E\n" +
"\rPostListReply\x12\"\n" +
"\x04list\x18\x01 \x03(\v2\x0e.feed.PostItemR\x04list\x12\x10\n" +
"\x03cnt\x18\x02 \x01(\x03R\x03cnt\"\xc1\x02\n" +
"\bPostItem\x12\x1a\n" +
"\bidentity\x18\x01 \x01(\tR\bidentity\x12\x18\n" +
"\acontent\x18\x02 \x01(\tR\acontent\x12\x17\n" +
"\afeed_id\x18\x03 \x01(\x03R\x06feedId\x12#\n" +
"\rfeed_identity\x18\x04 \x01(\tR\ffeedIdentity\x12\x17\n" +
"\ais_open\x18\x05 \x01(\bR\x06isOpen\x12\x1d\n" +
"\n" +
"cnt_unlike\x18\x06 \x01(\x03R\tcntUnlike\x12\x1f\n" +
"\vcnt_comment\x18\a \x01(\x03R\n" +
"cntComment\x12\x19\n" +
"\bcnt_like\x18\b \x01(\x03R\acntLike\x12*\n" +
"\aattachs\x18\t \x03(\v2\x10.feed.AttachItemR\aattachs\x12!\n" +
"\x04tags\x18\n" +
" \x03(\v2\r.feed.TagItemR\x04tags\"[\n" +
"\n" +
"AttachItem\x12\x1a\n" +
"\bidentity\x18\x01 \x01(\tR\bidentity\x12\x1f\n" +
"\vattach_type\x18\x02 \x01(\tR\n" +
"attachType\x12\x10\n" +
"\x03url\x18\x03 \x01(\tR\x03url\"5\n" +
"\aTagItem\x12\x10\n" +
"\x03key\x18\x01 \x01(\tR\x03key\x12\x18\n" +
"\acontent\x18\x02 \x01(\tR\acontentB\bZ\x06.;feedb\x06proto3"
var (
file_blocks_proto_rawDescOnce sync.Once
file_blocks_proto_rawDescData []byte
)
func file_blocks_proto_rawDescGZIP() []byte {
file_blocks_proto_rawDescOnce.Do(func() {
file_blocks_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_blocks_proto_rawDesc), len(file_blocks_proto_rawDesc)))
})
return file_blocks_proto_rawDescData
}
var file_blocks_proto_msgTypes = make([]protoimpl.MessageInfo, 11)
var file_blocks_proto_goTypes = []any{
(*FetchRequest)(nil), // 0: feed.FetchRequest
(*IdentRequest)(nil), // 1: feed.IdentRequest
(*VersionRequest)(nil), // 2: feed.VersionRequest
(*SearchRequest)(nil), // 3: feed.SearchRequest
(*StatusReply)(nil), // 4: feed.StatusReply
(*Empty)(nil), // 5: feed.Empty
(*PostListReply)(nil), // 6: feed.PostListReply
(*PostItem)(nil), // 7: feed.PostItem
(*AttachItem)(nil), // 8: feed.AttachItem
(*TagItem)(nil), // 9: feed.TagItem
nil, // 10: feed.FetchRequest.ParamsEntry
}
var file_blocks_proto_depIdxs = []int32{
10, // 0: feed.FetchRequest.params:type_name -> feed.FetchRequest.ParamsEntry
7, // 1: feed.PostListReply.list:type_name -> feed.PostItem
8, // 2: feed.PostItem.attachs:type_name -> feed.AttachItem
9, // 3: feed.PostItem.tags:type_name -> feed.TagItem
4, // [4:4] is the sub-list for method output_type
4, // [4:4] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension type_name
4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name
}
func init() { file_blocks_proto_init() }
func file_blocks_proto_init() {
if File_blocks_proto != nil {
return
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_blocks_proto_rawDesc), len(file_blocks_proto_rawDesc)),
NumEnums: 0,
NumMessages: 11,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_blocks_proto_goTypes,
DependencyIndexes: file_blocks_proto_depIdxs,
MessageInfos: file_blocks_proto_msgTypes,
}.Build()
File_blocks_proto = out.File
file_blocks_proto_goTypes = nil
file_blocks_proto_depIdxs = nil
}

View File

@@ -0,0 +1,317 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.8
// protoc (unknown)
// source: post.proto
package feed
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// 推文评论列表
type CommentListReply struct {
state protoimpl.MessageState `protogen:"open.v1"`
List []*CommentItem `protobuf:"bytes,1,rep,name=list,proto3" json:"list,omitempty"` // 评论列表
Total int64 `protobuf:"varint,2,opt,name=total,proto3" json:"total,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *CommentListReply) Reset() {
*x = CommentListReply{}
mi := &file_post_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CommentListReply) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CommentListReply) ProtoMessage() {}
func (x *CommentListReply) ProtoReflect() protoreflect.Message {
mi := &file_post_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CommentListReply.ProtoReflect.Descriptor instead.
func (*CommentListReply) Descriptor() ([]byte, []int) {
return file_post_proto_rawDescGZIP(), []int{0}
}
func (x *CommentListReply) GetList() []*CommentItem {
if x != nil {
return x.List
}
return nil
}
func (x *CommentListReply) GetTotal() int64 {
if x != nil {
return x.Total
}
return 0
}
type CommentItem struct {
state protoimpl.MessageState `protogen:"open.v1"`
Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` // 评论identity
PostIdentity string `protobuf:"bytes,2,opt,name=post_identity,json=postIdentity,proto3" json:"post_identity,omitempty"` // 被评论唯一标识
FeedIdentity string `protobuf:"bytes,3,opt,name=feed_identity,json=feedIdentity,proto3" json:"feed_identity,omitempty"` // 评论人唯一标识
Content string `protobuf:"bytes,4,opt,name=content,proto3" json:"content,omitempty"` // 评论内容
SubComment []*CommentItem `protobuf:"bytes,5,rep,name=sub_comment,json=subComment,proto3" json:"sub_comment,omitempty"` // 子评论
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *CommentItem) Reset() {
*x = CommentItem{}
mi := &file_post_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CommentItem) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CommentItem) ProtoMessage() {}
func (x *CommentItem) ProtoReflect() protoreflect.Message {
mi := &file_post_proto_msgTypes[1]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CommentItem.ProtoReflect.Descriptor instead.
func (*CommentItem) Descriptor() ([]byte, []int) {
return file_post_proto_rawDescGZIP(), []int{1}
}
func (x *CommentItem) GetIdentity() string {
if x != nil {
return x.Identity
}
return ""
}
func (x *CommentItem) GetPostIdentity() string {
if x != nil {
return x.PostIdentity
}
return ""
}
func (x *CommentItem) GetFeedIdentity() string {
if x != nil {
return x.FeedIdentity
}
return ""
}
func (x *CommentItem) GetContent() string {
if x != nil {
return x.Content
}
return ""
}
func (x *CommentItem) GetSubComment() []*CommentItem {
if x != nil {
return x.SubComment
}
return nil
}
type PostActionRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
ActionOp string `protobuf:"bytes,1,opt,name=action_op,json=actionOp,proto3" json:"action_op,omitempty"` //操作运作ilike,unlike
ActionType string `protobuf:"bytes,2,opt,name=action_type,json=actionType,proto3" json:"action_type,omitempty"` //类别:推文,评论
Identity string `protobuf:"bytes,3,opt,name=identity,proto3" json:"identity,omitempty"` // 唯一标识
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *PostActionRequest) Reset() {
*x = PostActionRequest{}
mi := &file_post_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *PostActionRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PostActionRequest) ProtoMessage() {}
func (x *PostActionRequest) ProtoReflect() protoreflect.Message {
mi := &file_post_proto_msgTypes[2]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use PostActionRequest.ProtoReflect.Descriptor instead.
func (*PostActionRequest) Descriptor() ([]byte, []int) {
return file_post_proto_rawDescGZIP(), []int{2}
}
func (x *PostActionRequest) GetActionOp() string {
if x != nil {
return x.ActionOp
}
return ""
}
func (x *PostActionRequest) GetActionType() string {
if x != nil {
return x.ActionType
}
return ""
}
func (x *PostActionRequest) GetIdentity() string {
if x != nil {
return x.Identity
}
return ""
}
var File_post_proto protoreflect.FileDescriptor
const file_post_proto_rawDesc = "" +
"\n" +
"\x16" +
"social/feed/post.proto\x12\x04feed\x1a\x11feed/blocks.proto\"O\n" +
"\x10CommentListReply\x12%\n" +
"\x04list\x18\x01 \x03(\v2\x11.feed.CommentItemR\x04list\x12\x14\n" +
"\x05total\x18\x02 \x01(\x03R\x05total\"\xc1\x01\n" +
"\vCommentItem\x12\x1a\n" +
"\bidentity\x18\x01 \x01(\tR\bidentity\x12#\n" +
"\rpost_identity\x18\x02 \x01(\tR\fpostIdentity\x12#\n" +
"\rfeed_identity\x18\x03 \x01(\tR\ffeedIdentity\x12\x18\n" +
"\acontent\x18\x04 \x01(\tR\acontent\x122\n" +
"\vsub_comment\x18\x05 \x03(\v2\x11.feed.CommentItemR\n" +
"subComment\"m\n" +
"\x11PostActionRequest\x12\x1b\n" +
"\taction_op\x18\x01 \x01(\tR\bactionOp\x12\x1f\n" +
"\vaction_type\x18\x02 \x01(\tR\n" +
"actionType\x12\x1a\n" +
"\bidentity\x18\x03 \x01(\tR\bidentity2\xb0\x03\n" +
"\x04Post\x122\n" +
"\x05Fetch\x12\x12.feed.FetchRequest\x1a\x13.feed.PostListReply\"\x00\x12-\n" +
"\x06Create\x12\x0e.feed.PostItem\x1a\x11.feed.StatusReply\"\x00\x12-\n" +
"\x06Change\x12\x0e.feed.PostItem\x1a\x11.feed.StatusReply\"\x00\x121\n" +
"\x06Remove\x12\x12.feed.IdentRequest\x1a\x11.feed.StatusReply\"\x00\x12;\n" +
"\vCommentList\x12\x12.feed.FetchRequest\x1a\x16.feed.CommentListReply\"\x00\x124\n" +
"\n" +
"AddComment\x12\x11.feed.CommentItem\x1a\x11.feed.StatusReply\"\x00\x128\n" +
"\rDeleteComment\x12\x12.feed.IdentRequest\x1a\x11.feed.StatusReply\"\x00\x126\n" +
"\x06Action\x12\x17.feed.PostActionRequest\x1a\x11.feed.StatusReply\"\x00B\bZ\x06.;feedb\x06proto3"
var (
file_post_proto_rawDescOnce sync.Once
file_post_proto_rawDescData []byte
)
func file_post_proto_rawDescGZIP() []byte {
file_post_proto_rawDescOnce.Do(func() {
file_post_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_post_proto_rawDesc), len(file_post_proto_rawDesc)))
})
return file_post_proto_rawDescData
}
var file_post_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_post_proto_goTypes = []any{
(*CommentListReply)(nil), // 0: feed.CommentListReply
(*CommentItem)(nil), // 1: feed.CommentItem
(*PostActionRequest)(nil), // 2: feed.PostActionRequest
(*FetchRequest)(nil), // 3: feed.FetchRequest
(*PostItem)(nil), // 4: feed.PostItem
(*IdentRequest)(nil), // 5: feed.IdentRequest
(*PostListReply)(nil), // 6: feed.PostListReply
(*StatusReply)(nil), // 7: feed.StatusReply
}
var file_post_proto_depIdxs = []int32{
1, // 0: feed.CommentListReply.list:type_name -> feed.CommentItem
1, // 1: feed.CommentItem.sub_comment:type_name -> feed.CommentItem
3, // 2: feed.Post.Fetch:input_type -> feed.FetchRequest
4, // 3: feed.Post.Create:input_type -> feed.PostItem
4, // 4: feed.Post.Change:input_type -> feed.PostItem
5, // 5: feed.Post.Remove:input_type -> feed.IdentRequest
3, // 6: feed.Post.CommentList:input_type -> feed.FetchRequest
1, // 7: feed.Post.AddComment:input_type -> feed.CommentItem
5, // 8: feed.Post.DeleteComment:input_type -> feed.IdentRequest
2, // 9: feed.Post.Action:input_type -> feed.PostActionRequest
6, // 10: feed.Post.Fetch:output_type -> feed.PostListReply
7, // 11: feed.Post.Create:output_type -> feed.StatusReply
7, // 12: feed.Post.Change:output_type -> feed.StatusReply
7, // 13: feed.Post.Remove:output_type -> feed.StatusReply
0, // 14: feed.Post.CommentList:output_type -> feed.CommentListReply
7, // 15: feed.Post.AddComment:output_type -> feed.StatusReply
7, // 16: feed.Post.DeleteComment:output_type -> feed.StatusReply
7, // 17: feed.Post.Action:output_type -> feed.StatusReply
10, // [10:18] is the sub-list for method output_type
2, // [2:10] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
}
func init() { file_post_proto_init() }
func file_post_proto_init() {
if File_post_proto != nil {
return
}
file_blocks_proto_init()
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_post_proto_rawDesc), len(file_post_proto_rawDesc)),
NumEnums: 0,
NumMessages: 3,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_post_proto_goTypes,
DependencyIndexes: file_post_proto_depIdxs,
MessageInfos: file_post_proto_msgTypes,
}.Build()
File_post_proto = out.File
file_post_proto_goTypes = nil
file_post_proto_depIdxs = nil
}

View File

@@ -0,0 +1,619 @@
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
// source: post.proto
/*
Package feed is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
*/
package feed
import (
"context"
"errors"
"io"
"net/http"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/grpc-ecosystem/grpc-gateway/v2/utilities"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
)
// Suppress "imported and not used" errors
var (
_ codes.Code
_ io.Reader
_ status.Status
_ = errors.New
_ = runtime.String
_ = utilities.NewDoubleArray
_ = metadata.Join
)
func request_Post_Fetch_0(ctx context.Context, marshaler runtime.Marshaler, client PostClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq FetchRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if req.Body != nil {
_, _ = io.Copy(io.Discard, req.Body)
}
msg, err := client.Fetch(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Post_Fetch_0(ctx context.Context, marshaler runtime.Marshaler, server PostServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq FetchRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.Fetch(ctx, &protoReq)
return msg, metadata, err
}
func request_Post_Create_0(ctx context.Context, marshaler runtime.Marshaler, client PostClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq PostItem
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if req.Body != nil {
_, _ = io.Copy(io.Discard, req.Body)
}
msg, err := client.Create(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Post_Create_0(ctx context.Context, marshaler runtime.Marshaler, server PostServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq PostItem
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.Create(ctx, &protoReq)
return msg, metadata, err
}
func request_Post_Change_0(ctx context.Context, marshaler runtime.Marshaler, client PostClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq PostItem
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if req.Body != nil {
_, _ = io.Copy(io.Discard, req.Body)
}
msg, err := client.Change(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Post_Change_0(ctx context.Context, marshaler runtime.Marshaler, server PostServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq PostItem
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.Change(ctx, &protoReq)
return msg, metadata, err
}
func request_Post_Remove_0(ctx context.Context, marshaler runtime.Marshaler, client PostClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq IdentRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if req.Body != nil {
_, _ = io.Copy(io.Discard, req.Body)
}
msg, err := client.Remove(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Post_Remove_0(ctx context.Context, marshaler runtime.Marshaler, server PostServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq IdentRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.Remove(ctx, &protoReq)
return msg, metadata, err
}
func request_Post_CommentList_0(ctx context.Context, marshaler runtime.Marshaler, client PostClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq FetchRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if req.Body != nil {
_, _ = io.Copy(io.Discard, req.Body)
}
msg, err := client.CommentList(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Post_CommentList_0(ctx context.Context, marshaler runtime.Marshaler, server PostServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq FetchRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.CommentList(ctx, &protoReq)
return msg, metadata, err
}
func request_Post_AddComment_0(ctx context.Context, marshaler runtime.Marshaler, client PostClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq CommentItem
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if req.Body != nil {
_, _ = io.Copy(io.Discard, req.Body)
}
msg, err := client.AddComment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Post_AddComment_0(ctx context.Context, marshaler runtime.Marshaler, server PostServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq CommentItem
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.AddComment(ctx, &protoReq)
return msg, metadata, err
}
func request_Post_DeleteComment_0(ctx context.Context, marshaler runtime.Marshaler, client PostClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq IdentRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if req.Body != nil {
_, _ = io.Copy(io.Discard, req.Body)
}
msg, err := client.DeleteComment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Post_DeleteComment_0(ctx context.Context, marshaler runtime.Marshaler, server PostServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq IdentRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.DeleteComment(ctx, &protoReq)
return msg, metadata, err
}
func request_Post_Action_0(ctx context.Context, marshaler runtime.Marshaler, client PostClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq PostActionRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if req.Body != nil {
_, _ = io.Copy(io.Discard, req.Body)
}
msg, err := client.Action(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Post_Action_0(ctx context.Context, marshaler runtime.Marshaler, server PostServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq PostActionRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.Action(ctx, &protoReq)
return msg, metadata, err
}
// RegisterPostHandlerServer registers the http handlers for service Post to "mux".
// UnaryRPC :call PostServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterPostHandlerFromEndpoint instead.
// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call.
func RegisterPostHandlerServer(ctx context.Context, mux *runtime.ServeMux, server PostServer) error {
mux.Handle(http.MethodPost, pattern_Post_Fetch_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/feed.Post/Fetch", runtime.WithHTTPPathPattern("/feed.Post/Fetch"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Post_Fetch_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Post_Fetch_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Post_Create_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/feed.Post/Create", runtime.WithHTTPPathPattern("/feed.Post/Create"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Post_Create_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Post_Create_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Post_Change_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/feed.Post/Change", runtime.WithHTTPPathPattern("/feed.Post/Change"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Post_Change_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Post_Change_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Post_Remove_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/feed.Post/Remove", runtime.WithHTTPPathPattern("/feed.Post/Remove"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Post_Remove_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Post_Remove_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Post_CommentList_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/feed.Post/CommentList", runtime.WithHTTPPathPattern("/feed.Post/CommentList"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Post_CommentList_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Post_CommentList_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Post_AddComment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/feed.Post/AddComment", runtime.WithHTTPPathPattern("/feed.Post/AddComment"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Post_AddComment_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Post_AddComment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Post_DeleteComment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/feed.Post/DeleteComment", runtime.WithHTTPPathPattern("/feed.Post/DeleteComment"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Post_DeleteComment_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Post_DeleteComment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Post_Action_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/feed.Post/Action", runtime.WithHTTPPathPattern("/feed.Post/Action"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Post_Action_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Post_Action_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
// RegisterPostHandlerFromEndpoint is same as RegisterPostHandler but
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterPostHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
conn, err := grpc.NewClient(endpoint, opts...)
if err != nil {
return err
}
defer func() {
if err != nil {
if cerr := conn.Close(); cerr != nil {
grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
}
return
}
go func() {
<-ctx.Done()
if cerr := conn.Close(); cerr != nil {
grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
}
}()
}()
return RegisterPostHandler(ctx, mux, conn)
}
// RegisterPostHandler registers the http handlers for service Post to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterPostHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
return RegisterPostHandlerClient(ctx, mux, NewPostClient(conn))
}
// RegisterPostHandlerClient registers the http handlers for service Post
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "PostClient".
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "PostClient"
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
// "PostClient" to call the correct interceptors. This client ignores the HTTP middlewares.
func RegisterPostHandlerClient(ctx context.Context, mux *runtime.ServeMux, client PostClient) error {
mux.Handle(http.MethodPost, pattern_Post_Fetch_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/feed.Post/Fetch", runtime.WithHTTPPathPattern("/feed.Post/Fetch"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Post_Fetch_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Post_Fetch_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Post_Create_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/feed.Post/Create", runtime.WithHTTPPathPattern("/feed.Post/Create"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Post_Create_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Post_Create_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Post_Change_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/feed.Post/Change", runtime.WithHTTPPathPattern("/feed.Post/Change"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Post_Change_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Post_Change_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Post_Remove_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/feed.Post/Remove", runtime.WithHTTPPathPattern("/feed.Post/Remove"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Post_Remove_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Post_Remove_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Post_CommentList_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/feed.Post/CommentList", runtime.WithHTTPPathPattern("/feed.Post/CommentList"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Post_CommentList_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Post_CommentList_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Post_AddComment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/feed.Post/AddComment", runtime.WithHTTPPathPattern("/feed.Post/AddComment"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Post_AddComment_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Post_AddComment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Post_DeleteComment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/feed.Post/DeleteComment", runtime.WithHTTPPathPattern("/feed.Post/DeleteComment"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Post_DeleteComment_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Post_DeleteComment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Post_Action_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/feed.Post/Action", runtime.WithHTTPPathPattern("/feed.Post/Action"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Post_Action_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Post_Action_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
var (
pattern_Post_Fetch_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"feed.Post", "Fetch"}, ""))
pattern_Post_Create_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"feed.Post", "Create"}, ""))
pattern_Post_Change_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"feed.Post", "Change"}, ""))
pattern_Post_Remove_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"feed.Post", "Remove"}, ""))
pattern_Post_CommentList_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"feed.Post", "CommentList"}, ""))
pattern_Post_AddComment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"feed.Post", "AddComment"}, ""))
pattern_Post_DeleteComment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"feed.Post", "DeleteComment"}, ""))
pattern_Post_Action_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"feed.Post", "Action"}, ""))
)
var (
forward_Post_Fetch_0 = runtime.ForwardResponseMessage
forward_Post_Create_0 = runtime.ForwardResponseMessage
forward_Post_Change_0 = runtime.ForwardResponseMessage
forward_Post_Remove_0 = runtime.ForwardResponseMessage
forward_Post_CommentList_0 = runtime.ForwardResponseMessage
forward_Post_AddComment_0 = runtime.ForwardResponseMessage
forward_Post_DeleteComment_0 = runtime.ForwardResponseMessage
forward_Post_Action_0 = runtime.ForwardResponseMessage
)

View File

@@ -0,0 +1,407 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc (unknown)
// source: post.proto
package feed
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
Post_Fetch_FullMethodName = "/feed.Post/Fetch"
Post_Create_FullMethodName = "/feed.Post/Create"
Post_Change_FullMethodName = "/feed.Post/Change"
Post_Remove_FullMethodName = "/feed.Post/Remove"
Post_CommentList_FullMethodName = "/feed.Post/CommentList"
Post_AddComment_FullMethodName = "/feed.Post/AddComment"
Post_DeleteComment_FullMethodName = "/feed.Post/DeleteComment"
Post_Action_FullMethodName = "/feed.Post/Action"
)
// PostClient is the client API for Post service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
//
// 推文相关操作
type PostClient interface {
// 推文列表
Fetch(ctx context.Context, in *FetchRequest, opts ...grpc.CallOption) (*PostListReply, error)
// 新建推文
Create(ctx context.Context, in *PostItem, opts ...grpc.CallOption) (*StatusReply, error)
// 修改推文
Change(ctx context.Context, in *PostItem, opts ...grpc.CallOption) (*StatusReply, error)
// 删除推文
Remove(ctx context.Context, in *IdentRequest, opts ...grpc.CallOption) (*StatusReply, error)
// 评论列表
CommentList(ctx context.Context, in *FetchRequest, opts ...grpc.CallOption) (*CommentListReply, error)
// 新建评论
AddComment(ctx context.Context, in *CommentItem, opts ...grpc.CallOption) (*StatusReply, error)
// 删除评论
DeleteComment(ctx context.Context, in *IdentRequest, opts ...grpc.CallOption) (*StatusReply, error)
// 计数操作
Action(ctx context.Context, in *PostActionRequest, opts ...grpc.CallOption) (*StatusReply, error)
}
type postClient struct {
cc grpc.ClientConnInterface
}
func NewPostClient(cc grpc.ClientConnInterface) PostClient {
return &postClient{cc}
}
func (c *postClient) Fetch(ctx context.Context, in *FetchRequest, opts ...grpc.CallOption) (*PostListReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(PostListReply)
err := c.cc.Invoke(ctx, Post_Fetch_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *postClient) Create(ctx context.Context, in *PostItem, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Post_Create_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *postClient) Change(ctx context.Context, in *PostItem, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Post_Change_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *postClient) Remove(ctx context.Context, in *IdentRequest, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Post_Remove_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *postClient) CommentList(ctx context.Context, in *FetchRequest, opts ...grpc.CallOption) (*CommentListReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(CommentListReply)
err := c.cc.Invoke(ctx, Post_CommentList_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *postClient) AddComment(ctx context.Context, in *CommentItem, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Post_AddComment_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *postClient) DeleteComment(ctx context.Context, in *IdentRequest, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Post_DeleteComment_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *postClient) Action(ctx context.Context, in *PostActionRequest, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Post_Action_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// PostServer is the server API for Post service.
// All implementations must embed UnimplementedPostServer
// for forward compatibility.
//
// 推文相关操作
type PostServer interface {
// 推文列表
Fetch(context.Context, *FetchRequest) (*PostListReply, error)
// 新建推文
Create(context.Context, *PostItem) (*StatusReply, error)
// 修改推文
Change(context.Context, *PostItem) (*StatusReply, error)
// 删除推文
Remove(context.Context, *IdentRequest) (*StatusReply, error)
// 评论列表
CommentList(context.Context, *FetchRequest) (*CommentListReply, error)
// 新建评论
AddComment(context.Context, *CommentItem) (*StatusReply, error)
// 删除评论
DeleteComment(context.Context, *IdentRequest) (*StatusReply, error)
// 计数操作
Action(context.Context, *PostActionRequest) (*StatusReply, error)
mustEmbedUnimplementedPostServer()
}
// UnimplementedPostServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedPostServer struct{}
func (UnimplementedPostServer) Fetch(context.Context, *FetchRequest) (*PostListReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Fetch not implemented")
}
func (UnimplementedPostServer) Create(context.Context, *PostItem) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Create not implemented")
}
func (UnimplementedPostServer) Change(context.Context, *PostItem) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Change not implemented")
}
func (UnimplementedPostServer) Remove(context.Context, *IdentRequest) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Remove not implemented")
}
func (UnimplementedPostServer) CommentList(context.Context, *FetchRequest) (*CommentListReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method CommentList not implemented")
}
func (UnimplementedPostServer) AddComment(context.Context, *CommentItem) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method AddComment not implemented")
}
func (UnimplementedPostServer) DeleteComment(context.Context, *IdentRequest) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method DeleteComment not implemented")
}
func (UnimplementedPostServer) Action(context.Context, *PostActionRequest) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Action not implemented")
}
func (UnimplementedPostServer) mustEmbedUnimplementedPostServer() {}
func (UnimplementedPostServer) testEmbeddedByValue() {}
// UnsafePostServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to PostServer will
// result in compilation errors.
type UnsafePostServer interface {
mustEmbedUnimplementedPostServer()
}
func RegisterPostServer(s grpc.ServiceRegistrar, srv PostServer) {
// If the following call pancis, it indicates UnimplementedPostServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&Post_ServiceDesc, srv)
}
func _Post_Fetch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(FetchRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PostServer).Fetch(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Post_Fetch_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PostServer).Fetch(ctx, req.(*FetchRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Post_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(PostItem)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PostServer).Create(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Post_Create_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PostServer).Create(ctx, req.(*PostItem))
}
return interceptor(ctx, in, info, handler)
}
func _Post_Change_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(PostItem)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PostServer).Change(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Post_Change_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PostServer).Change(ctx, req.(*PostItem))
}
return interceptor(ctx, in, info, handler)
}
func _Post_Remove_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(IdentRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PostServer).Remove(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Post_Remove_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PostServer).Remove(ctx, req.(*IdentRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Post_CommentList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(FetchRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PostServer).CommentList(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Post_CommentList_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PostServer).CommentList(ctx, req.(*FetchRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Post_AddComment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CommentItem)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PostServer).AddComment(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Post_AddComment_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PostServer).AddComment(ctx, req.(*CommentItem))
}
return interceptor(ctx, in, info, handler)
}
func _Post_DeleteComment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(IdentRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PostServer).DeleteComment(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Post_DeleteComment_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PostServer).DeleteComment(ctx, req.(*IdentRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Post_Action_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(PostActionRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PostServer).Action(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Post_Action_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PostServer).Action(ctx, req.(*PostActionRequest))
}
return interceptor(ctx, in, info, handler)
}
// Post_ServiceDesc is the grpc.ServiceDesc for Post service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Post_ServiceDesc = grpc.ServiceDesc{
ServiceName: "feed.Post",
HandlerType: (*PostServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Fetch",
Handler: _Post_Fetch_Handler,
},
{
MethodName: "Create",
Handler: _Post_Create_Handler,
},
{
MethodName: "Change",
Handler: _Post_Change_Handler,
},
{
MethodName: "Remove",
Handler: _Post_Remove_Handler,
},
{
MethodName: "CommentList",
Handler: _Post_CommentList_Handler,
},
{
MethodName: "AddComment",
Handler: _Post_AddComment_Handler,
},
{
MethodName: "DeleteComment",
Handler: _Post_DeleteComment_Handler,
},
{
MethodName: "Action",
Handler: _Post_Action_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "post.proto",
}

View File

@@ -0,0 +1,69 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.8
// protoc (unknown)
// source: setting.proto
package feed
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
unsafe "unsafe"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
var File_setting_proto protoreflect.FileDescriptor
const file_setting_proto_rawDesc = "" +
"\n" +
"\x19social/feed/setting.proto\x12\x04feed\x1a\x11feed/blocks.proto2S\n" +
"\aSetting\x12\"\n" +
"\x04Info\x12\v.feed.Empty\x1a\v.feed.Empty\"\x00\x12$\n" +
"\x06Rights\x12\v.feed.Empty\x1a\v.feed.Empty\"\x00B\bZ\x06.;feedb\x06proto3"
var file_setting_proto_goTypes = []any{
(*Empty)(nil), // 0: feed.Empty
}
var file_setting_proto_depIdxs = []int32{
0, // 0: feed.Setting.Info:input_type -> feed.Empty
0, // 1: feed.Setting.Rights:input_type -> feed.Empty
0, // 2: feed.Setting.Info:output_type -> feed.Empty
0, // 3: feed.Setting.Rights:output_type -> feed.Empty
2, // [2:4] is the sub-list for method output_type
0, // [0:2] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_setting_proto_init() }
func file_setting_proto_init() {
if File_setting_proto != nil {
return
}
file_blocks_proto_init()
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_setting_proto_rawDesc), len(file_setting_proto_rawDesc)),
NumEnums: 0,
NumMessages: 0,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_setting_proto_goTypes,
DependencyIndexes: file_setting_proto_depIdxs,
}.Build()
File_setting_proto = out.File
file_setting_proto_goTypes = nil
file_setting_proto_depIdxs = nil
}

View File

@@ -0,0 +1,223 @@
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
// source: setting.proto
/*
Package feed is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
*/
package feed
import (
"context"
"errors"
"io"
"net/http"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/grpc-ecosystem/grpc-gateway/v2/utilities"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
)
// Suppress "imported and not used" errors
var (
_ codes.Code
_ io.Reader
_ status.Status
_ = errors.New
_ = runtime.String
_ = utilities.NewDoubleArray
_ = metadata.Join
)
func request_Setting_Info_0(ctx context.Context, marshaler runtime.Marshaler, client SettingClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq Empty
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if req.Body != nil {
_, _ = io.Copy(io.Discard, req.Body)
}
msg, err := client.Info(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Setting_Info_0(ctx context.Context, marshaler runtime.Marshaler, server SettingServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq Empty
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.Info(ctx, &protoReq)
return msg, metadata, err
}
func request_Setting_Rights_0(ctx context.Context, marshaler runtime.Marshaler, client SettingClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq Empty
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if req.Body != nil {
_, _ = io.Copy(io.Discard, req.Body)
}
msg, err := client.Rights(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Setting_Rights_0(ctx context.Context, marshaler runtime.Marshaler, server SettingServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq Empty
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.Rights(ctx, &protoReq)
return msg, metadata, err
}
// RegisterSettingHandlerServer registers the http handlers for service Setting to "mux".
// UnaryRPC :call SettingServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterSettingHandlerFromEndpoint instead.
// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call.
func RegisterSettingHandlerServer(ctx context.Context, mux *runtime.ServeMux, server SettingServer) error {
mux.Handle(http.MethodPost, pattern_Setting_Info_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/feed.Setting/Info", runtime.WithHTTPPathPattern("/feed.Setting/Info"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Setting_Info_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Setting_Info_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Setting_Rights_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/feed.Setting/Rights", runtime.WithHTTPPathPattern("/feed.Setting/Rights"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Setting_Rights_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Setting_Rights_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
// RegisterSettingHandlerFromEndpoint is same as RegisterSettingHandler but
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterSettingHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
conn, err := grpc.NewClient(endpoint, opts...)
if err != nil {
return err
}
defer func() {
if err != nil {
if cerr := conn.Close(); cerr != nil {
grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
}
return
}
go func() {
<-ctx.Done()
if cerr := conn.Close(); cerr != nil {
grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
}
}()
}()
return RegisterSettingHandler(ctx, mux, conn)
}
// RegisterSettingHandler registers the http handlers for service Setting to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterSettingHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
return RegisterSettingHandlerClient(ctx, mux, NewSettingClient(conn))
}
// RegisterSettingHandlerClient registers the http handlers for service Setting
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "SettingClient".
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "SettingClient"
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
// "SettingClient" to call the correct interceptors. This client ignores the HTTP middlewares.
func RegisterSettingHandlerClient(ctx context.Context, mux *runtime.ServeMux, client SettingClient) error {
mux.Handle(http.MethodPost, pattern_Setting_Info_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/feed.Setting/Info", runtime.WithHTTPPathPattern("/feed.Setting/Info"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Setting_Info_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Setting_Info_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Setting_Rights_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/feed.Setting/Rights", runtime.WithHTTPPathPattern("/feed.Setting/Rights"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Setting_Rights_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Setting_Rights_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
var (
pattern_Setting_Info_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"feed.Setting", "Info"}, ""))
pattern_Setting_Rights_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"feed.Setting", "Rights"}, ""))
)
var (
forward_Setting_Info_0 = runtime.ForwardResponseMessage
forward_Setting_Rights_0 = runtime.ForwardResponseMessage
)

View File

@@ -0,0 +1,163 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc (unknown)
// source: setting.proto
package feed
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
Setting_Info_FullMethodName = "/feed.Setting/Info"
Setting_Rights_FullMethodName = "/feed.Setting/Rights"
)
// SettingClient is the client API for Setting service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type SettingClient interface {
// 修改个人信息
Info(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Empty, error)
// 修改权限信息
Rights(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Empty, error)
}
type settingClient struct {
cc grpc.ClientConnInterface
}
func NewSettingClient(cc grpc.ClientConnInterface) SettingClient {
return &settingClient{cc}
}
func (c *settingClient) Info(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Empty, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(Empty)
err := c.cc.Invoke(ctx, Setting_Info_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *settingClient) Rights(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Empty, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(Empty)
err := c.cc.Invoke(ctx, Setting_Rights_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// SettingServer is the server API for Setting service.
// All implementations must embed UnimplementedSettingServer
// for forward compatibility.
type SettingServer interface {
// 修改个人信息
Info(context.Context, *Empty) (*Empty, error)
// 修改权限信息
Rights(context.Context, *Empty) (*Empty, error)
mustEmbedUnimplementedSettingServer()
}
// UnimplementedSettingServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedSettingServer struct{}
func (UnimplementedSettingServer) Info(context.Context, *Empty) (*Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method Info not implemented")
}
func (UnimplementedSettingServer) Rights(context.Context, *Empty) (*Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method Rights not implemented")
}
func (UnimplementedSettingServer) mustEmbedUnimplementedSettingServer() {}
func (UnimplementedSettingServer) testEmbeddedByValue() {}
// UnsafeSettingServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to SettingServer will
// result in compilation errors.
type UnsafeSettingServer interface {
mustEmbedUnimplementedSettingServer()
}
func RegisterSettingServer(s grpc.ServiceRegistrar, srv SettingServer) {
// If the following call pancis, it indicates UnimplementedSettingServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&Setting_ServiceDesc, srv)
}
func _Setting_Info_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(Empty)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(SettingServer).Info(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Setting_Info_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(SettingServer).Info(ctx, req.(*Empty))
}
return interceptor(ctx, in, info, handler)
}
func _Setting_Rights_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(Empty)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(SettingServer).Rights(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Setting_Rights_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(SettingServer).Rights(ctx, req.(*Empty))
}
return interceptor(ctx, in, info, handler)
}
// Setting_ServiceDesc is the grpc.ServiceDesc for Setting service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Setting_ServiceDesc = grpc.ServiceDesc{
ServiceName: "feed.Setting",
HandlerType: (*SettingServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Info",
Handler: _Setting_Info_Handler,
},
{
MethodName: "Rights",
Handler: _Setting_Rights_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "setting.proto",
}

View File

@@ -0,0 +1,194 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.8
// protoc (unknown)
// source: tag.proto
package feed
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type AddTagRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Tags []string `protobuf:"bytes,1,rep,name=tags,proto3" json:"tags,omitempty"` // 标签名称
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *AddTagRequest) Reset() {
*x = AddTagRequest{}
mi := &file_tag_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AddTagRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AddTagRequest) ProtoMessage() {}
func (x *AddTagRequest) ProtoReflect() protoreflect.Message {
mi := &file_tag_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AddTagRequest.ProtoReflect.Descriptor instead.
func (*AddTagRequest) Descriptor() ([]byte, []int) {
return file_tag_proto_rawDescGZIP(), []int{0}
}
func (x *AddTagRequest) GetTags() []string {
if x != nil {
return x.Tags
}
return nil
}
type TagListReply struct {
state protoimpl.MessageState `protogen:"open.v1"`
Tags []*TagItem `protobuf:"bytes,1,rep,name=tags,proto3" json:"tags,omitempty"`
Total int64 `protobuf:"varint,2,opt,name=total,proto3" json:"total,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *TagListReply) Reset() {
*x = TagListReply{}
mi := &file_tag_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *TagListReply) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*TagListReply) ProtoMessage() {}
func (x *TagListReply) ProtoReflect() protoreflect.Message {
mi := &file_tag_proto_msgTypes[1]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use TagListReply.ProtoReflect.Descriptor instead.
func (*TagListReply) Descriptor() ([]byte, []int) {
return file_tag_proto_rawDescGZIP(), []int{1}
}
func (x *TagListReply) GetTags() []*TagItem {
if x != nil {
return x.Tags
}
return nil
}
func (x *TagListReply) GetTotal() int64 {
if x != nil {
return x.Total
}
return 0
}
var File_tag_proto protoreflect.FileDescriptor
const file_tag_proto_rawDesc = "" +
"\n" +
"\x15social/feed/tag.proto\x12\x04feed\x1a\x11feed/blocks.proto\"#\n" +
"\rAddTagRequest\x12\x12\n" +
"\x04tags\x18\x01 \x03(\tR\x04tags\"G\n" +
"\fTagListReply\x12!\n" +
"\x04tags\x18\x01 \x03(\v2\r.feed.TagItemR\x04tags\x12\x14\n" +
"\x05total\x18\x02 \x01(\x03R\x05total2\xa2\x01\n" +
"\x03Tag\x120\n" +
"\x04List\x12\x12.feed.FetchRequest\x1a\x12.feed.TagListReply\"\x00\x122\n" +
"\x06Create\x12\x13.feed.AddTagRequest\x1a\x11.feed.StatusReply\"\x00\x125\n" +
"\bPostList\x12\x12.feed.FetchRequest\x1a\x13.feed.PostListReply\"\x00B\bZ\x06.;feedb\x06proto3"
var (
file_tag_proto_rawDescOnce sync.Once
file_tag_proto_rawDescData []byte
)
func file_tag_proto_rawDescGZIP() []byte {
file_tag_proto_rawDescOnce.Do(func() {
file_tag_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_tag_proto_rawDesc), len(file_tag_proto_rawDesc)))
})
return file_tag_proto_rawDescData
}
var file_tag_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_tag_proto_goTypes = []any{
(*AddTagRequest)(nil), // 0: feed.AddTagRequest
(*TagListReply)(nil), // 1: feed.TagListReply
(*TagItem)(nil), // 2: feed.TagItem
(*FetchRequest)(nil), // 3: feed.FetchRequest
(*StatusReply)(nil), // 4: feed.StatusReply
(*PostListReply)(nil), // 5: feed.PostListReply
}
var file_tag_proto_depIdxs = []int32{
2, // 0: feed.TagListReply.tags:type_name -> feed.TagItem
3, // 1: feed.Tag.List:input_type -> feed.FetchRequest
0, // 2: feed.Tag.Create:input_type -> feed.AddTagRequest
3, // 3: feed.Tag.PostList:input_type -> feed.FetchRequest
1, // 4: feed.Tag.List:output_type -> feed.TagListReply
4, // 5: feed.Tag.Create:output_type -> feed.StatusReply
5, // 6: feed.Tag.PostList:output_type -> feed.PostListReply
4, // [4:7] is the sub-list for method output_type
1, // [1:4] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_tag_proto_init() }
func file_tag_proto_init() {
if File_tag_proto != nil {
return
}
file_blocks_proto_init()
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_tag_proto_rawDesc), len(file_tag_proto_rawDesc)),
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_tag_proto_goTypes,
DependencyIndexes: file_tag_proto_depIdxs,
MessageInfos: file_tag_proto_msgTypes,
}.Build()
File_tag_proto = out.File
file_tag_proto_goTypes = nil
file_tag_proto_depIdxs = nil
}

View File

@@ -0,0 +1,289 @@
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
// source: tag.proto
/*
Package feed is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
*/
package feed
import (
"context"
"errors"
"io"
"net/http"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/grpc-ecosystem/grpc-gateway/v2/utilities"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
)
// Suppress "imported and not used" errors
var (
_ codes.Code
_ io.Reader
_ status.Status
_ = errors.New
_ = runtime.String
_ = utilities.NewDoubleArray
_ = metadata.Join
)
func request_Tag_List_0(ctx context.Context, marshaler runtime.Marshaler, client TagClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq FetchRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if req.Body != nil {
_, _ = io.Copy(io.Discard, req.Body)
}
msg, err := client.List(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Tag_List_0(ctx context.Context, marshaler runtime.Marshaler, server TagServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq FetchRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.List(ctx, &protoReq)
return msg, metadata, err
}
func request_Tag_Create_0(ctx context.Context, marshaler runtime.Marshaler, client TagClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq AddTagRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if req.Body != nil {
_, _ = io.Copy(io.Discard, req.Body)
}
msg, err := client.Create(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Tag_Create_0(ctx context.Context, marshaler runtime.Marshaler, server TagServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq AddTagRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.Create(ctx, &protoReq)
return msg, metadata, err
}
func request_Tag_PostList_0(ctx context.Context, marshaler runtime.Marshaler, client TagClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq FetchRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if req.Body != nil {
_, _ = io.Copy(io.Discard, req.Body)
}
msg, err := client.PostList(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Tag_PostList_0(ctx context.Context, marshaler runtime.Marshaler, server TagServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq FetchRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.PostList(ctx, &protoReq)
return msg, metadata, err
}
// RegisterTagHandlerServer registers the http handlers for service Tag to "mux".
// UnaryRPC :call TagServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterTagHandlerFromEndpoint instead.
// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call.
func RegisterTagHandlerServer(ctx context.Context, mux *runtime.ServeMux, server TagServer) error {
mux.Handle(http.MethodPost, pattern_Tag_List_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/feed.Tag/List", runtime.WithHTTPPathPattern("/feed.Tag/List"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Tag_List_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Tag_List_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Tag_Create_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/feed.Tag/Create", runtime.WithHTTPPathPattern("/feed.Tag/Create"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Tag_Create_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Tag_Create_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Tag_PostList_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/feed.Tag/PostList", runtime.WithHTTPPathPattern("/feed.Tag/PostList"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Tag_PostList_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Tag_PostList_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
// RegisterTagHandlerFromEndpoint is same as RegisterTagHandler but
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterTagHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
conn, err := grpc.NewClient(endpoint, opts...)
if err != nil {
return err
}
defer func() {
if err != nil {
if cerr := conn.Close(); cerr != nil {
grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
}
return
}
go func() {
<-ctx.Done()
if cerr := conn.Close(); cerr != nil {
grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
}
}()
}()
return RegisterTagHandler(ctx, mux, conn)
}
// RegisterTagHandler registers the http handlers for service Tag to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterTagHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
return RegisterTagHandlerClient(ctx, mux, NewTagClient(conn))
}
// RegisterTagHandlerClient registers the http handlers for service Tag
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "TagClient".
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "TagClient"
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
// "TagClient" to call the correct interceptors. This client ignores the HTTP middlewares.
func RegisterTagHandlerClient(ctx context.Context, mux *runtime.ServeMux, client TagClient) error {
mux.Handle(http.MethodPost, pattern_Tag_List_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/feed.Tag/List", runtime.WithHTTPPathPattern("/feed.Tag/List"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Tag_List_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Tag_List_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Tag_Create_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/feed.Tag/Create", runtime.WithHTTPPathPattern("/feed.Tag/Create"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Tag_Create_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Tag_Create_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Tag_PostList_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/feed.Tag/PostList", runtime.WithHTTPPathPattern("/feed.Tag/PostList"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Tag_PostList_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Tag_PostList_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
var (
pattern_Tag_List_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"feed.Tag", "List"}, ""))
pattern_Tag_Create_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"feed.Tag", "Create"}, ""))
pattern_Tag_PostList_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"feed.Tag", "PostList"}, ""))
)
var (
forward_Tag_List_0 = runtime.ForwardResponseMessage
forward_Tag_Create_0 = runtime.ForwardResponseMessage
forward_Tag_PostList_0 = runtime.ForwardResponseMessage
)

View File

@@ -0,0 +1,203 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc (unknown)
// source: tag.proto
package feed
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
Tag_List_FullMethodName = "/feed.Tag/List"
Tag_Create_FullMethodName = "/feed.Tag/Create"
Tag_PostList_FullMethodName = "/feed.Tag/PostList"
)
// TagClient is the client API for Tag service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type TagClient interface {
// 标签列表
List(ctx context.Context, in *FetchRequest, opts ...grpc.CallOption) (*TagListReply, error)
// 新建标签
Create(ctx context.Context, in *AddTagRequest, opts ...grpc.CallOption) (*StatusReply, error)
// 话题相关的文章
PostList(ctx context.Context, in *FetchRequest, opts ...grpc.CallOption) (*PostListReply, error)
}
type tagClient struct {
cc grpc.ClientConnInterface
}
func NewTagClient(cc grpc.ClientConnInterface) TagClient {
return &tagClient{cc}
}
func (c *tagClient) List(ctx context.Context, in *FetchRequest, opts ...grpc.CallOption) (*TagListReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(TagListReply)
err := c.cc.Invoke(ctx, Tag_List_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *tagClient) Create(ctx context.Context, in *AddTagRequest, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Tag_Create_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *tagClient) PostList(ctx context.Context, in *FetchRequest, opts ...grpc.CallOption) (*PostListReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(PostListReply)
err := c.cc.Invoke(ctx, Tag_PostList_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// TagServer is the server API for Tag service.
// All implementations must embed UnimplementedTagServer
// for forward compatibility.
type TagServer interface {
// 标签列表
List(context.Context, *FetchRequest) (*TagListReply, error)
// 新建标签
Create(context.Context, *AddTagRequest) (*StatusReply, error)
// 话题相关的文章
PostList(context.Context, *FetchRequest) (*PostListReply, error)
mustEmbedUnimplementedTagServer()
}
// UnimplementedTagServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedTagServer struct{}
func (UnimplementedTagServer) List(context.Context, *FetchRequest) (*TagListReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method List not implemented")
}
func (UnimplementedTagServer) Create(context.Context, *AddTagRequest) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Create not implemented")
}
func (UnimplementedTagServer) PostList(context.Context, *FetchRequest) (*PostListReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method PostList not implemented")
}
func (UnimplementedTagServer) mustEmbedUnimplementedTagServer() {}
func (UnimplementedTagServer) testEmbeddedByValue() {}
// UnsafeTagServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to TagServer will
// result in compilation errors.
type UnsafeTagServer interface {
mustEmbedUnimplementedTagServer()
}
func RegisterTagServer(s grpc.ServiceRegistrar, srv TagServer) {
// If the following call pancis, it indicates UnimplementedTagServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&Tag_ServiceDesc, srv)
}
func _Tag_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(FetchRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(TagServer).List(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Tag_List_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(TagServer).List(ctx, req.(*FetchRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Tag_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(AddTagRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(TagServer).Create(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Tag_Create_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(TagServer).Create(ctx, req.(*AddTagRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Tag_PostList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(FetchRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(TagServer).PostList(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Tag_PostList_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(TagServer).PostList(ctx, req.(*FetchRequest))
}
return interceptor(ctx, in, info, handler)
}
// Tag_ServiceDesc is the grpc.ServiceDesc for Tag service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Tag_ServiceDesc = grpc.ServiceDesc{
ServiceName: "feed.Tag",
HandlerType: (*TagServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "List",
Handler: _Tag_List_Handler,
},
{
MethodName: "Create",
Handler: _Tag_Create_Handler,
},
{
MethodName: "PostList",
Handler: _Tag_PostList_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "tag.proto",
}

View File

@@ -0,0 +1,76 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.8
// protoc (unknown)
// source: timeline.proto
package feed
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
unsafe "unsafe"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
var File_timeline_proto protoreflect.FileDescriptor
const file_timeline_proto_rawDesc = "" +
"\n" +
"\x1asocial/feed/timeline.proto\x12\x04feed\x1a\x11feed/blocks.proto2\xde\x01\n" +
"\bTimeline\x126\n" +
"\tRecommend\x12\x12.feed.FetchRequest\x1a\x13.feed.PostListReply\"\x00\x123\n" +
"\x06Friend\x12\x12.feed.FetchRequest\x1a\x13.feed.PostListReply\"\x00\x123\n" +
"\x06Follow\x12\x12.feed.FetchRequest\x1a\x13.feed.PostListReply\"\x00\x120\n" +
"\x03Hot\x12\x12.feed.FetchRequest\x1a\x13.feed.PostListReply\"\x00B\bZ\x06.;feedb\x06proto3"
var file_timeline_proto_goTypes = []any{
(*FetchRequest)(nil), // 0: feed.FetchRequest
(*PostListReply)(nil), // 1: feed.PostListReply
}
var file_timeline_proto_depIdxs = []int32{
0, // 0: feed.Timeline.Recommend:input_type -> feed.FetchRequest
0, // 1: feed.Timeline.Friend:input_type -> feed.FetchRequest
0, // 2: feed.Timeline.Follow:input_type -> feed.FetchRequest
0, // 3: feed.Timeline.Hot:input_type -> feed.FetchRequest
1, // 4: feed.Timeline.Recommend:output_type -> feed.PostListReply
1, // 5: feed.Timeline.Friend:output_type -> feed.PostListReply
1, // 6: feed.Timeline.Follow:output_type -> feed.PostListReply
1, // 7: feed.Timeline.Hot:output_type -> feed.PostListReply
4, // [4:8] is the sub-list for method output_type
0, // [0:4] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_timeline_proto_init() }
func file_timeline_proto_init() {
if File_timeline_proto != nil {
return
}
file_blocks_proto_init()
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_timeline_proto_rawDesc), len(file_timeline_proto_rawDesc)),
NumEnums: 0,
NumMessages: 0,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_timeline_proto_goTypes,
DependencyIndexes: file_timeline_proto_depIdxs,
}.Build()
File_timeline_proto = out.File
file_timeline_proto_goTypes = nil
file_timeline_proto_depIdxs = nil
}

View File

@@ -0,0 +1,355 @@
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
// source: timeline.proto
/*
Package feed is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
*/
package feed
import (
"context"
"errors"
"io"
"net/http"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/grpc-ecosystem/grpc-gateway/v2/utilities"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
)
// Suppress "imported and not used" errors
var (
_ codes.Code
_ io.Reader
_ status.Status
_ = errors.New
_ = runtime.String
_ = utilities.NewDoubleArray
_ = metadata.Join
)
func request_Timeline_Recommend_0(ctx context.Context, marshaler runtime.Marshaler, client TimelineClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq FetchRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if req.Body != nil {
_, _ = io.Copy(io.Discard, req.Body)
}
msg, err := client.Recommend(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Timeline_Recommend_0(ctx context.Context, marshaler runtime.Marshaler, server TimelineServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq FetchRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.Recommend(ctx, &protoReq)
return msg, metadata, err
}
func request_Timeline_Friend_0(ctx context.Context, marshaler runtime.Marshaler, client TimelineClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq FetchRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if req.Body != nil {
_, _ = io.Copy(io.Discard, req.Body)
}
msg, err := client.Friend(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Timeline_Friend_0(ctx context.Context, marshaler runtime.Marshaler, server TimelineServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq FetchRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.Friend(ctx, &protoReq)
return msg, metadata, err
}
func request_Timeline_Follow_0(ctx context.Context, marshaler runtime.Marshaler, client TimelineClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq FetchRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if req.Body != nil {
_, _ = io.Copy(io.Discard, req.Body)
}
msg, err := client.Follow(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Timeline_Follow_0(ctx context.Context, marshaler runtime.Marshaler, server TimelineServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq FetchRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.Follow(ctx, &protoReq)
return msg, metadata, err
}
func request_Timeline_Hot_0(ctx context.Context, marshaler runtime.Marshaler, client TimelineClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq FetchRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if req.Body != nil {
_, _ = io.Copy(io.Discard, req.Body)
}
msg, err := client.Hot(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Timeline_Hot_0(ctx context.Context, marshaler runtime.Marshaler, server TimelineServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq FetchRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.Hot(ctx, &protoReq)
return msg, metadata, err
}
// RegisterTimelineHandlerServer registers the http handlers for service Timeline to "mux".
// UnaryRPC :call TimelineServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterTimelineHandlerFromEndpoint instead.
// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call.
func RegisterTimelineHandlerServer(ctx context.Context, mux *runtime.ServeMux, server TimelineServer) error {
mux.Handle(http.MethodPost, pattern_Timeline_Recommend_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/feed.Timeline/Recommend", runtime.WithHTTPPathPattern("/feed.Timeline/Recommend"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Timeline_Recommend_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Timeline_Recommend_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Timeline_Friend_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/feed.Timeline/Friend", runtime.WithHTTPPathPattern("/feed.Timeline/Friend"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Timeline_Friend_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Timeline_Friend_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Timeline_Follow_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/feed.Timeline/Follow", runtime.WithHTTPPathPattern("/feed.Timeline/Follow"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Timeline_Follow_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Timeline_Follow_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Timeline_Hot_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/feed.Timeline/Hot", runtime.WithHTTPPathPattern("/feed.Timeline/Hot"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Timeline_Hot_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Timeline_Hot_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
// RegisterTimelineHandlerFromEndpoint is same as RegisterTimelineHandler but
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterTimelineHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
conn, err := grpc.NewClient(endpoint, opts...)
if err != nil {
return err
}
defer func() {
if err != nil {
if cerr := conn.Close(); cerr != nil {
grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
}
return
}
go func() {
<-ctx.Done()
if cerr := conn.Close(); cerr != nil {
grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
}
}()
}()
return RegisterTimelineHandler(ctx, mux, conn)
}
// RegisterTimelineHandler registers the http handlers for service Timeline to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterTimelineHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
return RegisterTimelineHandlerClient(ctx, mux, NewTimelineClient(conn))
}
// RegisterTimelineHandlerClient registers the http handlers for service Timeline
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "TimelineClient".
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "TimelineClient"
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
// "TimelineClient" to call the correct interceptors. This client ignores the HTTP middlewares.
func RegisterTimelineHandlerClient(ctx context.Context, mux *runtime.ServeMux, client TimelineClient) error {
mux.Handle(http.MethodPost, pattern_Timeline_Recommend_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/feed.Timeline/Recommend", runtime.WithHTTPPathPattern("/feed.Timeline/Recommend"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Timeline_Recommend_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Timeline_Recommend_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Timeline_Friend_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/feed.Timeline/Friend", runtime.WithHTTPPathPattern("/feed.Timeline/Friend"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Timeline_Friend_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Timeline_Friend_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Timeline_Follow_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/feed.Timeline/Follow", runtime.WithHTTPPathPattern("/feed.Timeline/Follow"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Timeline_Follow_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Timeline_Follow_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Timeline_Hot_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/feed.Timeline/Hot", runtime.WithHTTPPathPattern("/feed.Timeline/Hot"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Timeline_Hot_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Timeline_Hot_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
var (
pattern_Timeline_Recommend_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"feed.Timeline", "Recommend"}, ""))
pattern_Timeline_Friend_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"feed.Timeline", "Friend"}, ""))
pattern_Timeline_Follow_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"feed.Timeline", "Follow"}, ""))
pattern_Timeline_Hot_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"feed.Timeline", "Hot"}, ""))
)
var (
forward_Timeline_Recommend_0 = runtime.ForwardResponseMessage
forward_Timeline_Friend_0 = runtime.ForwardResponseMessage
forward_Timeline_Follow_0 = runtime.ForwardResponseMessage
forward_Timeline_Hot_0 = runtime.ForwardResponseMessage
)

View File

@@ -0,0 +1,247 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc (unknown)
// source: timeline.proto
package feed
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
Timeline_Recommend_FullMethodName = "/feed.Timeline/Recommend"
Timeline_Friend_FullMethodName = "/feed.Timeline/Friend"
Timeline_Follow_FullMethodName = "/feed.Timeline/Follow"
Timeline_Hot_FullMethodName = "/feed.Timeline/Hot"
)
// TimelineClient is the client API for Timeline service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
//
// 实时动态
type TimelineClient interface {
// 推荐
Recommend(ctx context.Context, in *FetchRequest, opts ...grpc.CallOption) (*PostListReply, error)
// 好友动态
Friend(ctx context.Context, in *FetchRequest, opts ...grpc.CallOption) (*PostListReply, error)
// 关注的动态
Follow(ctx context.Context, in *FetchRequest, opts ...grpc.CallOption) (*PostListReply, error)
// 热门
Hot(ctx context.Context, in *FetchRequest, opts ...grpc.CallOption) (*PostListReply, error)
}
type timelineClient struct {
cc grpc.ClientConnInterface
}
func NewTimelineClient(cc grpc.ClientConnInterface) TimelineClient {
return &timelineClient{cc}
}
func (c *timelineClient) Recommend(ctx context.Context, in *FetchRequest, opts ...grpc.CallOption) (*PostListReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(PostListReply)
err := c.cc.Invoke(ctx, Timeline_Recommend_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *timelineClient) Friend(ctx context.Context, in *FetchRequest, opts ...grpc.CallOption) (*PostListReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(PostListReply)
err := c.cc.Invoke(ctx, Timeline_Friend_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *timelineClient) Follow(ctx context.Context, in *FetchRequest, opts ...grpc.CallOption) (*PostListReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(PostListReply)
err := c.cc.Invoke(ctx, Timeline_Follow_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *timelineClient) Hot(ctx context.Context, in *FetchRequest, opts ...grpc.CallOption) (*PostListReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(PostListReply)
err := c.cc.Invoke(ctx, Timeline_Hot_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// TimelineServer is the server API for Timeline service.
// All implementations must embed UnimplementedTimelineServer
// for forward compatibility.
//
// 实时动态
type TimelineServer interface {
// 推荐
Recommend(context.Context, *FetchRequest) (*PostListReply, error)
// 好友动态
Friend(context.Context, *FetchRequest) (*PostListReply, error)
// 关注的动态
Follow(context.Context, *FetchRequest) (*PostListReply, error)
// 热门
Hot(context.Context, *FetchRequest) (*PostListReply, error)
mustEmbedUnimplementedTimelineServer()
}
// UnimplementedTimelineServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedTimelineServer struct{}
func (UnimplementedTimelineServer) Recommend(context.Context, *FetchRequest) (*PostListReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Recommend not implemented")
}
func (UnimplementedTimelineServer) Friend(context.Context, *FetchRequest) (*PostListReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Friend not implemented")
}
func (UnimplementedTimelineServer) Follow(context.Context, *FetchRequest) (*PostListReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Follow not implemented")
}
func (UnimplementedTimelineServer) Hot(context.Context, *FetchRequest) (*PostListReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Hot not implemented")
}
func (UnimplementedTimelineServer) mustEmbedUnimplementedTimelineServer() {}
func (UnimplementedTimelineServer) testEmbeddedByValue() {}
// UnsafeTimelineServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to TimelineServer will
// result in compilation errors.
type UnsafeTimelineServer interface {
mustEmbedUnimplementedTimelineServer()
}
func RegisterTimelineServer(s grpc.ServiceRegistrar, srv TimelineServer) {
// If the following call pancis, it indicates UnimplementedTimelineServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&Timeline_ServiceDesc, srv)
}
func _Timeline_Recommend_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(FetchRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(TimelineServer).Recommend(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Timeline_Recommend_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(TimelineServer).Recommend(ctx, req.(*FetchRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Timeline_Friend_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(FetchRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(TimelineServer).Friend(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Timeline_Friend_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(TimelineServer).Friend(ctx, req.(*FetchRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Timeline_Follow_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(FetchRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(TimelineServer).Follow(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Timeline_Follow_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(TimelineServer).Follow(ctx, req.(*FetchRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Timeline_Hot_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(FetchRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(TimelineServer).Hot(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Timeline_Hot_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(TimelineServer).Hot(ctx, req.(*FetchRequest))
}
return interceptor(ctx, in, info, handler)
}
// Timeline_ServiceDesc is the grpc.ServiceDesc for Timeline service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Timeline_ServiceDesc = grpc.ServiceDesc{
ServiceName: "feed.Timeline",
HandlerType: (*TimelineServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Recommend",
Handler: _Timeline_Recommend_Handler,
},
{
MethodName: "Friend",
Handler: _Timeline_Friend_Handler,
},
{
MethodName: "Follow",
Handler: _Timeline_Follow_Handler,
},
{
MethodName: "Hot",
Handler: _Timeline_Hot_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "timeline.proto",
}