add further accessor methods to feeds (#51)

This commit is contained in:
Asim Aslam
2021-01-27 20:04:48 +00:00
committed by GitHub
parent 78f9ad4422
commit 9e7d7b7e34
4 changed files with 466 additions and 430 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"time"
"github.com/micro/micro/v3/service/errors"
log "github.com/micro/micro/v3/service/logger"
"github.com/micro/micro/v3/service/model"
@@ -69,7 +70,7 @@ func (e *Feeds) crawl() {
}
}
func (e *Feeds) New(ctx context.Context, req *feeds.NewRequest, rsp *feeds.NewResponse) error {
func (e *Feeds) Add(ctx context.Context, req *feeds.AddRequest, rsp *feeds.AddResponse) error {
log.Info("Received Feeds.New request")
e.feeds.Create(feeds.Feed{
Name: req.Name,
@@ -86,3 +87,24 @@ func (e *Feeds) Entries(ctx context.Context, req *feeds.EntriesRequest, rsp *fee
}
return e.entries.Read(e.entriesURLIndex.ToQuery(req.Url), &rsp.Entries)
}
func (e *Feeds) List(ctx context.Context, req *feeds.ListRequest, rsp *feeds.ListResponse) error {
var feeds []*feeds.Feed
err := e.feeds.Read(model.QueryAll(), &feeds)
if err != nil {
return errors.InternalServerError("feeds.list", "failed to read list of feeds: %v", err)
}
rsp.Feeds = feeds
return nil
}
func (e *Feeds) Remove(ctx context.Context, req *feeds.RemoveRequest, rsp *feeds.RemoveResponse) error {
if len(req.Name) == 0 {
return errors.BadRequest("feeds.remove", "blank name provided")
}
e.feeds.Delete(model.QueryEquals("name", req.Name))
return nil
}

View File

@@ -1,535 +1,497 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.6.1
// source: proto/feeds.proto
package feeds
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
math "math"
)
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)
)
// 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 that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
type Feed struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// rss feed name
// eg. a16z
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
// rss feed url
// eg. http://a16z.com/feed/
Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"`
Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (x *Feed) Reset() {
*x = Feed{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_feeds_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Feed) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Feed) ProtoMessage() {}
func (x *Feed) ProtoReflect() protoreflect.Message {
mi := &file_proto_feeds_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 Feed.ProtoReflect.Descriptor instead.
func (m *Feed) Reset() { *m = Feed{} }
func (m *Feed) String() string { return proto.CompactTextString(m) }
func (*Feed) ProtoMessage() {}
func (*Feed) Descriptor() ([]byte, []int) {
return file_proto_feeds_proto_rawDescGZIP(), []int{0}
return fileDescriptor_dd517c38176c13bf, []int{0}
}
func (x *Feed) GetName() string {
if x != nil {
return x.Name
func (m *Feed) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Feed.Unmarshal(m, b)
}
func (m *Feed) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Feed.Marshal(b, m, deterministic)
}
func (m *Feed) XXX_Merge(src proto.Message) {
xxx_messageInfo_Feed.Merge(m, src)
}
func (m *Feed) XXX_Size() int {
return xxx_messageInfo_Feed.Size(m)
}
func (m *Feed) XXX_DiscardUnknown() {
xxx_messageInfo_Feed.DiscardUnknown(m)
}
var xxx_messageInfo_Feed proto.InternalMessageInfo
func (m *Feed) GetName() string {
if m != nil {
return m.Name
}
return ""
}
func (x *Feed) GetUrl() string {
if x != nil {
return x.Url
func (m *Feed) GetUrl() string {
if m != nil {
return m.Url
}
return ""
}
type Entry struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Domain string `protobuf:"bytes,2,opt,name=domain,proto3" json:"domain,omitempty"`
Url string `protobuf:"bytes,3,opt,name=url,proto3" json:"url,omitempty"`
Title string `protobuf:"bytes,4,opt,name=title,proto3" json:"title,omitempty"`
Content string `protobuf:"bytes,5,opt,name=content,proto3" json:"content,omitempty"`
Date int64 `protobuf:"varint,6,opt,name=date,proto3" json:"date,omitempty"`
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Domain string `protobuf:"bytes,2,opt,name=domain,proto3" json:"domain,omitempty"`
Url string `protobuf:"bytes,3,opt,name=url,proto3" json:"url,omitempty"`
Title string `protobuf:"bytes,4,opt,name=title,proto3" json:"title,omitempty"`
Content string `protobuf:"bytes,5,opt,name=content,proto3" json:"content,omitempty"`
Date int64 `protobuf:"varint,6,opt,name=date,proto3" json:"date,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (x *Entry) Reset() {
*x = Entry{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_feeds_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Entry) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Entry) ProtoMessage() {}
func (x *Entry) ProtoReflect() protoreflect.Message {
mi := &file_proto_feeds_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 Entry.ProtoReflect.Descriptor instead.
func (m *Entry) Reset() { *m = Entry{} }
func (m *Entry) String() string { return proto.CompactTextString(m) }
func (*Entry) ProtoMessage() {}
func (*Entry) Descriptor() ([]byte, []int) {
return file_proto_feeds_proto_rawDescGZIP(), []int{1}
return fileDescriptor_dd517c38176c13bf, []int{1}
}
func (x *Entry) GetId() string {
if x != nil {
return x.Id
func (m *Entry) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Entry.Unmarshal(m, b)
}
func (m *Entry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Entry.Marshal(b, m, deterministic)
}
func (m *Entry) XXX_Merge(src proto.Message) {
xxx_messageInfo_Entry.Merge(m, src)
}
func (m *Entry) XXX_Size() int {
return xxx_messageInfo_Entry.Size(m)
}
func (m *Entry) XXX_DiscardUnknown() {
xxx_messageInfo_Entry.DiscardUnknown(m)
}
var xxx_messageInfo_Entry proto.InternalMessageInfo
func (m *Entry) GetId() string {
if m != nil {
return m.Id
}
return ""
}
func (x *Entry) GetDomain() string {
if x != nil {
return x.Domain
func (m *Entry) GetDomain() string {
if m != nil {
return m.Domain
}
return ""
}
func (x *Entry) GetUrl() string {
if x != nil {
return x.Url
func (m *Entry) GetUrl() string {
if m != nil {
return m.Url
}
return ""
}
func (x *Entry) GetTitle() string {
if x != nil {
return x.Title
func (m *Entry) GetTitle() string {
if m != nil {
return m.Title
}
return ""
}
func (x *Entry) GetContent() string {
if x != nil {
return x.Content
func (m *Entry) GetContent() string {
if m != nil {
return m.Content
}
return ""
}
func (x *Entry) GetDate() int64 {
if x != nil {
return x.Date
func (m *Entry) GetDate() int64 {
if m != nil {
return m.Date
}
return 0
}
type NewRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
type AddRequest struct {
// rss feed name
// eg. a16z
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
// rss feed url
// eg. http://a16z.com/feed/
Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"`
Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (x *NewRequest) Reset() {
*x = NewRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_feeds_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (m *AddRequest) Reset() { *m = AddRequest{} }
func (m *AddRequest) String() string { return proto.CompactTextString(m) }
func (*AddRequest) ProtoMessage() {}
func (*AddRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_dd517c38176c13bf, []int{2}
}
func (x *NewRequest) String() string {
return protoimpl.X.MessageStringOf(x)
func (m *AddRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_AddRequest.Unmarshal(m, b)
}
func (m *AddRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_AddRequest.Marshal(b, m, deterministic)
}
func (m *AddRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_AddRequest.Merge(m, src)
}
func (m *AddRequest) XXX_Size() int {
return xxx_messageInfo_AddRequest.Size(m)
}
func (m *AddRequest) XXX_DiscardUnknown() {
xxx_messageInfo_AddRequest.DiscardUnknown(m)
}
func (*NewRequest) ProtoMessage() {}
var xxx_messageInfo_AddRequest proto.InternalMessageInfo
func (x *NewRequest) ProtoReflect() protoreflect.Message {
mi := &file_proto_feeds_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 NewRequest.ProtoReflect.Descriptor instead.
func (*NewRequest) Descriptor() ([]byte, []int) {
return file_proto_feeds_proto_rawDescGZIP(), []int{2}
}
func (x *NewRequest) GetName() string {
if x != nil {
return x.Name
func (m *AddRequest) GetName() string {
if m != nil {
return m.Name
}
return ""
}
func (x *NewRequest) GetUrl() string {
if x != nil {
return x.Url
func (m *AddRequest) GetUrl() string {
if m != nil {
return m.Url
}
return ""
}
type NewResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
type AddResponse struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (x *NewResponse) Reset() {
*x = NewResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_feeds_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (m *AddResponse) Reset() { *m = AddResponse{} }
func (m *AddResponse) String() string { return proto.CompactTextString(m) }
func (*AddResponse) ProtoMessage() {}
func (*AddResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_dd517c38176c13bf, []int{3}
}
func (x *NewResponse) String() string {
return protoimpl.X.MessageStringOf(x)
func (m *AddResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_AddResponse.Unmarshal(m, b)
}
func (m *AddResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_AddResponse.Marshal(b, m, deterministic)
}
func (m *AddResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_AddResponse.Merge(m, src)
}
func (m *AddResponse) XXX_Size() int {
return xxx_messageInfo_AddResponse.Size(m)
}
func (m *AddResponse) XXX_DiscardUnknown() {
xxx_messageInfo_AddResponse.DiscardUnknown(m)
}
func (*NewResponse) ProtoMessage() {}
func (x *NewResponse) ProtoReflect() protoreflect.Message {
mi := &file_proto_feeds_proto_msgTypes[3]
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 NewResponse.ProtoReflect.Descriptor instead.
func (*NewResponse) Descriptor() ([]byte, []int) {
return file_proto_feeds_proto_rawDescGZIP(), []int{3}
}
var xxx_messageInfo_AddResponse proto.InternalMessageInfo
type EntriesRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// rss feed url
// eg. http://a16z.com/feed/
Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"`
Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (x *EntriesRequest) Reset() {
*x = EntriesRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_feeds_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *EntriesRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*EntriesRequest) ProtoMessage() {}
func (x *EntriesRequest) ProtoReflect() protoreflect.Message {
mi := &file_proto_feeds_proto_msgTypes[4]
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 EntriesRequest.ProtoReflect.Descriptor instead.
func (m *EntriesRequest) Reset() { *m = EntriesRequest{} }
func (m *EntriesRequest) String() string { return proto.CompactTextString(m) }
func (*EntriesRequest) ProtoMessage() {}
func (*EntriesRequest) Descriptor() ([]byte, []int) {
return file_proto_feeds_proto_rawDescGZIP(), []int{4}
return fileDescriptor_dd517c38176c13bf, []int{4}
}
func (x *EntriesRequest) GetUrl() string {
if x != nil {
return x.Url
func (m *EntriesRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_EntriesRequest.Unmarshal(m, b)
}
func (m *EntriesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_EntriesRequest.Marshal(b, m, deterministic)
}
func (m *EntriesRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_EntriesRequest.Merge(m, src)
}
func (m *EntriesRequest) XXX_Size() int {
return xxx_messageInfo_EntriesRequest.Size(m)
}
func (m *EntriesRequest) XXX_DiscardUnknown() {
xxx_messageInfo_EntriesRequest.DiscardUnknown(m)
}
var xxx_messageInfo_EntriesRequest proto.InternalMessageInfo
func (m *EntriesRequest) GetUrl() string {
if m != nil {
return m.Url
}
return ""
}
type EntriesResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Entries []*Entry `protobuf:"bytes,1,rep,name=entries,proto3" json:"entries,omitempty"`
Entries []*Entry `protobuf:"bytes,1,rep,name=entries,proto3" json:"entries,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (x *EntriesResponse) Reset() {
*x = EntriesResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_feeds_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *EntriesResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*EntriesResponse) ProtoMessage() {}
func (x *EntriesResponse) ProtoReflect() protoreflect.Message {
mi := &file_proto_feeds_proto_msgTypes[5]
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 EntriesResponse.ProtoReflect.Descriptor instead.
func (m *EntriesResponse) Reset() { *m = EntriesResponse{} }
func (m *EntriesResponse) String() string { return proto.CompactTextString(m) }
func (*EntriesResponse) ProtoMessage() {}
func (*EntriesResponse) Descriptor() ([]byte, []int) {
return file_proto_feeds_proto_rawDescGZIP(), []int{5}
return fileDescriptor_dd517c38176c13bf, []int{5}
}
func (x *EntriesResponse) GetEntries() []*Entry {
if x != nil {
return x.Entries
func (m *EntriesResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_EntriesResponse.Unmarshal(m, b)
}
func (m *EntriesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_EntriesResponse.Marshal(b, m, deterministic)
}
func (m *EntriesResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_EntriesResponse.Merge(m, src)
}
func (m *EntriesResponse) XXX_Size() int {
return xxx_messageInfo_EntriesResponse.Size(m)
}
func (m *EntriesResponse) XXX_DiscardUnknown() {
xxx_messageInfo_EntriesResponse.DiscardUnknown(m)
}
var xxx_messageInfo_EntriesResponse proto.InternalMessageInfo
func (m *EntriesResponse) GetEntries() []*Entry {
if m != nil {
return m.Entries
}
return nil
}
var File_proto_feeds_proto protoreflect.FileDescriptor
var file_proto_feeds_proto_rawDesc = []byte{
0x0a, 0x11, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x66, 0x65, 0x65, 0x64, 0x73, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x12, 0x05, 0x66, 0x65, 0x65, 0x64, 0x73, 0x22, 0x2c, 0x0a, 0x04, 0x46, 0x65,
0x65, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x02, 0x20,
0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x22, 0x85, 0x01, 0x0a, 0x05, 0x45, 0x6e, 0x74,
0x72, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02,
0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01,
0x28, 0x09, 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72,
0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x14, 0x0a, 0x05,
0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74,
0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x05, 0x20,
0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04,
0x64, 0x61, 0x74, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x64, 0x61, 0x74, 0x65,
0x22, 0x32, 0x0a, 0x0a, 0x4e, 0x65, 0x77, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12,
0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61,
0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x03, 0x75, 0x72, 0x6c, 0x22, 0x0d, 0x0a, 0x0b, 0x4e, 0x65, 0x77, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x22, 0x22, 0x0a, 0x0e, 0x45, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x22, 0x39, 0x0a, 0x0f, 0x45, 0x6e, 0x74, 0x72, 0x69,
0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x07, 0x65, 0x6e,
0x74, 0x72, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x66, 0x65,
0x65, 0x64, 0x73, 0x2e, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x65, 0x6e, 0x74, 0x72, 0x69,
0x65, 0x73, 0x32, 0x73, 0x0a, 0x05, 0x46, 0x65, 0x65, 0x64, 0x73, 0x12, 0x2e, 0x0a, 0x03, 0x4e,
0x65, 0x77, 0x12, 0x11, 0x2e, 0x66, 0x65, 0x65, 0x64, 0x73, 0x2e, 0x4e, 0x65, 0x77, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x66, 0x65, 0x65, 0x64, 0x73, 0x2e, 0x4e, 0x65,
0x77, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3a, 0x0a, 0x07, 0x45,
0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x12, 0x15, 0x2e, 0x66, 0x65, 0x65, 0x64, 0x73, 0x2e, 0x45,
0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e,
0x66, 0x65, 0x65, 0x64, 0x73, 0x2e, 0x45, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x0d, 0x5a, 0x0b, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x3b, 0x66, 0x65, 0x65, 0x64, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
type ListRequest struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
var (
file_proto_feeds_proto_rawDescOnce sync.Once
file_proto_feeds_proto_rawDescData = file_proto_feeds_proto_rawDesc
)
func file_proto_feeds_proto_rawDescGZIP() []byte {
file_proto_feeds_proto_rawDescOnce.Do(func() {
file_proto_feeds_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_feeds_proto_rawDescData)
})
return file_proto_feeds_proto_rawDescData
func (m *ListRequest) Reset() { *m = ListRequest{} }
func (m *ListRequest) String() string { return proto.CompactTextString(m) }
func (*ListRequest) ProtoMessage() {}
func (*ListRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_dd517c38176c13bf, []int{6}
}
var file_proto_feeds_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_proto_feeds_proto_goTypes = []interface{}{
(*Feed)(nil), // 0: feeds.Feed
(*Entry)(nil), // 1: feeds.Entry
(*NewRequest)(nil), // 2: feeds.NewRequest
(*NewResponse)(nil), // 3: feeds.NewResponse
(*EntriesRequest)(nil), // 4: feeds.EntriesRequest
(*EntriesResponse)(nil), // 5: feeds.EntriesResponse
func (m *ListRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ListRequest.Unmarshal(m, b)
}
var file_proto_feeds_proto_depIdxs = []int32{
1, // 0: feeds.EntriesResponse.entries:type_name -> feeds.Entry
2, // 1: feeds.Feeds.New:input_type -> feeds.NewRequest
4, // 2: feeds.Feeds.Entries:input_type -> feeds.EntriesRequest
3, // 3: feeds.Feeds.New:output_type -> feeds.NewResponse
5, // 4: feeds.Feeds.Entries:output_type -> feeds.EntriesResponse
3, // [3:5] is the sub-list for method output_type
1, // [1:3] 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 (m *ListRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ListRequest.Marshal(b, m, deterministic)
}
func (m *ListRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_ListRequest.Merge(m, src)
}
func (m *ListRequest) XXX_Size() int {
return xxx_messageInfo_ListRequest.Size(m)
}
func (m *ListRequest) XXX_DiscardUnknown() {
xxx_messageInfo_ListRequest.DiscardUnknown(m)
}
func init() { file_proto_feeds_proto_init() }
func file_proto_feeds_proto_init() {
if File_proto_feeds_proto != nil {
return
var xxx_messageInfo_ListRequest proto.InternalMessageInfo
type ListResponse struct {
Feeds []*Feed `protobuf:"bytes,1,rep,name=feeds,proto3" json:"feeds,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ListResponse) Reset() { *m = ListResponse{} }
func (m *ListResponse) String() string { return proto.CompactTextString(m) }
func (*ListResponse) ProtoMessage() {}
func (*ListResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_dd517c38176c13bf, []int{7}
}
func (m *ListResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ListResponse.Unmarshal(m, b)
}
func (m *ListResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ListResponse.Marshal(b, m, deterministic)
}
func (m *ListResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_ListResponse.Merge(m, src)
}
func (m *ListResponse) XXX_Size() int {
return xxx_messageInfo_ListResponse.Size(m)
}
func (m *ListResponse) XXX_DiscardUnknown() {
xxx_messageInfo_ListResponse.DiscardUnknown(m)
}
var xxx_messageInfo_ListResponse proto.InternalMessageInfo
func (m *ListResponse) GetFeeds() []*Feed {
if m != nil {
return m.Feeds
}
if !protoimpl.UnsafeEnabled {
file_proto_feeds_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Feed); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_feeds_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Entry); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_feeds_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*NewRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_feeds_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*NewResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_feeds_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*EntriesRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_feeds_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*EntriesResponse); 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_feeds_proto_rawDesc,
NumEnums: 0,
NumMessages: 6,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_proto_feeds_proto_goTypes,
DependencyIndexes: file_proto_feeds_proto_depIdxs,
MessageInfos: file_proto_feeds_proto_msgTypes,
}.Build()
File_proto_feeds_proto = out.File
file_proto_feeds_proto_rawDesc = nil
file_proto_feeds_proto_goTypes = nil
file_proto_feeds_proto_depIdxs = nil
return nil
}
type RemoveRequest struct {
// rss feed name
// eg. a16z
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *RemoveRequest) Reset() { *m = RemoveRequest{} }
func (m *RemoveRequest) String() string { return proto.CompactTextString(m) }
func (*RemoveRequest) ProtoMessage() {}
func (*RemoveRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_dd517c38176c13bf, []int{8}
}
func (m *RemoveRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_RemoveRequest.Unmarshal(m, b)
}
func (m *RemoveRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_RemoveRequest.Marshal(b, m, deterministic)
}
func (m *RemoveRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_RemoveRequest.Merge(m, src)
}
func (m *RemoveRequest) XXX_Size() int {
return xxx_messageInfo_RemoveRequest.Size(m)
}
func (m *RemoveRequest) XXX_DiscardUnknown() {
xxx_messageInfo_RemoveRequest.DiscardUnknown(m)
}
var xxx_messageInfo_RemoveRequest proto.InternalMessageInfo
func (m *RemoveRequest) GetName() string {
if m != nil {
return m.Name
}
return ""
}
type RemoveResponse struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *RemoveResponse) Reset() { *m = RemoveResponse{} }
func (m *RemoveResponse) String() string { return proto.CompactTextString(m) }
func (*RemoveResponse) ProtoMessage() {}
func (*RemoveResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_dd517c38176c13bf, []int{9}
}
func (m *RemoveResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_RemoveResponse.Unmarshal(m, b)
}
func (m *RemoveResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_RemoveResponse.Marshal(b, m, deterministic)
}
func (m *RemoveResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_RemoveResponse.Merge(m, src)
}
func (m *RemoveResponse) XXX_Size() int {
return xxx_messageInfo_RemoveResponse.Size(m)
}
func (m *RemoveResponse) XXX_DiscardUnknown() {
xxx_messageInfo_RemoveResponse.DiscardUnknown(m)
}
var xxx_messageInfo_RemoveResponse proto.InternalMessageInfo
func init() {
proto.RegisterType((*Feed)(nil), "feeds.Feed")
proto.RegisterType((*Entry)(nil), "feeds.Entry")
proto.RegisterType((*AddRequest)(nil), "feeds.AddRequest")
proto.RegisterType((*AddResponse)(nil), "feeds.AddResponse")
proto.RegisterType((*EntriesRequest)(nil), "feeds.EntriesRequest")
proto.RegisterType((*EntriesResponse)(nil), "feeds.EntriesResponse")
proto.RegisterType((*ListRequest)(nil), "feeds.ListRequest")
proto.RegisterType((*ListResponse)(nil), "feeds.ListResponse")
proto.RegisterType((*RemoveRequest)(nil), "feeds.RemoveRequest")
proto.RegisterType((*RemoveResponse)(nil), "feeds.RemoveResponse")
}
func init() { proto.RegisterFile("proto/feeds.proto", fileDescriptor_dd517c38176c13bf) }
var fileDescriptor_dd517c38176c13bf = []byte{
// 363 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0xcb, 0x4e, 0x2a, 0x41,
0x10, 0xbd, 0xc3, 0x3c, 0xc8, 0xad, 0x01, 0x2e, 0xd4, 0x05, 0xd2, 0x99, 0x15, 0xb6, 0x89, 0x61,
0x61, 0x30, 0xe0, 0xc2, 0xa8, 0x2b, 0x4c, 0x74, 0xe5, 0x6a, 0x96, 0xee, 0xd0, 0x2e, 0x93, 0x49,
0x60, 0x06, 0xe9, 0xc6, 0xc4, 0x0f, 0xf0, 0x3b, 0xfd, 0x15, 0xd3, 0xaf, 0xe1, 0xb1, 0x30, 0xee,
0xea, 0x9c, 0xaa, 0x73, 0xba, 0xfa, 0x74, 0x43, 0x6f, 0xbd, 0xa9, 0x54, 0x75, 0xf1, 0x4a, 0x24,
0xe4, 0xc4, 0xd4, 0x18, 0x1b, 0xc0, 0xcf, 0x21, 0x7a, 0x20, 0x12, 0x88, 0x10, 0x95, 0x8b, 0x15,
0xb1, 0x60, 0x14, 0x8c, 0xff, 0xe6, 0xa6, 0xc6, 0x2e, 0x84, 0xdb, 0xcd, 0x92, 0x35, 0x0c, 0xa5,
0x4b, 0xfe, 0x19, 0x40, 0x7c, 0x5f, 0xaa, 0xcd, 0x07, 0x76, 0xa0, 0x51, 0x08, 0x37, 0xdd, 0x28,
0x04, 0x0e, 0x21, 0x11, 0xd5, 0x6a, 0x51, 0x94, 0x6e, 0xdc, 0x21, 0xef, 0x11, 0xd6, 0x1e, 0xd8,
0x87, 0x58, 0x15, 0x6a, 0x49, 0x2c, 0x32, 0x9c, 0x05, 0xc8, 0xa0, 0xf9, 0x52, 0x95, 0x8a, 0x4a,
0xc5, 0x62, 0xc3, 0x7b, 0xa8, 0x37, 0x13, 0x0b, 0x45, 0x2c, 0x19, 0x05, 0xe3, 0x30, 0x37, 0x35,
0x9f, 0x01, 0xcc, 0x85, 0xc8, 0xe9, 0x6d, 0x4b, 0x52, 0xfd, 0x72, 0xf7, 0x36, 0xa4, 0x46, 0x23,
0xd7, 0x55, 0x29, 0x89, 0x73, 0xe8, 0xe8, 0x9b, 0x14, 0x24, 0xbd, 0x8d, 0x93, 0x04, 0x3b, 0xc9,
0x35, 0xfc, 0xab, 0x67, 0xac, 0x0c, 0xcf, 0xa0, 0x49, 0x96, 0x62, 0xc1, 0x28, 0x1c, 0xa7, 0xb3,
0xd6, 0xc4, 0xa6, 0x6a, 0x62, 0xc9, 0x7d, 0x53, 0x9f, 0xf6, 0x58, 0x48, 0xe5, 0xbc, 0xf9, 0x14,
0x5a, 0x16, 0x3a, 0x9b, 0x13, 0xb0, 0xf9, 0x3b, 0x93, 0xd4, 0x99, 0xe8, 0xa7, 0xc8, 0xdd, 0xcb,
0x9c, 0x42, 0x3b, 0xa7, 0x55, 0xf5, 0x4e, 0x3f, 0x5c, 0x93, 0x77, 0xa1, 0xe3, 0x87, 0xac, 0xf3,
0xec, 0x2b, 0x80, 0x58, 0xdb, 0x48, 0x9c, 0x40, 0x38, 0x17, 0x02, 0x7b, 0xce, 0x7b, 0x17, 0x58,
0x86, 0xfb, 0x94, 0xcb, 0xe3, 0x0f, 0x5e, 0x41, 0x62, 0xbd, 0xb0, 0xef, 0xfa, 0x07, 0xe7, 0x67,
0x83, 0x23, 0xb6, 0x16, 0xde, 0x40, 0xd3, 0xc5, 0x84, 0x83, 0xbd, 0x34, 0x76, 0xd1, 0x66, 0xc3,
0x63, 0xba, 0xd6, 0x4e, 0x21, 0xd2, 0xc1, 0xa0, 0x5f, 0x69, 0x2f, 0xb4, 0xec, 0xff, 0x01, 0xe7,
0x25, 0x77, 0xed, 0xa7, 0xd4, 0x7c, 0xe1, 0x5b, 0xd3, 0x7d, 0x4e, 0x0c, 0xb8, 0xfc, 0x0e, 0x00,
0x00, 0xff, 0xff, 0x30, 0x85, 0x1a, 0xbb, 0xe4, 0x02, 0x00, 0x00,
}

View File

@@ -42,8 +42,10 @@ func NewFeedsEndpoints() []*api.Endpoint {
// Client API for Feeds service
type FeedsService interface {
New(ctx context.Context, in *NewRequest, opts ...client.CallOption) (*NewResponse, error)
Add(ctx context.Context, in *AddRequest, opts ...client.CallOption) (*AddResponse, error)
Remove(ctx context.Context, in *RemoveRequest, opts ...client.CallOption) (*RemoveResponse, error)
Entries(ctx context.Context, in *EntriesRequest, opts ...client.CallOption) (*EntriesResponse, error)
List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error)
}
type feedsService struct {
@@ -58,9 +60,19 @@ func NewFeedsService(name string, c client.Client) FeedsService {
}
}
func (c *feedsService) New(ctx context.Context, in *NewRequest, opts ...client.CallOption) (*NewResponse, error) {
req := c.c.NewRequest(c.name, "Feeds.New", in)
out := new(NewResponse)
func (c *feedsService) Add(ctx context.Context, in *AddRequest, opts ...client.CallOption) (*AddResponse, error) {
req := c.c.NewRequest(c.name, "Feeds.Add", in)
out := new(AddResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *feedsService) Remove(ctx context.Context, in *RemoveRequest, opts ...client.CallOption) (*RemoveResponse, error) {
req := c.c.NewRequest(c.name, "Feeds.Remove", in)
out := new(RemoveResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
@@ -78,17 +90,31 @@ func (c *feedsService) Entries(ctx context.Context, in *EntriesRequest, opts ...
return out, nil
}
func (c *feedsService) List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error) {
req := c.c.NewRequest(c.name, "Feeds.List", in)
out := new(ListResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// Server API for Feeds service
type FeedsHandler interface {
New(context.Context, *NewRequest, *NewResponse) error
Add(context.Context, *AddRequest, *AddResponse) error
Remove(context.Context, *RemoveRequest, *RemoveResponse) error
Entries(context.Context, *EntriesRequest, *EntriesResponse) error
List(context.Context, *ListRequest, *ListResponse) error
}
func RegisterFeedsHandler(s server.Server, hdlr FeedsHandler, opts ...server.HandlerOption) error {
type feeds interface {
New(ctx context.Context, in *NewRequest, out *NewResponse) error
Add(ctx context.Context, in *AddRequest, out *AddResponse) error
Remove(ctx context.Context, in *RemoveRequest, out *RemoveResponse) error
Entries(ctx context.Context, in *EntriesRequest, out *EntriesResponse) error
List(ctx context.Context, in *ListRequest, out *ListResponse) error
}
type Feeds struct {
feeds
@@ -101,10 +127,18 @@ type feedsHandler struct {
FeedsHandler
}
func (h *feedsHandler) New(ctx context.Context, in *NewRequest, out *NewResponse) error {
return h.FeedsHandler.New(ctx, in, out)
func (h *feedsHandler) Add(ctx context.Context, in *AddRequest, out *AddResponse) error {
return h.FeedsHandler.Add(ctx, in, out)
}
func (h *feedsHandler) Remove(ctx context.Context, in *RemoveRequest, out *RemoveResponse) error {
return h.FeedsHandler.Remove(ctx, in, out)
}
func (h *feedsHandler) Entries(ctx context.Context, in *EntriesRequest, out *EntriesResponse) error {
return h.FeedsHandler.Entries(ctx, in, out)
}
func (h *feedsHandler) List(ctx context.Context, in *ListRequest, out *ListResponse) error {
return h.FeedsHandler.List(ctx, in, out)
}

View File

@@ -5,8 +5,10 @@ package feeds;
option go_package = "proto;feeds";
service Feeds {
rpc New(NewRequest) returns (NewResponse) {}
rpc Add(AddRequest) returns (AddResponse) {}
rpc Remove(RemoveRequest) returns (RemoveResponse) {}
rpc Entries(EntriesRequest) returns (EntriesResponse) {}
rpc List(ListRequest) returns (ListResponse) {}
}
message Feed {
@@ -27,7 +29,7 @@ message Entry {
int64 date = 6;
}
message NewRequest {
message AddRequest {
// rss feed name
// eg. a16z
string name = 1;
@@ -36,7 +38,7 @@ message NewRequest {
string url = 2;
}
message NewResponse {
message AddResponse {
}
message EntriesRequest {
@@ -47,4 +49,20 @@ message EntriesRequest {
message EntriesResponse {
repeated Entry entries = 1;
}
}
message ListRequest {}
message ListResponse {
repeated Feed feeds = 1;
}
message RemoveRequest {
// rss feed name
// eg. a16z
string name = 1;
}
message RemoveResponse {
}