Documentation
¶
Overview ¶
Package cloudlog provides a CloudLog client library
Index ¶
- Variables
- func GetDefaultSaramaConfig() sarama.Config
- func IsEventEncodingError(err error) (ok bool, event interface{})
- type CloudLog
- type Event
- type EventEncoder
- type EventEncodingError
- type MarshalError
- type Option
- func OptionBrokers(broker string, brokers ...string) Option
- func OptionCACertificate(pemBlock []byte) Option
- func OptionCACertificateFile(path string) Option
- func OptionClientCertificateFile(certFile, keyFile string) Option
- func OptionClientCertificates(certs []tls.Certificate) Option
- func OptionEventEncoder(encoder EventEncoder) Option
- func OptionSaramaConfig(config sarama.Config) Option
- func OptionSourceHost(hostname string) Option
- func OptionTLSConfig(tlsConfig *tls.Config) Option
- type SimpleEventEncoder
Constants ¶
This section is empty.
Variables ¶
var ( // ErrCACertificateInvalid indicates that the supplied CA certificate is invalid ErrCACertificateInvalid = errors.New("CA certificate is invalid") // ErrCertificateMissing indicates that the client certificate is missing ErrCertificateMissing = errors.New("Client certificate is missing") // ErrIndexNotDefined indicates that the target index has not been defined ErrIndexNotDefined = errors.New("Target index is not defined") )
Functions ¶
func GetDefaultSaramaConfig ¶
GetDefaultSaramaConfig returns a copy of the default sarama config. The configuration returned by this function should be used as a basline configuration for modifications and changes.
func IsEventEncodingError ¶
IsEventEncodingError checks if a supplied error is an EventEncodingError and returns a boolean flag and the event that caused the error
Types ¶
type CloudLog ¶
type CloudLog struct {
// contains filtered or unexported fields
}
CloudLog is the CloudLog object to send logs
func InitCloudLog ¶
InitCloudLog validates and initializes the CloudLog client
func NewCloudLog ¶
NewCloudLog initializes a new CloudLog instance
func (*CloudLog) PushEvents ¶
PushEvents sends the supplied events to CloudLog
type Event ¶
type Event interface { // Encode encodes the given event to a map[string]interface{} Encode() map[string]interface{} }
Event defines the interface events may optionally implement to provide their own encoding logic
type EventEncoder ¶
type EventEncoder interface { // EncodeEvent encodes the given event EncodeEvent(event interface{}) (map[string]interface{}, error) }
EventEncoder defines the interface for encoding events
type EventEncodingError ¶
type EventEncodingError struct { Message string Event interface{} }
EventEncodingError indicates that an event could not be encoded
func NewUnsupportedEventType ¶
func NewUnsupportedEventType(event interface{}) *EventEncodingError
NewUnsupportedEventType constructs a new EventEncodingError that indicates that the supplied event type is unsupported
func (*EventEncodingError) Error ¶
func (e *EventEncodingError) Error() string
type MarshalError ¶
type MarshalError struct { // EventMap contains the events data map EventMap map[string]interface{} // Parent contains the parent error Parent error }
MarshalError represents a marshalling error
func NewMarshalError ¶
func NewMarshalError(eventMap map[string]interface{}, parent error) *MarshalError
NewMarshalError returns a new MarshalError
func (*MarshalError) Error ¶
func (e *MarshalError) Error() string
func (*MarshalError) WrappedErrors ¶
func (e *MarshalError) WrappedErrors() []error
WrappedErrors returns the wrapped parent error
type Option ¶
Option defines the type used for applying options to CloudLog
func OptionBrokers ¶
OptionBrokers defines the list of event brokers to use
func OptionCACertificate ¶
OptionCACertificate sets the CA certificate CloudLog uses
func OptionCACertificateFile ¶
OptionCACertificateFile loads the CA certificate from the supplied paths and configures CloudLog to use this CA certificate
func OptionClientCertificateFile ¶
OptionClientCertificateFile configures CloudLog to use the certificate and key contained in the supplied paths as client certificate
func OptionClientCertificates ¶
func OptionClientCertificates(certs []tls.Certificate) Option
OptionClientCertificates configures CloudLog to use the supplied tls.Certificates as client certificates
func OptionEventEncoder ¶
func OptionEventEncoder(encoder EventEncoder) Option
OptionEventEncoder configures the EventEncoder to use for encoding events
func OptionSaramaConfig ¶
OptionSaramaConfig sets the sarama configuration
func OptionSourceHost ¶
OptionSourceHost configures the sources' hostname
func OptionTLSConfig ¶
OptionTLSConfig defines the TLS configuration CloudLog uses
type SimpleEventEncoder ¶
type SimpleEventEncoder struct { }
SimpleEventEncoder implements a simple event encoder This encoder only supports map[string]interface{}, string and []byte events. A more sophisticated encoder providing support for encoding structs as well is available from the structencoder sub-package.
func (*SimpleEventEncoder) EncodeEvent ¶
func (e *SimpleEventEncoder) EncodeEvent(event interface{}) (map[string]interface{}, error)
EncodeEvent encodes the given event