debug

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2023 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Install go-enum by `go get -u github.com/searKing/golang/tools/go-enum`

Index

Constants

This section is empty.

Variables

View Source
var (
	Name     = "debug"
	Version  = "v0.0.0"
	CommitID = ""
)
View Source
var DefaultReceiverConfig = ReceiverConfig{
	IntervalMs:         pointer.Int(100),
	Rounds:             pointer.Int(4),
	Payload:            "debug message",
	MaxHistory:         pointer.Int(100),
	TracePayloadOnNack: pointer.Bool(false),
}
View Source
var DefaultSenderConfig = SenderConfig{
	Destination: DestinationDevNull,
	MaxHistory:  pointer.Int(0),
	Writer:      nil,
}
View Source
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 NewPlugin

func NewPlugin() (*pkgplugin.Plugin, error)

func NewPluginVersion

func NewPluginVersion(name string, version string, commitID string) (*pkgplugin.Plugin, error)

func NewReceiver

func NewReceiver(tid tenant.Id, plugin string, name string, config interface{}, secrets secret.Vault, tableSyncer syncer.DeltaSyncer) (receiver.Receiver, error)

func NewSender

func NewSender(tid tenant.Id, plugin string, name string, config interface{}, secrets secret.Vault, tableSyncer syncer.DeltaSyncer) (sender.Sender, error)

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

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 EventWriter interface {
	Write(e event.Event) error
}

type Receiver

type Receiver struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*Receiver) Config added in v0.2.1

func (r *Receiver) Config() interface{}

func (*Receiver) Count

func (r *Receiver) Count() int

func (*Receiver) EventErrorCount added in v1.1.2

func (r *Receiver) EventErrorCount() int

func (*Receiver) EventErrorVelocity added in v1.1.2

func (r *Receiver) EventErrorVelocity() int

func (*Receiver) EventSuccessCount added in v1.1.2

func (r *Receiver) EventSuccessCount() int

func (*Receiver) EventSuccessVelocity added in v1.1.2

func (r *Receiver) EventSuccessVelocity() int

func (*Receiver) EventTs added in v1.1.2

func (r *Receiver) EventTs() int64

func (*Receiver) Hash added in v1.1.2

func (r *Receiver) Hash() string

func (*Receiver) History

func (r *Receiver) History() []event.Event

func (*Receiver) LogSuccess added in v1.1.2

func (r *Receiver) LogSuccess()

func (*Receiver) Name added in v0.2.1

func (r *Receiver) Name() string

func (*Receiver) Plugin added in v0.2.1

func (r *Receiver) Plugin() string

func (*Receiver) Receive

func (r *Receiver) Receive(next receiver.NextFn) error

func (*Receiver) StopReceiving

func (r *Receiver) StopReceiving(ctx context.Context) error

func (*Receiver) Tenant added in v0.3.0

func (r *Receiver) Tenant() tenant.Id

func (*Receiver) Trigger

func (r *Receiver) Trigger(e event.Event)

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.

func (*SendSlice) Events

func (s *SendSlice) Events() []event.Event

func (*SendSlice) Write

func (s *SendSlice) Write(e event.Event) error

type SendStderr

type SendStderr struct {
	EventWriter
}

func (*SendStderr) Write

func (s *SendStderr) Write(e event.Event) error

type SendStdout

type SendStdout struct {
	EventWriter
}

func (*SendStdout) Write

func (s *SendStdout) Write(e event.Event) error

type Sender

type Sender struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*Sender) Config added in v0.2.1

func (s *Sender) Config() interface{}

func (*Sender) Count

func (s *Sender) Count() int

func (*Sender) EventErrorCount added in v1.1.2

func (s *Sender) EventErrorCount() int

func (*Sender) EventErrorVelocity added in v1.1.2

func (s *Sender) EventErrorVelocity() int

func (*Sender) EventSuccessCount added in v1.1.2

func (s *Sender) EventSuccessCount() int

func (*Sender) EventSuccessVelocity added in v1.1.2

func (s *Sender) EventSuccessVelocity() int

func (*Sender) EventTs added in v1.1.2

func (s *Sender) EventTs() int64

func (*Sender) Hash added in v1.1.2

func (s *Sender) Hash() string

func (*Sender) History

func (s *Sender) History() []event.Event

func (*Sender) Name added in v0.2.1

func (s *Sender) Name() string

func (*Sender) Plugin added in v0.2.1

func (s *Sender) Plugin() string

func (*Sender) Reset

func (s *Sender) Reset()

func (*Sender) Send

func (s *Sender) Send(e event.Event)

func (*Sender) StopSending

func (s *Sender) StopSending(ctx context.Context)

func (*Sender) Tenant added in v0.3.0

func (s *Sender) Tenant() tenant.Id

func (*Sender) Unwrap

func (s *Sender) Unwrap() sender.Sender

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL