straumur

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

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

Go to latest
Published: Nov 20, 2013 License: MIT Imports: 17 Imported by: 4

README

Straumur

Build Status

Modular activity feed written in Go. Work in progress.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AggregateTypeTest

func AggregateTypeTest(t *testing.T, d DataBackend)

func DateRangeFilterTest

func DateRangeFilterTest(t *testing.T, d DataBackend)

func InsertUpdateTest

func InsertUpdateTest(t *testing.T, d DataBackend)

func NewHub

func NewHub(d DataBackend) *hub

func NewProcessorList

func NewProcessorList() *processorList

Returns a new processor list

func QueryByTest

func QueryByTest(t *testing.T, d DataBackend)

func QueryTest

func QueryTest(t *testing.T, d DataBackend)

func RunDataBackendSuite

func RunDataBackendSuite(t *testing.T, d DataBackend, clear clearfunc)

Types

type Broadcaster

type Broadcaster interface {
	Broadcast(e *Event)
	Run(ec chan error)
}

type ByDate

type ByDate struct{ Events }

func (ByDate) Less

func (s ByDate) Less(i, j int) bool

type DataBackend

type DataBackend interface {
	Save(e *Event) error
	GetById(id int) (*Event, error)
	Query(q Query) ([]*Event, error)
	AggregateType(q Query, s string) (map[string]int, error)
}

Queryable Data store

type DataService

type DataService interface {
	Run(d DataBackend, ec chan error)
}

type Event

type Event struct {
	ID              int         `json:"id"`
	Key             string      `json:"key"`
	KeyParams       interface{} `json:"key_params"`
	Created         time.Time   `json:"created"`
	Updated         time.Time   `json:"updated"`
	Payload         interface{} `json:"payload"`
	Description     string      `json:"description"`
	Importance      int         `json:"importance"`
	Origin          string      `json:"origin"`
	Entities        []string    `json:"entities"`
	OtherReferences []string    `json:"other_references"`
	Actors          []string    `json:"actors"`
	Tags            []string    `json:"tags"`
}

func NewEvent

func NewEvent(key string, keyParams interface{}, payload interface{}, description string, importance int,
	origin string, entities []string, otherReferences []string, actors []string, tags []string) *Event

type EventFeed

type EventFeed interface {
	Updates() <-chan *Event
	Close() error
}

func Merge

func Merge(feeds ...EventFeed) EventFeed

type Events

type Events []*Event

func (Events) Len

func (e Events) Len() int

func (Events) Swap

func (e Events) Swap(i, j int)

type LocalMemoryStore

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

func NewLocalMemoryStore

func NewLocalMemoryStore() *LocalMemoryStore

func (*LocalMemoryStore) AggregateType

func (d *LocalMemoryStore) AggregateType(q Query, s string) (map[string]int, error)

func (*LocalMemoryStore) Clear

func (d *LocalMemoryStore) Clear()

func (*LocalMemoryStore) GetById

func (d *LocalMemoryStore) GetById(id int) (*Event, error)

func (*LocalMemoryStore) Query

func (d *LocalMemoryStore) Query(q Query) ([]*Event, error)

func (*LocalMemoryStore) Save

func (d *LocalMemoryStore) Save(e *Event) error

type MatchArray

type MatchArray [2][]string

func (MatchArray) Match

func (m MatchArray) Match() bool

Given two string arrays, returns true if the value array contains all of the query array's values

type Processor

type Processor func(*Event) error

Processor is a function which modifies the contents of the event and emits any errors to the error channel

type Query

type Query struct {
	Origin          string    `url:"origin,omitempty" schema:"origin" json:"origin"`
	Key             string    `url:"key,omitempty" schema:"key" json:"key"`
	Entities        []string  `url:"entities,omitempty" schema:"entities" json:"entities"`
	OtherReferences []string  `url:"other_references,omitempty" schema:"other_references" json:"other_references"`
	Actors          []string  `url:"actors,omitempty" schema:"actors" json:"actors"`
	Tags            []string  `url:"tags,omitempty" schema:"tags" json:"tags"`
	Importance      string    `url:"importance,omitempty" schema:"importance" json:"importance"`
	From            time.Time `url:"from,omitempty" schema:"from" json:"from"`
	To              time.Time `url:"to,omitempty" schema:"to" json:"to"`
}

TODO: Created/Updated, lt & gt TODO: Importance, 1+OR+3 gt1 lt4. single param TODO: Sort & direction

func QueryFromString

func QueryFromString(s string) (*Query, error)

func QueryFromValues

func QueryFromValues(u url.Values) (*Query, error)

func (*Query) IsEmpty

func (q *Query) IsEmpty() bool

Returns true if the query values are empty

func (*Query) IsValidArrayType

func (q *Query) IsValidArrayType(s string) bool

Return true if s is a valid array type

func (*Query) Match

func (q *Query) Match(e Event) bool

Determines whether an event matched the query

Jump to

Keyboard shortcuts

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