chg: [main] reuse existing tcp connection
parent
d52c02f8de
commit
ab248fa3ad
|
@ -266,7 +266,7 @@ func d4loadConfig(d4 *d4S) bool {
|
|||
}
|
||||
if (*d4).conf.source == "d4server" {
|
||||
// Parse Input Redis Config
|
||||
tmp := config.ReadConfigFile(*confdir, "redis_d4")
|
||||
tmp := string(readConfFile(d4, "redis_d4"))
|
||||
ss := strings.Split(string(tmp), "/")
|
||||
if len(ss) <= 1 {
|
||||
log.Fatal("Missing Database in Redis input config: should be host:port/database_name")
|
||||
|
@ -414,6 +414,12 @@ func setReaderWriters(d4 *d4S) bool {
|
|||
}
|
||||
isn, dstnet := config.IsNet((*d4).conf.destination)
|
||||
if isn {
|
||||
// First, we test whether a usable connection already exist
|
||||
// (case where the reader run out of data)
|
||||
switch (*d4).dst.w.(type){
|
||||
case net.Conn:
|
||||
logger.Println("Reusing previous tcp connection.")
|
||||
default:
|
||||
dial := net.Dialer{
|
||||
Timeout: (*d4).ct,
|
||||
KeepAlive: (*d4).cka,
|
||||
|
@ -442,6 +448,7 @@ func setReaderWriters(d4 *d4S) bool {
|
|||
}
|
||||
(*d4).dst = newD4Writer(conn, (*d4).conf.key)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
switch (*d4).conf.destination {
|
||||
case "stdout":
|
||||
|
@ -466,7 +473,7 @@ func generateUUIDv4() []byte {
|
|||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
logger.Println(fmt.Sprintf("UUIDv4: %s\n", uuid))
|
||||
logger.Println(fmt.Sprintf("UUIDv4: %s", uuid))
|
||||
return uuid.Bytes()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue