Ejemplo n.º 1
0
func TestConnectToServer(t *testing.T) {
	hosts := []string{
		"127.0.0.1",
	}
	if os.Getenv("TRAVIS") == "" {
		// travis-ci has not ipv6 networking
		hosts = append(hosts, "[::1]")
	}
	for _, host := range hosts {
		port := startDummyServer(host)
		conf := fluent.Config{
			Server:  host + ":" + port,
			Timeout: time.Second * 1,
		}
		f, err := fluent.New(conf)
		if err != nil {
			t.Error(err)
		}
		if !f.Alive() {
			t.Error("server is not available")
		}
		f.Close()
		time.Sleep(time.Second * 1)
	}
}
Ejemplo n.º 2
0
// OutForward ... recieve FluentRecordSet from channel, and send it to passed loggers until success.
func NewOutForward(configServers []*ConfigServer) (*OutForward, error) {
	loggers := make([]*fluent.Fluent, len(configServers))
	for i, server := range configServers {
		logger, err := fluent.New(fluent.Config{Server: server.Address()})
		if err != nil {
			log.Println("[warning]", err)
		} else {
			log.Println("[info] Server", server.Address(), "connected")
		}
		loggers[i] = logger
		logger.Send([]byte{})
	}
	return &OutForward{
		loggers: loggers,
		sent:    0,
	}, nil
}