Documentation
¶
Overview ¶
Package rules implements queries for reading and modifying the rules used by streaming search queries.
Reading Rules ¶
Use rules.Get to query for existing rules by ID. If no IDs are given, Get will return all available rules.
myRules := rules.Get(id1, id2, id3) allRules := rules.Get()
Invoke the query to fetch the rules:
rsp, err := allRules.Invoke(ctx, cli)
The Rules field of the response contains the requested rules.
Updating Rules ¶
Each rule update must either add or delete rules, but not both. Use Adds to describe a Set of rules to add, or Deletes to identify a Set of rules to delete. For example:
adds := rules.Adds{ {Query: `cat has:images lang:en`, Tag: "cat pictures in English"}, {Query: `dog or puppy has:images`}, } dels := rules.Deletes{id1, id2}
Once you have a set, you can build a query to Update or Validate. Update applies the rule change; Validate just reports whether the update would have succeeded (this corresponds to the "dry_run" parameter in the API):
apply := rules.Update(adds) check := rules.Validate(dels)
Invoke the query to execute the change or check:
rsp, err := apply.Invoke(ctx, cli)
The response will include the updated rules, along with server metadata indicating the effective time of application and summary statistics.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Meta ¶
type Meta struct { Sent time.Time `json:"sent"` Summary struct { Created int `json:"created,omitempty"` NotCreated int `json:"not_created,omitempty"` Deleted int `json:"deleted,omitempty"` NotDeleted int `json:"not_deleted,omitempty"` Valid int `json:"valid,omitempty"` Invalid int `json:"invalid,omitempty"` } `json:"summary,omitempty"` }
Meta records rule set metadata reported by the service.
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
A Query performs a rule fetch or update query.
func Get ¶
Get constructs a query to fetch the specified streaming search rule IDs. If no rule IDs are given, all known rules are fetched.
API: GET 2/tweets/search/stream/rules
func Update ¶
Update constructs a query to add or delete streaming search rules.
API: POST 2/tweets/search/stream/rules