(ep *Endpoint, cfg *Config)
| 28 | // seqHeaderSize is the big-endian sequence number prepended to every queue |
| 29 | // message. Azure Storage Queues are at-least-once and not strictly FIFO, so |
| 30 | // the receiver uses this to dedup and reorder into a clean byte stream. |
| 31 | seqHeaderSize = 8 |
| 32 | // queueSizeMargin keeps the base64-encoded message safely below the 64 KiB |
| 33 | // queue ceiling. See MaxRawSize: base64 expands by 4/3, and the encoded form |
| 34 | // of (seqHeaderSize + sealed chunk) must stay <= MaxQueueTextMessageSize. |
| 35 | queueSizeMargin = 64 |
| 36 | // maxPendingMessages caps the reassembly buffer's memory footprint. Liveness |
| 37 | // is not tied to it: the stall clock in ReadRaw fails a missing sequence. |
| 38 | maxPendingMessages = 256 |
| 39 | // defaultReassemblyStall bounds the wait for a missing sequence when the |
| 40 | // config carries no usable idle timeout. |
| 41 | defaultReassemblyStall = 60 * time.Second |
| 42 | ) |
| 43 | |
| 44 | // ErrReassemblyOverflow is returned when the azqueue reassembly buffer exceeds |
| 45 | // maxPendingMessages, indicating a sequence gap that will not resolve. |
| 46 | var ErrReassemblyOverflow = errors.New("azqueue: reassembly buffer overflow") |
| 47 | |
| 48 | // ErrReassemblyStalled is returned when a sequence gap in the azqueue receive |
| 49 | // stream fails to close within the stall bound, i.e. a message was lost and the |
| 50 | // byte stream can never be completed. |
| 51 | var ErrReassemblyStalled = errors.New("azqueue: reassembly stalled on missing sequence") |
| 52 | |
| 53 | func init() { |
| 54 | RegisterFactory(queueDriverName, &queueFactory{}) |
| 55 | } |
| 56 | |
| 57 | type queueFactory struct{} |
| 58 | |
| 59 | func (d *queueFactory) NewDriver(ep *Endpoint, cfg *Config) (Driver, error) { |
| 60 | client, err := newQueueClient(ep) |
| 61 | if err != nil { |
| 62 | return nil, err |
| 63 | } |
| 64 | |
| 65 | if client != nil { |
| 66 | for _, name := range []string{cfg.handshakeEndpoint, cfg.tokenEndpoint} { |
| 67 | if _, err := client.CreateQueue(cfg.ctx, name, nil); err != nil && !queueerror.HasCode(err, queueerror.QueueAlreadyExists) { |
| 68 | return nil, err |
nothing calls this directly
no test coverage detected