Documentation ¶
Index ¶
- func WrapSerialize[E any](wrapper func([]byte) ([]byte, SimplifiableError), ...) func([]E) ([]byte, SimplifiableError)
- type AzureAuthSharedKey
- type AzureBlobStorageClientConfig
- type AzureClient
- type AzureError
- type BaseClient
- type BaseClientConfig
- type Client
- type ClientRequest
- type EventSink
- type EventSinkMetrics
- type HTTPClient
- type HTTPClientConfig
- type S3Client
- type S3ClientConfig
- type S3Error
- type SimplifiableError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WrapSerialize ¶
func WrapSerialize[E any]( wrapper func([]byte) ([]byte, SimplifiableError), base func([]E) ([]byte, SimplifiableError), ) func([]E) ([]byte, SimplifiableError)
WrapSerialize is a combinator that takes an existing function valid for Client.SerializeBatch and produces a new function that applies the 'wrapper' function to the output before returning it.
This can be used, for example, to provide a SerializeBatch implementation that gzips the data after encoding it as JSON, e.g., by:
WrapSerialize(GZIPCompress, JSONLinesMarshalBatch)
Types ¶
type AzureAuthSharedKey ¶
type AzureAuthSharedKey struct {}
type AzureBlobStorageClientConfig ¶
type AzureBlobStorageClientConfig struct { // In Azure a Container is close to a bucket in AWS S3 Container string `json:"container"` // Example Endpoint: "https://MYSTORAGEACCOUNT.blob.core.windows.net/" Endpoint string `json:"endpoint"` }
type AzureClient ¶
type AzureClient struct {
// contains filtered or unexported fields
}
func NewAzureBlobStorageClient ¶
func NewAzureBlobStorageClient( cfg AzureBlobStorageClientConfig, generateKey func() string, ) (*AzureClient, error)
func NewAzureBlobStorageClientWithBaseClient ¶
func NewAzureBlobStorageClientWithBaseClient( client *azblob.Client, cfg AzureBlobStorageClientConfig, generateKey func() string, ) *AzureClient
func (AzureClient) NewRequest ¶
func (c AzureClient) NewRequest() ClientRequest
NewRequest implements BaseClient
type AzureError ¶
type AzureError struct {
Err error
}
func (AzureError) Error ¶
func (e AzureError) Error() string
func (AzureError) Simplified ¶
func (e AzureError) Simplified() string
func (AzureError) Unwrap ¶
func (e AzureError) Unwrap() error
type BaseClient ¶
type BaseClient interface {
NewRequest() ClientRequest
}
BaseClient is the shared lower-level interface to send the processed data somewhere.
It's split into the client itself, intended to be used as a kind of persistent object, and a separate ClientRequest object, intended to be used only for the lifetime of a single request.
See S3Client, AzureBlobClient, and HTTPClient.
type BaseClientConfig ¶
type Client ¶
type Client[E any] struct { Name string Base BaseClient BaseConfig BaseClientConfig SerializeBatch func(events []E) ([]byte, SimplifiableError) }
type ClientRequest ¶
type ClientRequest interface { LogFields() zap.Field Send(ctx context.Context, payload []byte) SimplifiableError }
ClientRequest is the abstract interface for a single request to send a batch of processed data.
This exists as a separate interface because there are some request-scoped values that we'd like to include in the call to LogFields().
type EventSink ¶
type EventSink[E any] struct { // contains filtered or unexported fields }
func NewEventSink ¶
type EventSinkMetrics ¶
type EventSinkMetrics struct {
// contains filtered or unexported fields
}
func NewEventSinkMetrics ¶
func NewEventSinkMetrics(prefix string) *EventSinkMetrics
func (*EventSinkMetrics) MustRegister ¶
func (m *EventSinkMetrics) MustRegister(reg *prometheus.Registry)
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
func NewHTTPClient ¶
func NewHTTPClient(client *http.Client, cfg HTTPClientConfig) HTTPClient
func (HTTPClient) NewRequest ¶
func (c HTTPClient) NewRequest() ClientRequest
NewRequest implements BaseClient
type HTTPClientConfig ¶
type S3Client ¶
type S3Client struct {
// contains filtered or unexported fields
}
S3Client is a BaseClient for S3
func NewS3Client ¶
func (*S3Client) NewRequest ¶
func (c *S3Client) NewRequest() ClientRequest
NewRequest implements BaseClient
type S3ClientConfig ¶
type SimplifiableError ¶
SimplifiableError is an extension of the standard 'error' interface that provides a safe-for-metrics string representing the error.
func GZIPCompress ¶
func GZIPCompress(payload []byte) ([]byte, SimplifiableError)
GZIPCompress is a helper function to compress a byte string with gzip
func JSONLinesMarshalBatch ¶
func JSONLinesMarshalBatch[E any](events []E) ([]byte, SimplifiableError)
JSONLinesMarshalBatch is a function to implement Client.SerializeBatch by serializing each event in the batch onto a separate JSON line.
See also: JSONMarshalBatch
func JSONMarshalBatch ¶
func JSONMarshalBatch[V any](value V) ([]byte, SimplifiableError)
JSONMarshalBatch is a helper function to trivially build a function satisfying Client.SerializeBatch.
This function can't *directly* be used, because it takes any type as input, but a small wrapper function typically will suffice.
Why not take a list directly? Sometimes there's a small amount of wrapping we'd like to do, e.g. packaging it as a struct instead of directly an array.
See also: JSONLinesMarshalBatch, which *can* be used directly.