Documentation ¶
Overview ¶
Package datastore provides mongo implementation for store to keep and access rules
Index ¶
- type MongoServer
- type Rule
- type RulesDAO
- func (r RulesDAO) All(ctx context.Context) []Rule
- func (r RulesDAO) Disable(ctx context.Context, id primitive.ObjectID) error
- func (r RulesDAO) Get(ctx context.Context, rURL string) (Rule, bool)
- func (r RulesDAO) GetByID(ctx context.Context, id primitive.ObjectID) (Rule, bool)
- func (r RulesDAO) Save(ctx context.Context, rule Rule) (Rule, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MongoServer ¶
type MongoServer struct {
// contains filtered or unexported fields
}
MongoServer top level mongo ops
func New ¶
func New(connectionURI, dbName string, delay time.Duration) (*MongoServer, error)
New MongoServer
func (*MongoServer) GetStores ¶
func (m *MongoServer) GetStores() (rules RulesDAO)
GetStores initialize collections and make indexes
type Rule ¶
type Rule struct { ID primitive.ObjectID `json:"id" bson:"_id,omitempty"` Domain string `json:"domain"` MatchURLs []string `json:"match_url,omitempty" bson:"match_urls,omitempty"` Content string `json:"content"` Author string `json:"author,omitempty" bson:"author,omitempty"` TS string `json:"ts,omitempty" bson:"ts,omitempty"` // ts of original article Excludes []string `json:"excludes,omitempty" bson:"excludes,omitempty"` TestURLs []string `json:"test_urls,omitempty" bson:"test_urls"` User string `json:"user"` Enabled bool `json:"enabled"` }
Rule record, entry in mongo
type RulesDAO ¶
type RulesDAO struct {
*mongo.Collection
}
RulesDAO data-access obj for custom parsing rules, implements Rules
Click to show internal directories.
Click to hide internal directories.