blogaggregatormodule

package module
v0.0.0-...-bb385df Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2021 License: Apache-2.0 Imports: 12 Imported by: 1

README

blog-aggregator-module

This is the core module for the blog aggregator

Documentation

Index

Constants

View Source
const AUTHOR_CREATED = "blog.author_created"
View Source
const BLOG_ADDED = "blog.added"
View Source
const BLOG_UPDATED = "blog.updated"
View Source
const POST_CREATED = "blog.post_created"

Variables

View Source
var GenerateID = func() string {
	return ksuid.New().String()
}

Functions

func AddBlogCommand

func AddBlogCommand(url string) *weos.Command
func GetFeedLink(baseUrl string, body io.Reader) string

func Initialize

func Initialize(application weos.Application) error

Types

type AddBlogRequest

type AddBlogRequest struct {
	Url string `json:"url"`
}

type Author

type Author struct {
	Name  string `json:"name,omitempty"`
	Email string `json:"email,omitempty"`
}

type AuthorCreatedPayload

type AuthorCreatedPayload struct {
	BlogID string `json:"blogId"`
	Name   string `json:"name,omitempty"`
	Email  string `json:"email,omitempty"`
}

type Blog

type Blog struct {
	weos.AggregateRoot
	Title       string    `json:"title,omitempty"`
	Description string    `json:"description,omitempty"`
	URL         string    `json:"url,omitempty"`
	FeedURL     string    `json:"feedUrl,omitempty"`
	Authors     []*Author `json:"authors,omitempty"`
	Posts       []*Post   `json:"posts,omitempty"`
}

func (*Blog) AddFeed

func (b *Blog) AddFeed(feed *gofeed.Feed) error

func (*Blog) ApplyChanges

func (b *Blog) ApplyChanges(changes []*weos.Event) error

func (*Blog) Init

func (b *Blog) Init(blog *AddBlogRequest) (*Blog, error)

func (*Blog) Validate

func (b *Blog) Validate(blog *AddBlogRequest) error

type BlogCreatedPayload

type BlogCreatedPayload struct {
	Blog
}

type BlogRepository

type BlogRepository interface {
	weos.Repository
	GetByID(id string) *Blog
}

type BlogService

type BlogService struct {
	// contains filtered or unexported fields
}

func NewBlogService

func NewBlogService(client *http.Client, eventRepository weos.EventRepository) *BlogService

Create new repository service

func (*BlogService) AddBlog

func (b *BlogService) AddBlog(blogRequest *AddBlogRequest) (*Blog, error)

Add a new blog to the aggregator.

type Post

type Post struct {
	weos.BasicEntity
	Title       string    `json:"title,omitempty"`
	Description string    `json:"description,omitempty"`
	Content     string    `json:"content,omitempty"`
	Tags        []string  `json:"categories,omitempty"`
	PublishDate time.Time `json:"publishedParsed,omitempty"`
	Views       int       `json:"views"`
}

type PostCreatedPayload

type PostCreatedPayload struct {
	gofeed.Item
	BlogID string `json:"blogId"`
}

type Receiver

type Receiver struct {
	// contains filtered or unexported fields
}

func NewReceiver

func NewReceiver(application weos.Application) *Receiver

func (*Receiver) AddBlog

func (r *Receiver) AddBlog(ctx context.Context, command *weos.Command) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL