// This example demonstrates how to start a server and cleanly shut it down func ExampleShutdown() { srv := &Server{ Addr: net.JoinHostPort("::", DefaultService), Writer: format.NewPutval(os.Stdout), } srv.ListenAndWriteAsync() srv.Shutdown() }
// This example demonstrates how to listen to encrypted network traffic and // dump it to STDOUT using format.Putval. func ExampleServer_ListenAndWrite() { srv := &Server{ Addr: net.JoinHostPort("::", DefaultService), Writer: format.NewPutval(os.Stdout), PasswordLookup: NewAuthFile("/etc/collectd/users"), } // blocks log.Fatal(srv.ListenAndWrite()) }
func aggregator() { // listen on 8097 for collectd data cserver := &network.Server{ Addr: net.JoinHostPort("localhost", "8097"), Writer: format.NewPutval(os.Stdout), } // blocks log.Fatal(cserver.ListenAndWrite()) }
// in Go. package exec // import "collectd.org/exec" import ( "log" "os" "strconv" "sync" "time" "collectd.org/api" "collectd.org/format" ) // Putval is the dispatcher used by the exec package to print ValueLists. var Putval = format.NewPutval(os.Stdout) type valueCallback struct { callback func() api.Value vl api.ValueList done chan bool } type voidCallback struct { callback func(time.Duration) interval time.Duration done chan bool } type callback interface { run(*sync.WaitGroup)