Skip to content

Commit

Permalink
with custom marshaller
Browse files Browse the repository at this point in the history
  • Loading branch information
makasim committed Sep 17, 2024
1 parent 549ccfe commit 4fd3b47
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
34 changes: 17 additions & 17 deletions buffered.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@ import (
// NewBuffered creates a new Buffered client.
// Options may be one of the following:
//
// * fluent.WithAddress
// * fluent.WithBufferLimit
// * fluent.WithDialTimeout
// * fluent.WithJSONMarshaler
// * fluent.WithMaxConnAttempts
// * fluent.WithMsgpackMarshaler
// * fluent.WithNetwork
// * fluent.WithTagPrefix
// * fluent.WithWriteThreshold
// * fluent.WithWriteQueueSize
// - fluent.WithAddress
// - fluent.WithBufferLimit
// - fluent.WithDialTimeout
// - fluent.WithJSONMarshaler
// - fluent.WithMaxConnAttempts
// - fluent.WithMsgpackMarshaler
// - fluent.WithMarshaller
// - fluent.WithNetwork
// - fluent.WithTagPrefix
// - fluent.WithWriteThreshold
// - fluent.WithWriteQueueSize
//
// Please see their respective documentation for details.
func NewBuffered(options ...Option) (client *Buffered, err error) {
Expand Down Expand Up @@ -62,17 +63,16 @@ func NewBuffered(options ...Option) (client *Buffered, err error) {
// If you would like to specify options to `Post()`, you may pass them at the end of
// the method. Currently you can use the following:
//
// fluent.WithContext: specify context.Context to use
// fluent.WithTimestamp: allows you to set arbitrary timestamp values
// fluent.WithSyncAppend: allows you to verify if the append was successful
// fluent.WithContext: specify context.Context to use
// fluent.WithTimestamp: allows you to set arbitrary timestamp values
// fluent.WithSyncAppend: allows you to verify if the append was successful
//
// If fluent.WithSyncAppend is provide and is true, the following errors
// may be returned:
//
// 1. If the current underlying pending buffer is is not large enough to
// hold this new data, an error will be returned
// 2. If the marshaling into msgpack/json failed, it is returned
//
// 1. If the current underlying pending buffer is is not large enough to
// hold this new data, an error will be returned
// 2. If the marshaling into msgpack/json failed, it is returned
func (c *Buffered) Post(tag string, v interface{}, options ...Option) (err error) {
if pdebug.Enabled {
g := pdebug.Marker("fluent.Buffered.Post").BindError(&err)
Expand Down
6 changes: 6 additions & 0 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ func WithJSONMarshaler() Option {
return option.New(identMarshaler{}, marshalFunc(jsonMarshal))
}

// WithMarshaller specifies a custom marshaling to be used when
// sending messages to fluentd. Used for `fluent.New`
func WithMarshaller(m marshaler) Option {
return option.New(identMarshaler{}, m)
}

// WithMsgpackMarshaler specifies msgpack marshaling to be used when
// sending messages to fluentd. Used in `fluent.New`
func WithMsgpackMarshaler() Option {
Expand Down

0 comments on commit 4fd3b47

Please sign in to comment.