Documentation ¶
Overview ¶
Install go-enum by `go get -u github.com/searKing/golang/tools/go-enum`
Index ¶
- Variables
- func DestinationTypeSliceContains(enums []DestinationType, sunEnums ...DestinationType) bool
- func DestinationTypeSliceContainsAny(enums []DestinationType, sunEnums ...DestinationType) bool
- func NewPlugin() (*pkgplugin.Plugin, error)
- func NewPluginVersion(name string, version string, commitID string) (*pkgplugin.Plugin, error)
- func NewReceiver(tid tenant.Id, plugin string, name string, config interface{}, ...) (receiver.Receiver, error)
- func NewSender(tid tenant.Id, plugin string, name string, config interface{}, ...) (sender.Sender, error)
- type DestinationType
- func (i DestinationType) MarshalBinary() (data []byte, err error)
- func (i DestinationType) MarshalJSON() ([]byte, error)
- func (i DestinationType) MarshalText() ([]byte, error)
- func (i DestinationType) MarshalYAML() (interface{}, error)
- func (i DestinationType) New() *DestinationType
- func (i DestinationType) Registered() bool
- func (i DestinationType) String() string
- func (i *DestinationType) UnmarshalBinary(data []byte) error
- func (i *DestinationType) UnmarshalJSON(data []byte) error
- func (i *DestinationType) UnmarshalText(text []byte) error
- func (i *DestinationType) UnmarshalYAML(unmarshal func(interface{}) error) error
- type EventWriter
- type Receiver
- func (r *Receiver) Config() interface{}
- func (r *Receiver) Count() int
- func (r *Receiver) EventErrorCount() int
- func (r *Receiver) EventErrorVelocity() int
- func (r *Receiver) EventSuccessCount() int
- func (r *Receiver) EventSuccessVelocity() int
- func (r *Receiver) EventTs() int64
- func (r *Receiver) Hash() string
- func (r *Receiver) History() []event.Event
- func (r *Receiver) LogSuccess()
- func (r *Receiver) Name() string
- func (r *Receiver) Plugin() string
- func (r *Receiver) Receive(next receiver.NextFn) error
- func (r *Receiver) StopReceiving(ctx context.Context) error
- func (r *Receiver) Tenant() tenant.Id
- func (r *Receiver) Trigger(e event.Event)
- type ReceiverConfig
- type SendSlice
- type SendStderr
- type SendStdout
- type Sender
- func (s *Sender) Config() interface{}
- func (s *Sender) Count() int
- func (s *Sender) EventErrorCount() int
- func (s *Sender) EventErrorVelocity() int
- func (s *Sender) EventSuccessCount() int
- func (s *Sender) EventSuccessVelocity() int
- func (s *Sender) EventTs() int64
- func (s *Sender) Hash() string
- func (s *Sender) History() []event.Event
- func (s *Sender) Name() string
- func (s *Sender) Plugin() string
- func (s *Sender) Reset()
- func (s *Sender) Send(e event.Event)
- func (s *Sender) StopSending(ctx context.Context)
- func (s *Sender) Tenant() tenant.Id
- func (s *Sender) Unwrap() sender.Sender
- type SenderConfig
Constants ¶
This section is empty.
Variables ¶
var ( Name = "debug" Version = "v0.0.0" CommitID = "" )
var DefaultReceiverConfig = ReceiverConfig{ IntervalMs: pointer.Int(100), Rounds: pointer.Int(4), Payload: "debug message", MaxHistory: pointer.Int(100), TracePayloadOnNack: pointer.Bool(false), }
var DefaultSenderConfig = SenderConfig{ Destination: DestinationDevNull, MaxHistory: pointer.Int(0), Writer: nil, }
var InfiniteRounds = pointer.Int(-1)
Functions ¶
func DestinationTypeSliceContains ¶
func DestinationTypeSliceContains(enums []DestinationType, sunEnums ...DestinationType) bool
DestinationTypeSliceContains reports whether sunEnums is within enums.
func DestinationTypeSliceContainsAny ¶
func DestinationTypeSliceContainsAny(enums []DestinationType, sunEnums ...DestinationType) bool
DestinationTypeSliceContainsAny reports whether any sunEnum is within enums.
func NewPluginVersion ¶
func NewReceiver ¶
Types ¶
type DestinationType ¶
type DestinationType int
const ( DestinationUnknown DestinationType = iota // unknown DestinationDevNull // devnull DestinationStdout // stdout DestinationStderr // stderr DestinationCustom // custom )
func DestinationTypeValues ¶
func DestinationTypeValues() []DestinationType
DestinationTypeValues returns all values of the enum
func ParseDestinationTypeString ¶
func ParseDestinationTypeString(s string) (DestinationType, error)
ParseDestinationTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func (DestinationType) MarshalBinary ¶
func (i DestinationType) MarshalBinary() (data []byte, err error)
MarshalBinary implements the encoding.BinaryMarshaler interface for DestinationType
func (DestinationType) MarshalJSON ¶
func (i DestinationType) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface for DestinationType
func (DestinationType) MarshalText ¶
func (i DestinationType) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface for DestinationType
func (DestinationType) MarshalYAML ¶
func (i DestinationType) MarshalYAML() (interface{}, error)
MarshalYAML implements a YAML Marshaler for DestinationType
func (DestinationType) New ¶
func (i DestinationType) New() *DestinationType
New returns a pointer to a new addr filled with the DestinationType value passed in.
func (DestinationType) Registered ¶
func (i DestinationType) Registered() bool
IsADestinationType returns "true" if the value is listed in the enum definition. "false" otherwise
func (DestinationType) String ¶
func (i DestinationType) String() string
func (*DestinationType) UnmarshalBinary ¶
func (i *DestinationType) UnmarshalBinary(data []byte) error
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface for DestinationType
func (*DestinationType) UnmarshalJSON ¶
func (i *DestinationType) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface for DestinationType
func (*DestinationType) UnmarshalText ¶
func (i *DestinationType) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface for DestinationType
func (*DestinationType) UnmarshalYAML ¶
func (i *DestinationType) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML implements a YAML Unmarshaler for DestinationType
type EventWriter ¶
type Receiver ¶
func (*Receiver) EventErrorCount ¶ added in v1.1.2
func (*Receiver) EventErrorVelocity ¶ added in v1.1.2
func (*Receiver) EventSuccessCount ¶ added in v1.1.2
func (*Receiver) EventSuccessVelocity ¶ added in v1.1.2
func (*Receiver) LogSuccess ¶ added in v1.1.2
func (r *Receiver) LogSuccess()
type ReceiverConfig ¶
type ReceiverConfig struct { IntervalMs *int `json:"intervalMs,omitempty"` Rounds *int `json:"rounds,omitempty"` // (-1) signifies infinite routes Payload interface{} `json:"payload,omitempty"` MaxHistory *int `json:"maxHistory,omitempty"` TracePayloadOnNack *bool `json:"tracePayloadOnNack,omitempty"` }
func (*ReceiverConfig) Validate ¶
func (rc *ReceiverConfig) Validate() error
Validate returns an error upon validation failure
func (*ReceiverConfig) WithDefaults ¶
func (rc *ReceiverConfig) WithDefaults() ReceiverConfig
WithDefaults returns a new config object that has all of the unset (nil) values filled in.
type SendSlice ¶
type SendSlice struct { EventWriter sync.Mutex // contains filtered or unexported fields }
SendSlice is an EventWriter that will store all the events in a slice. The data structure is unbounded, so make sure your debugging will complete after some expected amount of usage. For long running debug sending, make use of SenderConfig.MaxHistory and History() instead.
type SendStderr ¶
type SendStderr struct {
EventWriter
}
type SendStdout ¶
type SendStdout struct {
EventWriter
}
type Sender ¶
func (*Sender) EventErrorCount ¶ added in v1.1.2
func (*Sender) EventErrorVelocity ¶ added in v1.1.2
func (*Sender) EventSuccessCount ¶ added in v1.1.2
func (*Sender) EventSuccessVelocity ¶ added in v1.1.2
func (*Sender) StopSending ¶
type SenderConfig ¶
type SenderConfig struct { // Destination should be set to one of the numerated DestinationType values. Destination DestinationType `json:"destination,omitempty"` // MaxHistory defines the number of past events to keep. Begins replacing the // oldest event when the buffer is full. MaxHistory *int `json:"maxHistory,omitempty"` // Writer defines a custom writer that will be written to on each Send. // Writer should support concurrent writes. Writer EventWriter `json:"-"` }
SenderConfig can be passed into NewSender() in order to configure the behavior of the sender.
func (*SenderConfig) Validate ¶
func (sc *SenderConfig) Validate() error
Validate will ensure that:
- The .Destination is a valid DestinationType and is not DestinationUnknown
- Max history is >= 0
- The .Writer is only set when .Destination is DestinationCustom
func (SenderConfig) WithDefaults ¶
func (sc SenderConfig) WithDefaults() SenderConfig
WithDefaults will set
- The .Destination and .Writer if Destination is DestinationUnknown
- The .MaxHistory if it is nil
The values will be set to the corresponding DefaultSenderConfig.* values