mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-22 23:35:26 +00:00
add news service (#282)
This commit is contained in:
416
news/proto/news.pb.go
Normal file
416
news/proto/news.pb.go
Normal file
@@ -0,0 +1,416 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.27.1
|
||||
// protoc v3.15.6
|
||||
// source: proto/news.proto
|
||||
|
||||
package news
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
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 Article struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// article id
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
// article title
|
||||
Title string `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"`
|
||||
// article description
|
||||
Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"`
|
||||
// related keywords
|
||||
Keywords string `protobuf:"bytes,4,opt,name=keywords,proto3" json:"keywords,omitempty"`
|
||||
// first 60 characters of article body
|
||||
Snippet string `protobuf:"bytes,5,opt,name=snippet,proto3" json:"snippet,omitempty"`
|
||||
// url of the article
|
||||
Url string `protobuf:"bytes,6,opt,name=url,proto3" json:"url,omitempty"`
|
||||
// image url
|
||||
ImageUrl string `protobuf:"bytes,7,opt,name=image_url,json=imageUrl,proto3" json:"image_url,omitempty"`
|
||||
// time it was published
|
||||
PublishedAt string `protobuf:"bytes,8,opt,name=published_at,json=publishedAt,proto3" json:"published_at,omitempty"`
|
||||
// source of news
|
||||
Source string `protobuf:"bytes,9,opt,name=source,proto3" json:"source,omitempty"`
|
||||
// categories
|
||||
Categories []string `protobuf:"bytes,10,rep,name=categories,proto3" json:"categories,omitempty"`
|
||||
// the article language
|
||||
Language string `protobuf:"bytes,11,opt,name=language,proto3" json:"language,omitempty"`
|
||||
// the locale
|
||||
Locale string `protobuf:"bytes,12,opt,name=locale,proto3" json:"locale,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Article) Reset() {
|
||||
*x = Article{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_news_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Article) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Article) ProtoMessage() {}
|
||||
|
||||
func (x *Article) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_news_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Article.ProtoReflect.Descriptor instead.
|
||||
func (*Article) Descriptor() ([]byte, []int) {
|
||||
return file_proto_news_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *Article) GetId() string {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Article) GetTitle() string {
|
||||
if x != nil {
|
||||
return x.Title
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Article) GetDescription() string {
|
||||
if x != nil {
|
||||
return x.Description
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Article) GetKeywords() string {
|
||||
if x != nil {
|
||||
return x.Keywords
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Article) GetSnippet() string {
|
||||
if x != nil {
|
||||
return x.Snippet
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Article) GetUrl() string {
|
||||
if x != nil {
|
||||
return x.Url
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Article) GetImageUrl() string {
|
||||
if x != nil {
|
||||
return x.ImageUrl
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Article) GetPublishedAt() string {
|
||||
if x != nil {
|
||||
return x.PublishedAt
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Article) GetSource() string {
|
||||
if x != nil {
|
||||
return x.Source
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Article) GetCategories() []string {
|
||||
if x != nil {
|
||||
return x.Categories
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Article) GetLanguage() string {
|
||||
if x != nil {
|
||||
return x.Language
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Article) GetLocale() string {
|
||||
if x != nil {
|
||||
return x.Locale
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type HeadlinesRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// comma separated list of languages to retrieve in e.g en,es
|
||||
Language string `protobuf:"bytes,1,opt,name=language,proto3" json:"language,omitempty"`
|
||||
// comma separated list of countries to include e.g us,ca
|
||||
Locale string `protobuf:"bytes,2,opt,name=locale,proto3" json:"locale,omitempty"`
|
||||
// date published on in YYYY-MM-DD format
|
||||
Date string `protobuf:"bytes,3,opt,name=date,proto3" json:"date,omitempty"`
|
||||
}
|
||||
|
||||
func (x *HeadlinesRequest) Reset() {
|
||||
*x = HeadlinesRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_news_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *HeadlinesRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*HeadlinesRequest) ProtoMessage() {}
|
||||
|
||||
func (x *HeadlinesRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_news_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use HeadlinesRequest.ProtoReflect.Descriptor instead.
|
||||
func (*HeadlinesRequest) Descriptor() ([]byte, []int) {
|
||||
return file_proto_news_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *HeadlinesRequest) GetLanguage() string {
|
||||
if x != nil {
|
||||
return x.Language
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *HeadlinesRequest) GetLocale() string {
|
||||
if x != nil {
|
||||
return x.Locale
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *HeadlinesRequest) GetDate() string {
|
||||
if x != nil {
|
||||
return x.Date
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type HeadlinesResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Articles []*Article `protobuf:"bytes,1,rep,name=articles,proto3" json:"articles,omitempty"`
|
||||
}
|
||||
|
||||
func (x *HeadlinesResponse) Reset() {
|
||||
*x = HeadlinesResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_news_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *HeadlinesResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*HeadlinesResponse) ProtoMessage() {}
|
||||
|
||||
func (x *HeadlinesResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_news_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use HeadlinesResponse.ProtoReflect.Descriptor instead.
|
||||
func (*HeadlinesResponse) Descriptor() ([]byte, []int) {
|
||||
return file_proto_news_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *HeadlinesResponse) GetArticles() []*Article {
|
||||
if x != nil {
|
||||
return x.Articles
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_proto_news_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_proto_news_proto_rawDesc = []byte{
|
||||
0x0a, 0x10, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6e, 0x65, 0x77, 0x73, 0x2e, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x12, 0x04, 0x6e, 0x65, 0x77, 0x73, 0x22, 0xc5, 0x02, 0x0a, 0x07, 0x41, 0x72, 0x74,
|
||||
0x69, 0x63, 0x6c, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65,
|
||||
0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08,
|
||||
0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08,
|
||||
0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x6e, 0x69, 0x70,
|
||||
0x70, 0x65, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x6e, 0x69, 0x70, 0x70,
|
||||
0x65, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x03, 0x75, 0x72, 0x6c, 0x12, 0x1b, 0x0a, 0x09, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x5f, 0x75, 0x72,
|
||||
0x6c, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x55, 0x72,
|
||||
0x6c, 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x64, 0x5f, 0x61,
|
||||
0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68,
|
||||
0x65, 0x64, 0x41, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x09,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x1e, 0x0a, 0x0a,
|
||||
0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x09,
|
||||
0x52, 0x0a, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x12, 0x1a, 0x0a, 0x08,
|
||||
0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08,
|
||||
0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x6f, 0x63, 0x61,
|
||||
0x6c, 0x65, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x65,
|
||||
0x22, 0x5a, 0x0a, 0x10, 0x48, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x52, 0x65, 0x71,
|
||||
0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65,
|
||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65,
|
||||
0x12, 0x16, 0x0a, 0x06, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x06, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x65,
|
||||
0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x64, 0x61, 0x74, 0x65, 0x22, 0x3e, 0x0a, 0x11,
|
||||
0x48, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
|
||||
0x65, 0x12, 0x29, 0x0a, 0x08, 0x61, 0x72, 0x74, 0x69, 0x63, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20,
|
||||
0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x6e, 0x65, 0x77, 0x73, 0x2e, 0x41, 0x72, 0x74, 0x69, 0x63,
|
||||
0x6c, 0x65, 0x52, 0x08, 0x61, 0x72, 0x74, 0x69, 0x63, 0x6c, 0x65, 0x73, 0x32, 0x46, 0x0a, 0x04,
|
||||
0x4e, 0x65, 0x77, 0x73, 0x12, 0x3e, 0x0a, 0x09, 0x48, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65,
|
||||
0x73, 0x12, 0x16, 0x2e, 0x6e, 0x65, 0x77, 0x73, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e,
|
||||
0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x6e, 0x65, 0x77, 0x73,
|
||||
0x2e, 0x48, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
|
||||
0x73, 0x65, 0x22, 0x00, 0x42, 0x0e, 0x5a, 0x0c, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b,
|
||||
0x6e, 0x65, 0x77, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_proto_news_proto_rawDescOnce sync.Once
|
||||
file_proto_news_proto_rawDescData = file_proto_news_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_proto_news_proto_rawDescGZIP() []byte {
|
||||
file_proto_news_proto_rawDescOnce.Do(func() {
|
||||
file_proto_news_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_news_proto_rawDescData)
|
||||
})
|
||||
return file_proto_news_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_proto_news_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
||||
var file_proto_news_proto_goTypes = []interface{}{
|
||||
(*Article)(nil), // 0: news.Article
|
||||
(*HeadlinesRequest)(nil), // 1: news.HeadlinesRequest
|
||||
(*HeadlinesResponse)(nil), // 2: news.HeadlinesResponse
|
||||
}
|
||||
var file_proto_news_proto_depIdxs = []int32{
|
||||
0, // 0: news.HeadlinesResponse.articles:type_name -> news.Article
|
||||
1, // 1: news.News.Headlines:input_type -> news.HeadlinesRequest
|
||||
2, // 2: news.News.Headlines:output_type -> news.HeadlinesResponse
|
||||
2, // [2:3] is the sub-list for method output_type
|
||||
1, // [1:2] 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_proto_news_proto_init() }
|
||||
func file_proto_news_proto_init() {
|
||||
if File_proto_news_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_proto_news_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Article); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_news_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*HeadlinesRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_news_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*HeadlinesResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_proto_news_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 3,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_proto_news_proto_goTypes,
|
||||
DependencyIndexes: file_proto_news_proto_depIdxs,
|
||||
MessageInfos: file_proto_news_proto_msgTypes,
|
||||
}.Build()
|
||||
File_proto_news_proto = out.File
|
||||
file_proto_news_proto_rawDesc = nil
|
||||
file_proto_news_proto_goTypes = nil
|
||||
file_proto_news_proto_depIdxs = nil
|
||||
}
|
||||
93
news/proto/news.pb.micro.go
Normal file
93
news/proto/news.pb.micro.go
Normal file
@@ -0,0 +1,93 @@
|
||||
// Code generated by protoc-gen-micro. DO NOT EDIT.
|
||||
// source: proto/news.proto
|
||||
|
||||
package news
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
math "math"
|
||||
)
|
||||
|
||||
import (
|
||||
context "context"
|
||||
api "github.com/micro/micro/v3/service/api"
|
||||
client "github.com/micro/micro/v3/service/client"
|
||||
server "github.com/micro/micro/v3/service/server"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ api.Endpoint
|
||||
var _ context.Context
|
||||
var _ client.Option
|
||||
var _ server.Option
|
||||
|
||||
// Api Endpoints for News service
|
||||
|
||||
func NewNewsEndpoints() []*api.Endpoint {
|
||||
return []*api.Endpoint{}
|
||||
}
|
||||
|
||||
// Client API for News service
|
||||
|
||||
type NewsService interface {
|
||||
Headlines(ctx context.Context, in *HeadlinesRequest, opts ...client.CallOption) (*HeadlinesResponse, error)
|
||||
}
|
||||
|
||||
type newsService struct {
|
||||
c client.Client
|
||||
name string
|
||||
}
|
||||
|
||||
func NewNewsService(name string, c client.Client) NewsService {
|
||||
return &newsService{
|
||||
c: c,
|
||||
name: name,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *newsService) Headlines(ctx context.Context, in *HeadlinesRequest, opts ...client.CallOption) (*HeadlinesResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "News.Headlines", in)
|
||||
out := new(HeadlinesResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Server API for News service
|
||||
|
||||
type NewsHandler interface {
|
||||
Headlines(context.Context, *HeadlinesRequest, *HeadlinesResponse) error
|
||||
}
|
||||
|
||||
func RegisterNewsHandler(s server.Server, hdlr NewsHandler, opts ...server.HandlerOption) error {
|
||||
type news interface {
|
||||
Headlines(ctx context.Context, in *HeadlinesRequest, out *HeadlinesResponse) error
|
||||
}
|
||||
type News struct {
|
||||
news
|
||||
}
|
||||
h := &newsHandler{hdlr}
|
||||
return s.Handle(s.NewHandler(&News{h}, opts...))
|
||||
}
|
||||
|
||||
type newsHandler struct {
|
||||
NewsHandler
|
||||
}
|
||||
|
||||
func (h *newsHandler) Headlines(ctx context.Context, in *HeadlinesRequest, out *HeadlinesResponse) error {
|
||||
return h.NewsHandler.Headlines(ctx, in, out)
|
||||
}
|
||||
49
news/proto/news.proto
Normal file
49
news/proto/news.proto
Normal file
@@ -0,0 +1,49 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package news;
|
||||
|
||||
option go_package = "./proto;news";
|
||||
|
||||
service News {
|
||||
rpc Headlines(HeadlinesRequest) returns (HeadlinesResponse) {}
|
||||
}
|
||||
|
||||
message Article {
|
||||
// article id
|
||||
string id = 1;
|
||||
// article title
|
||||
string title = 2;
|
||||
// article description
|
||||
string description = 3;
|
||||
// related keywords
|
||||
string keywords = 4;
|
||||
// first 60 characters of article body
|
||||
string snippet = 5;
|
||||
// url of the article
|
||||
string url = 6;
|
||||
// image url
|
||||
string image_url = 7;
|
||||
// time it was published
|
||||
string published_at = 8;
|
||||
// source of news
|
||||
string source = 9;
|
||||
// categories
|
||||
repeated string categories = 10;
|
||||
// the article language
|
||||
string language = 11;
|
||||
// the locale
|
||||
string locale = 12;
|
||||
}
|
||||
|
||||
message HeadlinesRequest {
|
||||
// comma separated list of languages to retrieve in e.g en,es
|
||||
string language = 1;
|
||||
// comma separated list of countries to include e.g us,ca
|
||||
string locale = 2;
|
||||
// date published on in YYYY-MM-DD format
|
||||
string date = 3;
|
||||
}
|
||||
|
||||
message HeadlinesResponse {
|
||||
repeated Article articles = 1;
|
||||
}
|
||||
Reference in New Issue
Block a user