Rename address to url (#27)

This commit is contained in:
Asim Aslam
2020-11-13 14:04:26 +00:00
committed by GitHub
parent e369086903
commit 2b534c55ed
6 changed files with 36 additions and 37 deletions

View File

@@ -12,7 +12,7 @@ micro new feeds
```
micro feeds new --name="az" --address=http://a16z.com/feed/
micro feeds new --name="a16z" --url=http://a16z.com/feed/
```
```
@@ -53,4 +53,4 @@ Run the service
```
micro run .
```
```

View File

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

View File

@@ -25,13 +25,13 @@ func (e *Feeds) fetchAll() {
return
}
for _, feed := range fs {
log.Infof("Fetching address %v", feed.Address)
fd, err := rss.Fetch(feed.Address)
log.Infof("Fetching address %v", feed.Url)
fd, err := rss.Fetch(feed.Url)
if err != nil {
log.Errorf("Error fetching address %v: %v", feed.Address, err)
log.Errorf("Error fetching address %v: %v", feed.Url, err)
continue
}
domain := getDomain(feed.Address)
domain := getDomain(feed.Url)
for _, item := range fd.Items {
id := fmt.Sprintf("%x", md5.Sum([]byte(item.ID)))

View File

@@ -71,8 +71,8 @@ func (e *Feeds) crawl() {
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,
Address: req.Address,
Name: req.Name,
Url: req.Url,
})
return nil
}

View File

@@ -23,8 +23,8 @@ const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
type Feed struct {
// rss feed name
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
// rss feed address
Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"`
// rss feed url
Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@@ -62,9 +62,9 @@ func (m *Feed) GetName() string {
return ""
}
func (m *Feed) GetAddress() string {
func (m *Feed) GetUrl() string {
if m != nil {
return m.Address
return m.Url
}
return ""
}
@@ -150,7 +150,7 @@ func (m *Entry) GetDate() int64 {
type NewRequest struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,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:"-"`
@@ -188,9 +188,9 @@ func (m *NewRequest) GetName() string {
return ""
}
func (m *NewRequest) GetAddress() string {
func (m *NewRequest) GetUrl() string {
if m != nil {
return m.Address
return m.Url
}
return ""
}
@@ -233,25 +233,23 @@ func init() {
proto.RegisterType((*NewResponse)(nil), "feeds.NewResponse")
}
func init() {
proto.RegisterFile("proto/feeds.proto", fileDescriptor_dd517c38176c13bf)
}
func init() { proto.RegisterFile("proto/feeds.proto", fileDescriptor_dd517c38176c13bf) }
var fileDescriptor_dd517c38176c13bf = []byte{
// 235 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x94, 0x90, 0xb1, 0x4a, 0x04, 0x31,
0x10, 0x86, 0xdd, 0xdb, 0xcd, 0x8a, 0x73, 0x9c, 0x78, 0x83, 0x48, 0xb0, 0x92, 0xad, 0xac, 0x56,
0x50, 0x41, 0xd0, 0x4e, 0xd0, 0xd2, 0x62, 0x4b, 0xbb, 0xd5, 0x8c, 0xb0, 0x70, 0x97, 0x9c, 0xc9,
0x2c, 0xe2, 0x03, 0xf8, 0xde, 0x26, 0x93, 0x88, 0xb6, 0x76, 0xff, 0xf7, 0x85, 0x3f, 0x93, 0x0c,
0xac, 0x77, 0xde, 0xb1, 0xbb, 0x78, 0x23, 0x32, 0xa1, 0x97, 0x8c, 0x4a, 0xa0, 0xbb, 0x86, 0xe6,
0x31, 0x06, 0x44, 0x68, 0xec, 0xb8, 0x25, 0x5d, 0x9d, 0x55, 0xe7, 0x07, 0x83, 0x64, 0xd4, 0xb0,
0x3f, 0x1a, 0xe3, 0x29, 0x04, 0xbd, 0x10, 0xfd, 0x83, 0xdd, 0x57, 0x05, 0xea, 0xc1, 0xb2, 0xff,
0xc4, 0x43, 0x58, 0x4c, 0xa6, 0xb4, 0x62, 0xc2, 0x13, 0x68, 0x8d, 0xdb, 0x8e, 0x93, 0x2d, 0x95,
0x42, 0x78, 0x04, 0xf5, 0xec, 0x37, 0xba, 0x16, 0x99, 0x22, 0x1e, 0x83, 0xe2, 0x89, 0x37, 0xa4,
0x1b, 0x71, 0x19, 0xd2, 0xcc, 0x57, 0x67, 0x99, 0x2c, 0x6b, 0x95, 0x67, 0x16, 0x4c, 0x2f, 0x34,
0x23, 0x93, 0x6e, 0xa3, 0xae, 0x07, 0xc9, 0xdd, 0x2d, 0xc0, 0x13, 0x7d, 0x0c, 0xf4, 0x3e, 0x53,
0xe0, 0x7f, 0xfe, 0x61, 0x05, 0x4b, 0xe9, 0x86, 0x9d, 0xb3, 0x81, 0x2e, 0x6f, 0x40, 0xa5, 0x45,
0x04, 0xec, 0xa1, 0x8e, 0x1e, 0xd7, 0x7d, 0xde, 0xd6, 0xef, 0xfd, 0xa7, 0xf8, 0x57, 0xe5, 0x5a,
0xb7, 0x77, 0xbf, 0x7a, 0x5e, 0xca, 0x46, 0xef, 0xe4, 0xf0, 0xa5, 0x15, 0xb8, 0xfa, 0x0e, 0x00,
0x00, 0xff, 0xff, 0x04, 0x4b, 0x80, 0xda, 0x73, 0x01, 0x00, 0x00,
// 233 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x90, 0x31, 0x4f, 0xc3, 0x30,
0x10, 0x85, 0x71, 0x1c, 0x07, 0x71, 0x55, 0x11, 0x3d, 0x21, 0x64, 0x31, 0x55, 0x9e, 0x3a, 0xa0,
0x20, 0x95, 0x81, 0x81, 0x0d,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3b, 0x00, 0x00, 0xff,
0xff, 0xb0, 0x77, 0x9c, 0xb9, 0x63, 0x01, 0x00, 0x00,
}

View File

@@ -11,8 +11,8 @@ service Feeds {
message Feed {
// rss feed name
string name = 1;
// rss feed address
string address = 2;
// rss feed url
string url = 2;
}
message Entry {
@@ -26,7 +26,7 @@ message Entry {
message NewRequest {
string name = 1;
string address = 2;
string url = 2;
}
message NewResponse {