This repository has been archived by the owner on Jul 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconsts.go
55 lines (44 loc) · 1.94 KB
/
consts.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
55
package snmp
import (
"log"
"time"
)
const (
defaultRetry = 2
defaultRetryAfter = time.Second
// DefaultChanSize represents the default queue size of MessageSender.MC and MessageSender.TC
DefaultChanSize = 20
// ErrTimedOut is emitted when the server did not respond in time
ErrTimedOut = errTimedOut("Timed Out")
// ErrWalkSingleOid is emitted when a snmpgo.GetBulkRequest PDU type with
// MessageRequest.DontWant set to false requested, but 0 or more than one
// OIDS were provided
ErrWalkSingleOid = errWalkSingleOid("bulkwalk only supports a single OID")
// ErrCancelViaUpdate is emitted when a TableRequest.Update function callback is
// non-nil and the invokign it returns true
ErrCancelViaUpdate = errCancelViaUpdate("cancellation requested by TableRequest.Update(...) returning true")
// DefaultErrorLogger (which implements ErrorLogger) is used when the error logger
// passed into NewMessageSender and NewMessageSenderWithConn is nil. It is called
// when an error occurs, namely the code is unable to marshal or unmarshal a
// message, or a socket read error occurs), or a validation step failed, this
// type is called with the error
DefaultErrorLogger = defaultErrorLogger("I am the default error logger!")
)
type errTimedOut string
func (e errTimedOut) Error() string { return string(e) }
type errWalkSingleOid string
func (e errWalkSingleOid) Error() string { return string(e) }
type errCancelViaUpdate string
func (e errCancelViaUpdate) Error() string { return string(e) }
// ErrorLogger is used when the error logger
// passed into NewMessageSender and NewMessageSenderWithConn is nil. It is called
// when an error occurs, namely the code is unable to marshal or unmarshal a
// message, or a socket read error occurs), or a validation step failed, this
// type is called with the error
type ErrorLogger interface {
Log(err error)
}
type defaultErrorLogger string
func (l defaultErrorLogger) Log(err error) {
log.Print(err.Error())
}