Autogenerate services.m3o.com (#37)

* Autogenerate services.m3o.com

* Openapi for all

* Gen

* Fix

* Whaat

* Fix dep

* Fix

* Hmm

* Install make

* Debug

* Debug 1

* Location -> locations

* Fix

* Intall protoc gen micro

* F

* F

* F

* Push

* Rename secret

* Fix npm install

* Fix script

* Fix v2

* Ignore errors

* Ignore v2

* F

* F

* F

* Docs index

* Add hugo theme

* Hugo tania fixes

* Change gen

* Change gen 2

* Install hugo

* Change gen

* Gen fix

* Change hugo install

* Change hugo install

* CNAME

* Change articles wording

* Tiny fix

* Fix gen

* Redoc it all

* Fix gen

* Fixing up protos

* Fix proto

* Fix gen

* Fix

* Trigger build

* Fix copy

* Openapi docs

* Flatten

* Changes

* No date vol2

* Changes

* Add make to chat

* Fixes

* Change

* api spec

* replace RSS

* fix link

* Dont continue on error

* increase the width

* use micro at master

* change box colours

* move some things

* Pushing new readmes to see how they look like

* Add skip file

* Readmes

* Nicer api link

* Remove stutter

* FIx mistake

* set service font weight

* Messages readme fix

* add other font bold

* Notes

* Remove post from url

* Revert "Remove post from url"

This reverts commit 5fea2c23d0bafa910f5dc4d4cc63f71f578530e3.

* move exampleSite to site

* replace exampleSite with site

* update readme

* use filename for post

* update index

* Add source urls

* set source as params

* set source as params

* Fix entries

* Generator in go

* Fixes to generator

* F

* Change doc gen

* FIx cname

* Fixing protos

* Change to makefiles

* Fix gen script

Co-authored-by: Asim Aslam <asim@aslam.me>
This commit is contained in:
Janos Dobronszki
2021-01-19 16:59:25 +00:00
committed by GitHub
parent ec81db0753
commit 40b71a9cf9
174 changed files with 10914 additions and 3157 deletions

2
feeds/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
feeds

3
feeds/Dockerfile Normal file
View File

@@ -0,0 +1,3 @@
FROM alpine
ADD feeds /feeds
ENTRYPOINT [ "/feeds" ]

27
feeds/Makefile Normal file
View File

@@ -0,0 +1,27 @@
GOPATH:=$(shell go env GOPATH)
.PHONY: init
init:
go get -u github.com/golang/protobuf/proto
go get -u github.com/golang/protobuf/protoc-gen-go
go get github.com/micro/micro/v3/cmd/protoc-gen-micro
.PHONY: proto
proto:
protoc --openapi_out=. --proto_path=. --micro_out=. --go_out=:. proto/feeds.proto
.PHONY: docs
docs:
protoc --openapi_out=. --proto_path=. --micro_out=. --go_out=:. proto/feeds.proto
@redoc-cli bundle api-feeds.json
.PHONY: build
build:
go build -o feeds *.go
.PHONY: test
test:
go test -v ./... -cover
.PHONY: docker
docker:
docker build . -t feeds:latest

63
feeds/README.md Normal file
View File

@@ -0,0 +1,63 @@
Designed to populate the posts service with RSS feeds from other blogs. Useful for migration or just to get outside content into the posts service.
# Feeds Service
## Creating a feeed
### cURL
```bash
> curl 'https://api.m3o.com/feeds/New' \
-H 'micro-namespace: $yourNamespace' \
-H 'authorization: Bearer $yourToken' \
-d '{"name":"a16z", "url": "http://a16z.com/feed/"}';
{}
```
### CLI
```shell
micro feeds new --name="a16z" --url=http://a16z.com/feed/
```
## Querying feeded posts
```shell
$ micro posts query
{
"posts": [
{
"id": "39cdfbd6e7534bcd868be9eebbf43f8f",
"title": "Anthony Albanese: From the NYSE to Crypto",
"slug": "anthony-albanese-from-the-nyse-to-crypto",
"created": "1605104742",
"updated": "1605105364",
"metadata": {
"domain": "a16z.com",
"link": "https://a16z.com/2020/10/28/anthony-albanese-from-the-nyse-to-crypto/"
}
},
{
"id": "5e9285c01311704e204322ba564cd99e",
"title": "Journal Club: From Insect Eyes to Nanomaterials",
"slug": "journal-club-from-insect-eyes-to-nanomaterials",
"created": "1605104741",
"updated": "1605105363",
"metadata": {
"domain": "a16z.com",
"link": "https://a16z.com/2020/10/29/journal-club-insect-eyes-nanomaterials/"
}
},
]
}
```
```
make proto
```
Run the service
```
micro run .
```

3
feeds/generate.go Normal file
View File

@@ -0,0 +1,3 @@
package main
//go:generate make proto

77
feeds/handler/crawl.go Normal file
View File

@@ -0,0 +1,77 @@
package handler
import (
"context"
"crypto/md5"
"fmt"
"net/url"
"github.com/SlyMarbo/rss"
log "github.com/micro/micro/v3/service/logger"
feeds "github.com/micro/services/feeds/proto"
posts "github.com/micro/services/posts/proto"
)
func (e *Feeds) fetchAll() {
fs := []*feeds.Feed{}
err := e.feeds.List(e.feedsNameIndex.ToQuery(nil), &fs)
if err != nil {
log.Errorf("Error listing feeds: %v", err)
return
}
if len(fs) == 0 {
log.Infof("No feeds to fetch")
return
}
for _, feed := range fs {
err = e.fetch(feed.Url)
if err != nil {
log.Errorf("Error saving post: %v", err)
}
}
}
func (e *Feeds) fetch(url string) error {
log.Infof("Fetching address %v", url)
fd, err := rss.Fetch(url)
if err != nil {
return fmt.Errorf("Error fetching address %v: %v", url, err)
}
domain := getDomain(url)
for _, item := range fd.Items {
id := fmt.Sprintf("%x", md5.Sum([]byte(item.ID)))
err = e.entries.Save(feeds.Entry{
Id: id,
Url: item.Link,
Title: item.Title,
Domain: domain,
Content: item.Summary,
Date: item.Date.Unix(),
})
if err != nil {
return fmt.Errorf("Error saving item: %v", err)
}
// @todo make this optional
_, err := e.postsService.Save(context.TODO(), &posts.SaveRequest{
Id: id,
Title: item.Title,
Content: item.Content,
Timestamp: item.Date.Unix(),
Metadata: map[string]string{
"domain": domain,
"link": item.Link,
},
})
if err != nil {
return err
}
}
return nil
}
func getDomain(address string) string {
uri, _ := url.Parse(address)
return uri.Host
}

93
feeds/handler/feeds.go Normal file
View File

@@ -0,0 +1,93 @@
package handler
import (
"context"
"time"
"github.com/micro/dev/model"
log "github.com/micro/micro/v3/service/logger"
"github.com/micro/micro/v3/service/store"
feeds "github.com/micro/services/feeds/proto"
posts "github.com/micro/services/posts/proto"
)
type Feeds struct {
feeds model.Model
entries model.Model
postsService posts.PostsService
feedsIdIndex model.Index
feedsNameIndex model.Index
entriesDateIndex model.Index
entriesURLIndex model.Index
}
func NewFeeds(postsService posts.PostsService) *Feeds {
idIndex := model.ByEquality("url")
idIndex.Order.Type = model.OrderTypeUnordered
nameIndex := model.ByEquality("name")
nameIndex.Unique = true
nameIndex.Order.Type = model.OrderTypeUnordered
dateIndex := model.ByEquality("date")
dateIndex.Order.Type = model.OrderTypeDesc
entriesURLIndex := model.ByEquality("url")
entriesURLIndex.Order.Type = model.OrderTypeDesc
entriesURLIndex.Order.FieldName = "date"
f := &Feeds{
feeds: model.New(
store.DefaultStore,
"feeds",
model.Indexes(nameIndex),
&model.ModelOptions{
Debug: false,
IdIndex: idIndex,
},
),
entries: model.New(
store.DefaultStore,
"entries",
model.Indexes(dateIndex, entriesURLIndex),
&model.ModelOptions{
Debug: false,
},
),
postsService: postsService,
feedsIdIndex: idIndex,
feedsNameIndex: nameIndex,
entriesDateIndex: dateIndex,
entriesURLIndex: entriesURLIndex,
}
go f.crawl()
return f
}
func (e *Feeds) crawl() {
e.fetchAll()
tick := time.NewTicker(1 * time.Minute)
for _ = range tick.C {
e.fetchAll()
}
}
func (e *Feeds) New(ctx context.Context, req *feeds.NewRequest, rsp *feeds.NewResponse) error {
log.Info("Received Feeds.New request")
e.feeds.Save(feeds.Feed{
Name: req.Name,
Url: req.Url,
})
return nil
}
func (e *Feeds) Entries(ctx context.Context, req *feeds.EntriesRequest, rsp *feeds.EntriesResponse) error {
log.Info("Received Feeds.New request")
err := e.fetch(req.Url)
if err != nil {
return err
}
return e.entries.List(e.entriesURLIndex.ToQuery(req.Url), &rsp.Entries)
}

27
feeds/main.go Normal file
View File

@@ -0,0 +1,27 @@
package main
import (
pb "github.com/micro/services/feeds/proto"
posts "github.com/micro/services/posts/proto"
"github.com/micro/services/feeds/handler"
"github.com/micro/micro/v3/service"
"github.com/micro/micro/v3/service/logger"
)
func main() {
// Create service
srv := service.New(
service.Name("feeds"),
service.Version("latest"),
)
// Register handler
pb.RegisterFeedsHandler(srv.Server(), handler.NewFeeds(posts.NewPostsService("posts", srv.Client())))
// Run service
if err := srv.Run(); err != nil {
logger.Fatal(err)
}
}

1
feeds/micro.mu Normal file
View File

@@ -0,0 +1 @@
service feeds

535
feeds/proto/feeds.pb.go Normal file
View File

@@ -0,0 +1,535 @@
// 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 (
proto "github.com/golang/protobuf/proto"
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)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
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"`
}
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 (*Feed) Descriptor() ([]byte, []int) {
return file_proto_feeds_proto_rawDescGZIP(), []int{0}
}
func (x *Feed) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *Feed) GetUrl() string {
if x != nil {
return x.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"`
}
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 (*Entry) Descriptor() ([]byte, []int) {
return file_proto_feeds_proto_rawDescGZIP(), []int{1}
}
func (x *Entry) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *Entry) GetDomain() string {
if x != nil {
return x.Domain
}
return ""
}
func (x *Entry) GetUrl() string {
if x != nil {
return x.Url
}
return ""
}
func (x *Entry) GetTitle() string {
if x != nil {
return x.Title
}
return ""
}
func (x *Entry) GetContent() string {
if x != nil {
return x.Content
}
return ""
}
func (x *Entry) GetDate() int64 {
if x != nil {
return x.Date
}
return 0
}
type NewRequest 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"`
}
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 (x *NewRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*NewRequest) ProtoMessage() {}
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
}
return ""
}
func (x *NewRequest) GetUrl() string {
if x != nil {
return x.Url
}
return ""
}
type NewResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
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 (x *NewResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
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}
}
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"`
}
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 (*EntriesRequest) Descriptor() ([]byte, []int) {
return file_proto_feeds_proto_rawDescGZIP(), []int{4}
}
func (x *EntriesRequest) GetUrl() string {
if x != nil {
return x.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"`
}
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 (*EntriesResponse) Descriptor() ([]byte, []int) {
return file_proto_feeds_proto_rawDescGZIP(), []int{5}
}
func (x *EntriesResponse) GetEntries() []*Entry {
if x != nil {
return x.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,
}
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
}
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
}
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 init() { file_proto_feeds_proto_init() }
func file_proto_feeds_proto_init() {
if File_proto_feeds_proto != nil {
return
}
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
}

View File

@@ -0,0 +1,110 @@
// Code generated by protoc-gen-micro. DO NOT EDIT.
// source: proto/feeds.proto
package feeds
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 Feeds service
func NewFeedsEndpoints() []*api.Endpoint {
return []*api.Endpoint{}
}
// Client API for Feeds service
type FeedsService interface {
New(ctx context.Context, in *NewRequest, opts ...client.CallOption) (*NewResponse, error)
Entries(ctx context.Context, in *EntriesRequest, opts ...client.CallOption) (*EntriesResponse, error)
}
type feedsService struct {
c client.Client
name string
}
func NewFeedsService(name string, c client.Client) FeedsService {
return &feedsService{
c: c,
name: name,
}
}
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)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *feedsService) Entries(ctx context.Context, in *EntriesRequest, opts ...client.CallOption) (*EntriesResponse, error) {
req := c.c.NewRequest(c.name, "Feeds.Entries", in)
out := new(EntriesResponse)
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
Entries(context.Context, *EntriesRequest, *EntriesResponse) error
}
func RegisterFeedsHandler(s server.Server, hdlr FeedsHandler, opts ...server.HandlerOption) error {
type feeds interface {
New(ctx context.Context, in *NewRequest, out *NewResponse) error
Entries(ctx context.Context, in *EntriesRequest, out *EntriesResponse) error
}
type Feeds struct {
feeds
}
h := &feedsHandler{hdlr}
return s.Handle(s.NewHandler(&Feeds{h}, opts...))
}
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) Entries(ctx context.Context, in *EntriesRequest, out *EntriesResponse) error {
return h.FeedsHandler.Entries(ctx, in, out)
}

50
feeds/proto/feeds.proto Normal file
View File

@@ -0,0 +1,50 @@
syntax = "proto3";
package feeds;
option go_package = "proto;feeds";
service Feeds {
rpc New(NewRequest) returns (NewResponse) {}
rpc Entries(EntriesRequest) returns (EntriesResponse) {}
}
message Feed {
// rss feed name
// eg. a16z
string name = 1;
// rss feed url
// eg. http://a16z.com/feed/
string url = 2;
}
message Entry {
string id = 1;
string domain = 2;
string url = 3;
string title = 4;
string content = 5;
int64 date = 6;
}
message NewRequest {
// rss feed name
// eg. a16z
string name = 1;
// rss feed url
// eg. http://a16z.com/feed/
string url = 2;
}
message NewResponse {
}
message EntriesRequest {
// rss feed url
// eg. http://a16z.com/feed/
string url = 1;
}
message EntriesResponse {
repeated Entry entries = 1;
}