func()

in client/client.go [483:513]


func (a *ARN) Async(ctx context.Context, n models.Notifications, promise bool) models.Notifications {
	n = n.SetCtx(ctx)
	if promise {
		n = n.SetPromise(conn.PromisePool.Get().(chan error))
		modelmetrics.ActivePromise(context.Background())
	}

	x := n.DataCount()
	switch {
	case x == 0:
		n.SendPromise(nil, a.errs)
		return n
	case x > maxvals.NotificationItems:
		n.SendPromise(models.ErrBatchSize, a.errs)
		return n
	}

	if ctx.Err() != nil {
		n.SendPromise(ctx.Err(), a.errs)
		return n
	}

	select {
	case <-ctx.Done():
		n.SendPromise(ctx.Err(), a.errs)
		return n
	case a.in <- n:
	}

	return n
}