func (os *ostream) Post(b []byte) error {
	os.mu.Lock()
	defer os.mu.Unlock()
	if err := os.e.EncodeTo(os.frontBuf, b); err != nil {
		out(os.Printf, "failed to write: %s", err)
		os.lostMsgs.Inc()
		os.lostBytes.Add(float64(len(b)))
		return err
	}
	os.bufferedMsgs++
	os.bufferedBytes += float64(len(b))
	for os.frontBuf.Len() > MaxBuffer {
		size, err := decodeSize(os.frontBuf)
		if err != nil {
			panic("nanoq: failed to decode payload size from the send buffer: " + err.Error())
		}
		if err := os.frontBuf.Discard(size); err != nil {
			panic("nanoq: failed to discard bytes from the send buffer: " + err.Error())
		}
		os.bufferedMsgs--
		os.bufferedBytes -= float64(size)
	}
	return nil
}
Post a message into the outgoing queue.
package nq
import (
	"context"
	"errors"
	"fmt"
	"math/rand"
	"net"
	"sync"
	"syscall"
	"time"
)
type ostream struct {
	*PubOpts
	addr net.Addr
	mu   sync.Mutex
	e encoder
	frontBuf *ringBuf  
	backBuf  *ringBuf  
	*pubMetrics
	bufferedMsgs  float64
	bufferedBytes float64
}
func newOStream(addr net.Addr, opts *PubOpts, p *pubMetrics) *ostream {
	os := &ostream{
		PubOpts:    opts,
		addr:       addr,
		frontBuf:   &ringBuf{},
		backBuf:    &ringBuf{},
		pubMetrics: p,
	}
	return os
}