Skip to content
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.

Commit

Permalink
output-tcp (#77)
Browse files Browse the repository at this point in the history
* http-output fix empty body in retry again

* bitfanDoc fix bad paths on windows

* add output-tcp

* added glob support for configs
now available `config = [ "/etc/bitfan/conf.d/*.conf"]`

* output-tcp fix tests
  • Loading branch information
AlexAkulov authored and vjeantet committed Apr 21, 2018
1 parent d452f47 commit 744278b
Show file tree
Hide file tree
Showing 9 changed files with 465 additions and 6 deletions.
2 changes: 2 additions & 0 deletions cmd/bitfan/commands/plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
fileoutput "github.com/vjeantet/bitfan/processors/output-file"
glusterfsoutput "github.com/vjeantet/bitfan/processors/output-glusterfs"
httpoutput "github.com/vjeantet/bitfan/processors/output-http"
tcpoutput "github.com/vjeantet/bitfan/processors/output-tcp"
mongodb "github.com/vjeantet/bitfan/processors/output-mongodb"
null "github.com/vjeantet/bitfan/processors/output-null"
rabbitmqoutput "github.com/vjeantet/bitfan/processors/output-rabbitmq"
Expand Down Expand Up @@ -127,6 +128,7 @@ func init() {
initPlugin("output", "rabbitmq", rabbitmqoutput.New)
initPlugin("output", "email", email.New)
initPlugin("output", "http", httpoutput.New)
initPlugin("output", "tcp", tcpoutput.New)
initPlugin("output", "sql", sqlprocessor.New)
initPlugin("output", "template", templateprocessor.New)
initPlugin("output", "httpout", httpoutprocessor.New)
Expand Down
16 changes: 14 additions & 2 deletions cmd/bitfan/commands/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,20 @@ When no configuration is passed to the command, bitfan use the config set in glo
cwd, _ := os.Getwd()
if len(args) == 0 {
for _, v := range viper.GetStringSlice("config") {
loc, _ := entrypoint.New(v, cwd, entrypoint.CONTENT_REF)
entrypoints.AddEntrypoint(loc)
files, err := filepath.Glob(v)
if err != nil {
core.Log().Errorf("can't match '%s' with err: %v", v, err)
continue
}
for _, file := range files {
core.Log().Debugf("add config file '%s'", file)
loc, err := entrypoint.New(file, cwd, entrypoint.CONTENT_REF)
if err != nil {
core.Log().Errorf("can't add etrypoint from '%s' with err: %v", file, err)
continue
}
entrypoints.AddEntrypoint(loc)
}
}
}

Expand Down
78 changes: 78 additions & 0 deletions docs/data/processors/tcpoutput.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"Behavior": "",
"Doc": "",
"DocShort": "",
"ImportPath": "github.com/vjeantet/bitfan/processors/output-tcp",
"Name": "tcpoutput",
"Options": {
"Doc": "",
"Options": [
{
"Alias": "codec",
"DefaultValue": "\"line\"",
"Doc": "The codec used for input data. Input codecs are a convenient method for decoding\nyour data before it enters the input, without needing a separate filter in your bitfan pipeline",
"ExampleLS": "",
"Name": "Codec",
"PossibleValues": [
"\"json\"",
"\"line\"",
"\"pp\"",
"\"rubydebug\""
],
"Required": false,
"Type": "codec"
},
{
"Alias": "host",
"DefaultValue": null,
"Doc": "",
"ExampleLS": "",
"Name": "Host",
"PossibleValues": null,
"Required": true,
"Type": "string"
},
{
"Alias": "port",
"DefaultValue": null,
"Doc": "",
"ExampleLS": "",
"Name": "Port",
"PossibleValues": null,
"Required": true,
"Type": "uint"
},
{
"Alias": "keepalive",
"DefaultValue": "true",
"Doc": "Turn this on to enable HTTP keepalive support. Default value is true",
"ExampleLS": "",
"Name": "KeepAlive",
"PossibleValues": null,
"Required": false,
"Type": "bool"
},
{
"Alias": "request_timeout",
"DefaultValue": "30",
"Doc": "Timeout (in seconds) for the entire request. Default value is 60",
"ExampleLS": "",
"Name": "RequestTimeout",
"PossibleValues": null,
"Required": false,
"Type": "uint"
},
{
"Alias": "retry_interval",
"DefaultValue": "10",
"Doc": "",
"ExampleLS": "",
"Name": "RetryInterval",
"PossibleValues": null,
"Required": false,
"Type": "uint"
}
]
},
"Ports": []
}
5 changes: 3 additions & 2 deletions processors/doc/doccodec.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"go/doc"
"go/parser"
"go/token"
"os"
"regexp"
"strings"

Expand Down Expand Up @@ -39,8 +40,8 @@ func NewCodec(pkgPath string) (*Codec, error) {

docPkg := doc.New(astPkg, pkgPath, doc.AllDecls)
dp.PkgName = docPkg.Name

dp.ImportPath = strings.TrimPrefix(docPkg.ImportPath, build.Default.GOPATH+"/src/")
p := string(os.PathSeparator)
dp.ImportPath = strings.Replace(strings.TrimPrefix(docPkg.ImportPath, build.Default.GOPATH+p+"src"+p), "\\", "/", -1)

dp.Doc = removeSpecialComment(docPkg.Doc)

Expand Down
4 changes: 2 additions & 2 deletions processors/doc/docprocessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ func NewProcessor(pkgPath string) (*Processor, error) {

docPkg := doc.New(astPkg, pkgPath, doc.AllDecls)
dp.Name = docPkg.Name
dp.ImportPath = strings.TrimPrefix(docPkg.ImportPath, build.Default.GOPATH+"/src/")

p := string(os.PathSeparator)
dp.ImportPath = strings.Replace(strings.TrimPrefix(docPkg.ImportPath, build.Default.GOPATH+p+"src"+p), "\\", "/", -1)
dp.Doc = removeSpecialComment(docPkg.Doc)

for _, typ := range docPkg.Types {
Expand Down
85 changes: 85 additions & 0 deletions processors/output-tcp/docdoc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 71 additions & 0 deletions processors/output-tcp/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# TCPOUTPUT


## Synopsys


| SETTING | TYPE | REQUIRED | DEFAULT VALUE |
|-----------------|--------|----------|---------------|
| codec | codec | false | "line" |
| host | string | true | "" |
| port | uint | true | ? |
| keepalive | bool | false | true |
| request_timeout | uint | false | 30 |
| retry_interval | uint | false | 10 |


## Details

### codec
* Value type is codec
* Default value is `"line"`

The codec used for input data. Input codecs are a convenient method for decoding
your data before it enters the input, without needing a separate filter in your bitfan pipeline

### host
* This is a required setting.
* Value type is string
* Default value is `""`



### port
* This is a required setting.
* Value type is uint
* Default value is `?`



### keepalive
* Value type is bool
* Default value is `true`

Turn this on to enable HTTP keepalive support. Default value is true

### request_timeout
* Value type is uint
* Default value is `30`

Timeout (in seconds) for the entire request. Default value is 60

### retry_interval
* Value type is uint
* Default value is `10`





## Configuration blueprint

```
tcpoutput{
codec => "line"
host => ""
port => uint
keepalive => true
request_timeout => 30
retry_interval => 10
}
```
Loading

0 comments on commit 744278b

Please sign in to comment.