forked from SierraSoftworks/sentry-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsendQueue.go
54 lines (44 loc) · 1.56 KB
/
sendQueue.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package sentry
// A SendQueue is used by the Sentry client to coordinate the transmission
// of events. Custom queues can be used to control parallelism and circuit
// breaking as necessary.
type SendQueue interface {
// Enqueue is called by clients wishing to send an event to Sentry.
// It is provided with a Config and Packet and is expected to return
// a QueuedEvent compatible object which an application can use to
// access information about whether the event was sent successfully
// or not.
Enqueue(conf Config, packet Packet) QueuedEvent
// Shutdown is called by a client that wishes to stop the flow of
// events through a SendQueue.
Shutdown(wait bool)
}
const (
// ErrSendQueueFull is used when an attempt to enqueue a
// new event fails as a result of no buffer space being available.
ErrSendQueueFull = ErrType("sentry: send queue was full")
// ErrSendQueueShutdown is used when an attempt to enqueue
// a new event fails as a result of the queue having been shutdown
// already.
ErrSendQueueShutdown = ErrType("sentry: send queue was shutdown")
)
func init() {
AddDefaultOptions(UseSendQueue(NewSequentialSendQueue(100)))
}
// UseSendQueue allows you to specify the send queue that will be used
// by a client.
func UseSendQueue(queue SendQueue) Option {
if queue == nil {
return nil
}
return &sendQueueOption{queue}
}
type sendQueueOption struct {
queue SendQueue
}
func (o *sendQueueOption) Class() string {
return "sentry-go.sendqueue"
}
func (o *sendQueueOption) Omit() bool {
return true
}