Skip to content

Commit

Permalink
Merge pull request #43 from rogpeppe-contrib/026-codec-none
Browse files Browse the repository at this point in the history
add "none" value codec
  • Loading branch information
skateinmars committed Mar 24, 2022
2 parents 77bb68d + d8cd955 commit e24b378
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions coder.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ func (c *coder) encoderForType(keyOrValue, typ string) (func([]byte) (json.RawMe
}
case "avro":
return c.encodeAvro, nil
case "none":
return func([]byte) (json.RawMessage, error) {
return nil, nil
}, nil
default:
return nil, fmt.Errorf(`unsupported decoder %#v, only json, string, hex, base64 and avro are supported`, typ)
}
Expand Down
4 changes: 2 additions & 2 deletions consume.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type consumedMessage struct {
Partition int32 `json:"partition"`
Offset int64 `json:"offset"`
Key json.RawMessage `json:"key,omitempty"`
Value json.RawMessage `json:"value"`
Value json.RawMessage `json:"value,omitempty"`
Time *time.Time `json:"time,omitempty"`
}

Expand All @@ -56,7 +56,7 @@ func (cmd *consumeCmd) addFlags(flags *flag.FlagSet) {
flags.StringVar(&cmd.keyStr, "key", "", "Print only messages with this key. Note: this relies on the producer using one of the partitioning algorithms specified with the -partitioners argument")
flags.BoolVar(&cmd.pretty, "pretty", true, "Control output pretty printing.")
flags.BoolVar(&cmd.follow, "f", false, "Follow topic by waiting new messages (default is to stop at end of topic)")
flags.StringVar(&cmd.valueCodecType, "valuecodec", "json", "Present message value as (json|string|hex|base64|avro), defaults to json.")
flags.StringVar(&cmd.valueCodecType, "valuecodec", "json", "Present message value as (json|string|hex|base64|avro|none), defaults to json.")
flags.StringVar(&cmd.keyCodecType, "keycodec", "string", "Present message key as (string|hex|base64), defaults to string.")

flags.Usage = func() {
Expand Down

0 comments on commit e24b378

Please sign in to comment.