func (s *Server) appendUDPService(c udp.Config) { if !c.Enabled { return } l := s.LogService.NewLogger("[udp] ", log.LstdFlags) srv := udp.NewService(c, l) srv.PointsWriter = s.TaskMaster s.Services = append(s.Services, srv) }
func (s *Server) appendUDPServices() { for i, c := range s.config.UDPs { if !c.Enabled { continue } l := s.LogService.NewLogger("[udp] ", log.LstdFlags) srv := udp.NewService(c, l) srv.PointsWriter = s.TaskMaster s.AppendService(fmt.Sprintf("udp%d", i), srv) } }
func (c *influxdbCluster) startUDPListener(se subEntry, port string) (*net.UDPAddr, error) { conf := udp.Config{} conf.Enabled = true conf.BindAddress = fmt.Sprintf("%s:%s", c.udpBind, port) conf.Database = se.db conf.RetentionPolicy = se.rp conf.Buffer = c.udpBuffer conf.ReadBuffer = c.udpReadBuffer l := c.LogService.NewLogger(fmt.Sprintf("[udp:%s.%s] ", se.db, se.rp), log.LstdFlags) service := udp.NewService(conf, l) service.PointsWriter = c.PointsWriter err := service.Open() if err != nil { return nil, err } c.services[se] = service c.logger.Println("I! started UDP listener for", se.db, se.rp) return service.Addr(), nil }
func (s *influxdbCluster) startUDPListener(cluster, rp, port string) (*net.UDPAddr, error) { c := udp.Config{} c.Enabled = true c.BindAddress = fmt.Sprintf("%s:%s", s.udpBind, port) c.Database = cluster c.RetentionPolicy = rp c.Buffer = s.udpBuffer c.ReadBuffer = s.udpReadBuffer l := s.LogService.NewLogger(fmt.Sprintf("[udp:%s.%s] ", cluster, rp), log.LstdFlags) service := udp.NewService(c, l) service.PointsWriter = s.PointsWriter err := service.Open() if err != nil { return nil, err } s.services = append(s.services, service) s.logger.Println("I! started UDP listener for", cluster, rp) return service.Addr(), nil }
func (s *Service) startListener(db, rp string, u url.URL) (net.Addr, error) { switch u.Scheme { case "udp": c := udp.Config{} c.Enabled = true c.BindAddress = u.Host c.Database = db c.RetentionPolicy = rp c.Buffer = s.udpBuffer c.ReadBuffer = s.udpReadBuffer l := s.LogService.NewLogger(fmt.Sprintf("[udp:%s.%s] ", db, rp), log.LstdFlags) service := udp.NewService(c, l) service.PointsWriter = s.PointsWriter err := service.Open() if err != nil { return nil, err } s.services = append(s.services, service) s.logger.Println("I! started UDP listener for", db, rp) return service.Addr(), nil } return nil, fmt.Errorf("unsupported scheme %q", u.Scheme) }