renamed DiscardRouter to DiscardingRouter.
parent
d8c0295605
commit
5c15d262cf
|
@ -15,7 +15,7 @@ func TestNewCopyingRouter(t *testing.T) {
|
||||||
randomness := rand.New(rand.NewSource( time.Now().UTC().UnixNano() ))
|
randomness := rand.New(rand.NewSource( time.Now().UTC().UnixNano() ))
|
||||||
|
|
||||||
|
|
||||||
router := NewCopyingRouter(NewDiscardRouter())
|
router := NewCopyingRouter(NewDiscardingRouter())
|
||||||
if nil == router {
|
if nil == router {
|
||||||
t.Errorf("After trying to create a copying router, expected it to be not nil, but was: %v", router)
|
t.Errorf("After trying to create a copying router, expected it to be not nil, but was: %v", router)
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ func TestCopyingRouterRoute(t *testing.T) {
|
||||||
|
|
||||||
TLoop: for testNumber, test := range tests {
|
TLoop: for testNumber, test := range tests {
|
||||||
|
|
||||||
router := NewCopyingRouter(NewDiscardRouter())
|
router := NewCopyingRouter(NewDiscardingRouter())
|
||||||
|
|
||||||
for _, datum := range test.Data {
|
for _, datum := range test.Data {
|
||||||
router.Route(datum.Message, datum.Context)
|
router.Route(datum.Message, datum.Context)
|
||||||
|
|
|
@ -2,23 +2,23 @@ package flog
|
||||||
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
singltonDiscardRouter = DiscardRouter{}
|
singltonDiscardingRouter = DiscardingRouter{}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
// NewDiscardRouter returns an initialized DiscardRouter.
|
// NewDiscardingRouter returns an initialized DiscardingRouter.
|
||||||
func NewDiscardRouter() *DiscardRouter {
|
func NewDiscardingRouter() *DiscardingRouter {
|
||||||
return &singltonDiscardRouter
|
return &singltonDiscardingRouter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// DiscardRouter is a Router that discards any message (and its context)
|
// DiscardingRouter is a Router that discards any message (and its context)
|
||||||
// it is asked to route.
|
// it is asked to route.
|
||||||
//
|
//
|
||||||
// Conceptually it is similar to /dev/null
|
// Conceptually it is similar to /dev/null
|
||||||
type DiscardRouter struct{}
|
type DiscardingRouter struct{}
|
||||||
|
|
||||||
|
|
||||||
func (router *DiscardRouter) Route(message string, context map[string]interface{}) error {
|
func (router *DiscardingRouter) Route(message string, context map[string]interface{}) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func TestNewDiscardRouter(t *testing.T) {
|
func TestNewDiscardingRouter(t *testing.T) {
|
||||||
|
|
||||||
randomness := rand.New(rand.NewSource( time.Now().UTC().UnixNano() ))
|
randomness := rand.New(rand.NewSource( time.Now().UTC().UnixNano() ))
|
||||||
|
|
||||||
|
|
||||||
router := NewDiscardRouter()
|
router := NewDiscardingRouter()
|
||||||
if nil == router {
|
if nil == router {
|
||||||
t.Errorf("After trying to create a discard router, expected it to be not nil, but was: %v", router)
|
t.Errorf("After trying to create a discard router, expected it to be not nil, but was: %v", router)
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ func TestFilteringRouterJustCreated(t *testing.T) {
|
||||||
randomness := rand.New(rand.NewSource( time.Now().UTC().UnixNano() ))
|
randomness := rand.New(rand.NewSource( time.Now().UTC().UnixNano() ))
|
||||||
|
|
||||||
|
|
||||||
router := NewFilteringRouter(NewDiscardRouter(), func(string, map[string]interface{}) bool {
|
router := NewFilteringRouter(NewDiscardingRouter(), func(string, map[string]interface{}) bool {
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
if nil == router {
|
if nil == router {
|
||||||
|
@ -44,7 +44,7 @@ func TestFilteringRouterJustFilterParameters(t *testing.T) {
|
||||||
var filterContext map[string] interface{}
|
var filterContext map[string] interface{}
|
||||||
var filterResult = false
|
var filterResult = false
|
||||||
|
|
||||||
router := NewFilteringRouter(NewDiscardRouter(), func(message string, context map[string]interface{}) bool {
|
router := NewFilteringRouter(NewDiscardingRouter(), func(message string, context map[string]interface{}) bool {
|
||||||
filterMessage = message
|
filterMessage = message
|
||||||
filterContext = context
|
filterContext = context
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
|
|
||||||
func TestNew(t *testing.T) {
|
func TestNew(t *testing.T) {
|
||||||
|
|
||||||
flogger := New(NewDiscardRouter())
|
flogger := New(NewDiscardingRouter())
|
||||||
if nil == flogger {
|
if nil == flogger {
|
||||||
t.Errorf("Expected created flogger to not be nil, but was: %v", flogger)
|
t.Errorf("Expected created flogger to not be nil, but was: %v", flogger)
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ func TestNewForContext(t *testing.T) {
|
||||||
TestLoop:
|
TestLoop:
|
||||||
for testNumber, test := range tests {
|
for testNumber, test := range tests {
|
||||||
|
|
||||||
flogger := New(NewDiscardRouter(), test.Cascade...)
|
flogger := New(NewDiscardingRouter(), test.Cascade...)
|
||||||
|
|
||||||
context := flogger.(*internalFlogger).context
|
context := flogger.(*internalFlogger).context
|
||||||
|
|
||||||
|
|
|
@ -303,7 +303,7 @@ func TestWith(t *testing.T) {
|
||||||
TestLoop:
|
TestLoop:
|
||||||
for testNumber, test := range tests {
|
for testNumber, test := range tests {
|
||||||
|
|
||||||
flogger1 := New(NewDiscardRouter(), test.Cascade1...)
|
flogger1 := New(NewDiscardingRouter(), test.Cascade1...)
|
||||||
|
|
||||||
flogger2 := flogger1.With(test.Cascade2...)
|
flogger2 := flogger1.With(test.Cascade2...)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue