func (t *AsyncTransport) Wait() {
	t.waitGroup.Wait()
}
Wait blocks until all of the items currently in the queue have been sent.
package rollbar
import (
	"sync"
	"time"
)
type AsyncTransport struct {
	baseTransport
	Buffer      int
	bodyChannel chan payload
	waitGroup   sync.WaitGroup
}
type payload struct {
	body        map[string]interface{}
	retriesLeft int
}
func NewAsyncTransport(token string, endpoint string, buffer int) *AsyncTransport {
	transport := &AsyncTransport{
		baseTransport: baseTransport{
			Token:               token,
			Endpoint:            endpoint,
			RetryAttempts:       DefaultRetryAttempts,
			PrintPayloadOnError: true,
			ItemsPerMinute:      0,
		},
		bodyChannel: make(chan payload, buffer),
		Buffer:      buffer,
	}
	go func() {
		for p := range transport.bodyChannel {
			elapsedTime := time.Now().Sub(transport.startTime).Seconds()
			if elapsedTime < 0 || elapsedTime >= 60 {
				transport.startTime = time.Now()
				transport.perMinCounter = 0
			}
			if transport.shouldSend() {
				canRetry, err := transport.post(p.body)
				if err != nil {
					if canRetry && p.retriesLeft > 0 {
						p.retriesLeft -= 1
						select {
						case transport.bodyChannel <- p:
						default:
							if transport.PrintPayloadOnError {
								writePayloadToStderr(transport.Logger, p.body)
							}
							transport.waitGroup.Done()
						}
					} else {
						if transport.PrintPayloadOnError {
							writePayloadToStderr(transport.Logger, p.body)
						}
						transport.waitGroup.Done()
					}
				} else {
					transport.waitGroup.Done()
					transport.perMinCounter++
				}
			} else {
				transport.waitGroup.Done()
			}
		}
	}()
	return transport
}
func (t *AsyncTransport) Send(body map[string]interface{}) error {
	if len(t.bodyChannel) < t.Buffer {
		t.waitGroup.Add(1)
		p := payload{
			body:        body,
			retriesLeft: t.RetryAttempts,
		}
		t.bodyChannel <- p
	} else {
		err := ErrBufferFull{}
		rollbarError(t.Logger, err.Error())
		if t.PrintPayloadOnError {
			writePayloadToStderr(t.Logger, body)
		}
		return err
	}
	return nil
}