-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: alexferl <me@alexferl.com>
- Loading branch information
Showing
28 changed files
with
401 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package factories | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"tinysyslog/filters" | ||
"tinysyslog/mutators" | ||
"tinysyslog/sinks" | ||
) | ||
|
||
func TestMutator(t *testing.T) { | ||
m := Mutator() | ||
assert.Equal(t, mutators.TextKind, m.GetKind()) | ||
} | ||
|
||
func TestFilter(t *testing.T) { | ||
f := Filter() | ||
assert.Equal(t, filters.NoOpKind, f.GetKind()) | ||
} | ||
|
||
func TestSinks(t *testing.T) { | ||
s := Sinks() | ||
assert.Equal(t, []sinks.Sink(nil), s) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,20 @@ | ||
package filters | ||
|
||
type Kind int8 | ||
|
||
const ( | ||
NoOpKind Kind = iota + 1 | ||
RegexKind | ||
) | ||
|
||
func (k Kind) String() string { | ||
return [...]string{"noop", "regex"}[k-1] | ||
} | ||
|
||
var Kinds = []string{NoOpKind.String(), RegexKind.String()} | ||
|
||
// Filter is a common interface for all filters | ||
type Filter interface { | ||
Filter(string) (string, error) | ||
GetKind() Kind | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,20 @@ | ||
package filters | ||
|
||
// NoOp represents a no operation filter | ||
type NoOp struct{} | ||
type NoOp struct { | ||
kind Kind | ||
} | ||
|
||
// NewNoOp creates a NoOp instance | ||
func NewNoOp() Filter { | ||
return Filter(&NoOp{}) | ||
return Filter(&NoOp{kind: NoOpKind}) | ||
} | ||
|
||
// Filter filters a log entry | ||
func (n *NoOp) Filter(data string) (string, error) { | ||
return data, nil | ||
} | ||
|
||
func (n *NoOp) GetKind() Kind { | ||
return n.kind | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.