Example #1
0
func (d *Decoder) run() {
	datagramDecoder := sflow.NewDecoder(nil)
	for buf := range d.inbound {
		r := bytes.NewReader(buf)
		datagramDecoder.Use(r)
		dgram, err := datagramDecoder.Decode()
		if err == nil {
			select {
			case d.outbound <- dgram:
			default:
				// Drop.
			}
		}
	}
}
Example #2
0
func (d *SflowDecoder) Run() {
	decoder := sflow.NewDecoder(nil)
	go func() {
		for buf := range d.inbound {
			r := bytes.NewReader(buf)

			decoder.Use(r)

			dgram, err := decoder.Decode()
			if err == nil {
				d.outbound <- *dgram
			} else {
				log.Println(err)
			}
		}
	}()
}