mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-06 05:25:35 +00:00
Rename Tag(s) to Event(s) (#4046)
* Rename Tag(s) to Event(s) - tag was replaced with event, but in some places it still mentions tag, would be easier to understand if we tried to replace it with event to not confuse people. Signed-off-by: Marko Baricevic <marbar3778@yahoo.com> * more changes from tag -> event * rename events to compositeKeys and keys * Apply suggestions from code review Co-Authored-By: Anton Kaliaev <anton.kalyaev@gmail.com> * add minor documentation on how composite keys are constructed * rename eventkey to compositekey Co-Authored-By: Anton Kaliaev <anton.kalyaev@gmail.com> * add changelog entry & add info to regenerate confid to changelog entry
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package query
|
||||
|
||||
// Empty query matches any set of tags.
|
||||
// Empty query matches any set of events.
|
||||
type Empty struct {
|
||||
}
|
||||
|
||||
|
||||
@@ -29,12 +29,12 @@ type Query struct {
|
||||
parser *QueryParser
|
||||
}
|
||||
|
||||
// Condition represents a single condition within a query and consists of tag
|
||||
// Condition represents a single condition within a query and consists of composite key
|
||||
// (e.g. "tx.gas"), operator (e.g. "=") and operand (e.g. "7").
|
||||
type Condition struct {
|
||||
Tag string
|
||||
Op Operator
|
||||
Operand interface{}
|
||||
CompositeKey string
|
||||
Op Operator
|
||||
Operand interface{}
|
||||
}
|
||||
|
||||
// New parses the given string and returns a query or error if the string is
|
||||
@@ -63,7 +63,7 @@ func (q *Query) String() string {
|
||||
return q.str
|
||||
}
|
||||
|
||||
// Operator is an operator that defines some kind of relation between tag and
|
||||
// Operator is an operator that defines some kind of relation between composite key and
|
||||
// operand (equality, etc.).
|
||||
type Operator uint8
|
||||
|
||||
@@ -399,7 +399,7 @@ func matchValue(value string, op Operator, operand reflect.Value) (bool, error)
|
||||
case reflect.Struct: // time
|
||||
operandAsTime := operand.Interface().(time.Time)
|
||||
|
||||
// try our best to convert value from tags to time.Time
|
||||
// try our best to convert value from events to time.Time
|
||||
var (
|
||||
v time.Time
|
||||
err error
|
||||
|
||||
@@ -187,26 +187,26 @@ func TestConditions(t *testing.T) {
|
||||
{
|
||||
s: "tm.events.type='NewBlock'",
|
||||
conditions: []query.Condition{
|
||||
{Tag: "tm.events.type", Op: query.OpEqual, Operand: "NewBlock"},
|
||||
{CompositeKey: "tm.events.type", Op: query.OpEqual, Operand: "NewBlock"},
|
||||
},
|
||||
},
|
||||
{
|
||||
s: "tx.gas > 7 AND tx.gas < 9",
|
||||
conditions: []query.Condition{
|
||||
{Tag: "tx.gas", Op: query.OpGreater, Operand: int64(7)},
|
||||
{Tag: "tx.gas", Op: query.OpLess, Operand: int64(9)},
|
||||
{CompositeKey: "tx.gas", Op: query.OpGreater, Operand: int64(7)},
|
||||
{CompositeKey: "tx.gas", Op: query.OpLess, Operand: int64(9)},
|
||||
},
|
||||
},
|
||||
{
|
||||
s: "tx.time >= TIME 2013-05-03T14:45:00Z",
|
||||
conditions: []query.Condition{
|
||||
{Tag: "tx.time", Op: query.OpGreaterEqual, Operand: txTime},
|
||||
{CompositeKey: "tx.time", Op: query.OpGreaterEqual, Operand: txTime},
|
||||
},
|
||||
},
|
||||
{
|
||||
s: "slashing EXISTS",
|
||||
conditions: []query.Condition{
|
||||
{Tag: "slashing", Op: query.OpExists},
|
||||
{CompositeKey: "slashing", Op: query.OpExists},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ var (
|
||||
|
||||
// A Subscription represents a client subscription for a particular query and
|
||||
// consists of three things:
|
||||
// 1) channel onto which messages and tags are published
|
||||
// 1) channel onto which messages and events are published
|
||||
// 2) channel which is closed if a client is too slow or choose to unsubscribe
|
||||
// 3) err indicating the reason for (2)
|
||||
type Subscription struct {
|
||||
@@ -35,7 +35,7 @@ func NewSubscription(outCapacity int) *Subscription {
|
||||
}
|
||||
}
|
||||
|
||||
// Out returns a channel onto which messages and tags are published.
|
||||
// Out returns a channel onto which messages and events are published.
|
||||
// Unsubscribe/UnsubscribeAll does not close the channel to avoid clients from
|
||||
// receiving a nil message.
|
||||
func (s *Subscription) Out() <-chan Message {
|
||||
@@ -68,7 +68,7 @@ func (s *Subscription) cancel(err error) {
|
||||
close(s.cancelled)
|
||||
}
|
||||
|
||||
// Message glues data and tags together.
|
||||
// Message glues data and events together.
|
||||
type Message struct {
|
||||
data interface{}
|
||||
events map[string][]string
|
||||
|
||||
Reference in New Issue
Block a user