func (c *Buffered) Close() error {
	c.muClosed.Lock()
	c.closed = true
	if c.minionQueue != nil {
		close(c.minionQueue)
		c.minionQueue = nil
	}
	if c.pingQueue != nil {
		close(c.pingQueue)
		c.pingQueue = nil
	}
	c.muClosed.Unlock()
	c.minionCancel()
	return nil
}
Close closes the connection, but does not wait for the pending buffers
to be flushed. If you want to make sure that background minion has properly
exited, you should probably use the Shutdown() method
package fluent
import (
	"context"
	"time"
	pdebug "github.com/lestrrat-go/pdebug"
	"github.com/pkg/errors"
)
func NewBuffered(options ...Option) (client *Buffered, err error) {
	if pdebug.Enabled {
		g := pdebug.Marker("fluent.NewBuffered").BindError(&err)
		defer g.End()
	}
	m, err := newMinion(options...)
	if err != nil {
		return nil, err
	}
	var c Buffered
	ctx, cancel := context.WithCancel(context.Background())
	var subsecond bool
	for _, opt := range options {
		switch opt.Ident() {
		case identSubSecond{}:
			subsecond = opt.Value().(bool)
		}
	}
	c.minionDone = m.done
	c.minionQueue = m.incoming
	c.minionCancel = cancel
	c.pingQueue = m.pingCh
	c.subsecond = subsecond
	go m.runReader(ctx)
	go m.runWriter(ctx)
	return &c, nil
}
func (c *Buffered) Post(tag string, v interface{}, options ...Option) (err error) {
	if pdebug.Enabled {
		g := pdebug.Marker("fluent.Buffered.Post").BindError(&err)
		defer g.End()
	}
	c.muClosed.RLock()
	defer c.muClosed.RUnlock()
	if c.closed {
		return errors.New(`client has already been closed`)
	}
	var syncAppend bool
	var subsecond = c.subsecond
	var t time.Time
	var ctx = context.Background()
	for _, opt := range options {
		switch opt.Ident() {
		case identTimestamp{}:
			t = opt.Value().(time.Time)
		case identSyncAppend{}:
			syncAppend = opt.Value().(bool)
		case identSubSecond{}:
			subsecond = opt.Value().(bool)
		case identContext{}:
			if pdebug.Enabled {
				pdebug.Printf("client: using user-supplied context")
			}
			ctx = opt.Value().(context.Context)
		}
	}
	if t.IsZero() {
		t = time.Now()
	}
	msg := makeMessage(tag, v, t, subsecond, syncAppend)
	var replyCh = msg.replyCh
	if syncAppend {
		if pdebug.Enabled {
			pdebug.Printf("client: synchronous append requested. creating channel")
		}
	}
	select {
	case <-ctx.Done():
		return ctx.Err()
	default:
	}
	select {
	case <-ctx.Done():
		return ctx.Err()
	case <-c.minionDone:
		return errors.New("writer has been closed. Shutdown called?")
	case c.minionQueue <- msg:
		if pdebug.Enabled {
			pdebug.Printf("client: wrote message to queue")
		}
	}
	if syncAppend {
		if pdebug.Enabled {
			pdebug.Printf("client: Post is waiting for return status")
		}
		select {
		case <-ctx.Done():
			return ctx.Err()
		case <-c.minionDone:
			return errors.New("writer has been closed. Shutdown called?")
		case e := <-replyCh:
			if pdebug.Enabled {
				pdebug.Printf("client: synchronous result received")
			}
			return e
		}
	}
	return nil
}