Created
February 12, 2015 00:35
-
-
Save ajackson/84e0489cbf25f5370e1d to your computer and use it in GitHub Desktop.
reconnect test with syslog writer
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
$ go run syslog_reconnect.go | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Wrote data successfully | |
Wrote data successfully | |
Wrote data successfully | |
Wrote data successfully | |
Wrote data successfully | |
Wrote data successfully | |
Wrote data successfully | |
Wrote data successfully | |
Wrote data successfully | |
Wrote data successfully | |
Wrote data successfully | |
Wrote data successfully | |
Wrote data successfully | |
Wrote data successfully | |
Failed to write data write tcp 127.0.0.1:12345: broken pipe | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Wrote data successfully | |
Wrote data successfully | |
Wrote data successfully | |
Wrote data successfully | |
Wrote data successfully | |
Wrote data successfully | |
Wrote data successfully | |
Wrote data successfully | |
Wrote data successfully | |
Wrote data successfully | |
Failed to write data write tcp 127.0.0.1:12345: broken pipe | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
Failed to connect dial tcp 127.0.0.1:12345: connection refused | |
$ |
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
$ nc -l 12345 | |
86 <14>1 2015-02-11T16:30:26.257012-08:00 loggregator an-app-id [] - - Some data for you | |
86 <14>1 2015-02-11T16:30:26.257254-08:00 loggregator an-app-id [] - - Some data for you | |
86 <14>1 2015-02-11T16:30:26.257284-08:00 loggregator an-app-id [] - - Some data for you | |
86 <14>1 2015-02-11T16:30:26.257322-08:00 loggregator an-app-id [] - - Some data for you | |
86 <14>1 2015-02-11T16:30:26.257349-08:00 loggregator an-app-id [] - - Some data for you | |
86 <14>1 2015-02-11T16:30:26.257378-08:00 loggregator an-app-id [] - - Some data for you | |
86 <14>1 2015-02-11T16:30:26.257408-08:00 loggregator an-app-id [] - - Some data for you | |
85 <14>1 2015-02-11T16:30:26.25744-08:00 loggregator an-app-id [] - - Some data for you | |
86 <14>1 2015-02-11T16:30:26.257472-08:00 loggregator an-app-id [] - - Some data for you | |
86 <14>1 2015-02-11T16:30:26.257505-08:00 loggregator an-app-id [] - - Some data for you | |
86 <14>1 2015-02-11T16:30:26.257535-08:00 loggregator an-app-id [] - - Some data for you | |
86 <14>1 2015-02-11T16:30:26.257583-08:00 loggregator an-app-id [] - - Some data for you | |
86 <14>1 2015-02-11T16:30:26.257654-08:00 loggregator an-app-id [] - - Some data for you | |
^C | |
$ nc -l 12345 | |
86 <14>1 2015-02-11T16:30:27.514415-08:00 loggregator an-app-id [] - - Some data for you | |
86 <14>1 2015-02-11T16:30:27.514426-08:00 loggregator an-app-id [] - - Some data for you | |
86 <14>1 2015-02-11T16:30:27.514436-08:00 loggregator an-app-id [] - - Some data for you | |
86 <14>1 2015-02-11T16:30:27.514446-08:00 loggregator an-app-id [] - - Some data for you | |
86 <14>1 2015-02-11T16:30:27.514456-08:00 loggregator an-app-id [] - - Some data for you | |
86 <14>1 2015-02-11T16:30:27.514466-08:00 loggregator an-app-id [] - - Some data for you | |
86 <14>1 2015-02-11T16:30:27.514475-08:00 loggregator an-app-id [] - - Some data for you | |
86 <14>1 2015-02-11T16:30:27.514486-08:00 loggregator an-app-id [] - - Some data for you | |
86 <14>1 2015-02-11T16:30:27.514495-08:00 loggregator an-app-id [] - - Some data for you | |
86 <14>1 2015-02-11T16:30:27.514505-08:00 loggregator an-app-id [] - - Some data for you | |
^C | |
$ |
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
package main | |
import ( | |
"doppler/sinks/syslogwriter" | |
"net/url" | |
"time" | |
) | |
func main() { | |
data := []byte("Some data for you\n") | |
dest, _ := url.Parse("syslog://localhost:12345") | |
writer := syslogwriter.NewSyslogWriter(dest, "an-app-id", false) | |
for { | |
err := writer.Connect() | |
if err != nil { | |
println("Failed to connect", err.Error()) | |
continue | |
} | |
for { | |
_, err = writer.WriteStdout(data, "", "", time.Now().UnixNano()) | |
println("Wrote data successfully") | |
if err != nil { | |
println("Failed to write data", err.Error()) | |
break | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment