Skip to content

Commit

Permalink
feat(cmd/influxd): add nats-max-payload-bytes config option to infl…
Browse files Browse the repository at this point in the history
…uxd (#20564)
  • Loading branch information
danxmoran committed Jan 20, 2021
1 parent d8a4b4d commit e77c467
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -29,6 +29,7 @@ Replacement `tsi1` indexes will be automatically generated on startup for shards
1. [20473](https://github.com/influxdata/influxdb/pull/20473): Add `--overwrite-existing-v2` flag to `influxd upgrade` to overwrite existing files at output paths (instead of aborting).
1. [20524](https://github.com/influxdata/influxdb/pull/20524): Add `influxd print-config` command to support automated config inspection.
1. [20561](https://github.com/influxdata/influxdb/pull/20561): Add `nats-port` config option for `influxd` server.
1. [20564](https://github.com/influxdata/influxdb/pull/20564): Add `nats-max-payload-bytes` config option for `influxd` server.

### Bug Fixes

Expand Down
13 changes: 11 additions & 2 deletions cmd/influxd/launcher/cmd.go
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/influxdata/influxdb/v2/storage"
"github.com/influxdata/influxdb/v2/v1/coordinator"
"github.com/influxdata/influxdb/v2/vault"
natsserver "github.com/nats-io/gnatsd/server"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"go.uber.org/zap/zapcore"
Expand Down Expand Up @@ -128,7 +129,8 @@ type InfluxdOpts struct {
SessionLength int // in minutes
SessionRenewDisabled bool

NatsPort int
NatsPort int
NatsMaxPayloadBytes int

NoTasks bool
FeatureFlags map[string]string
Expand Down Expand Up @@ -174,7 +176,8 @@ func newOpts(viper *viper.Viper) *InfluxdOpts {
StoreType: BoltStore,
SecretStore: BoltStore,

NatsPort: nats.RandomPort,
NatsPort: nats.RandomPort,
NatsMaxPayloadBytes: natsserver.MAX_PAYLOAD_SIZE,

NoTasks: false,

Expand Down Expand Up @@ -485,5 +488,11 @@ func (o *InfluxdOpts) bindCliOpts() []cli.Opt {
Desc: fmt.Sprintf("Port that should be bound by the NATS streaming server. A value of %d will cause a random port to be selected.", nats.RandomPort),
Default: o.NatsPort,
},
{
DestP: &o.NatsMaxPayloadBytes,
Flag: "nats-max-payload-bytes",
Desc: "The maximum number of bytes allowed in a NATS message payload.",
Default: o.NatsMaxPayloadBytes,
},
}
}
1 change: 1 addition & 0 deletions cmd/influxd/launcher/launcher.go
Expand Up @@ -573,6 +573,7 @@ func (m *Launcher) run(ctx context.Context, opts *InfluxdOpts) (err error) {
// NATS streaming server
natsOpts := nats.NewDefaultServerOptions()
natsOpts.Port = opts.NatsPort
natsOpts.MaxPayload = opts.NatsMaxPayloadBytes
m.natsServer = nats.NewServer(&natsOpts)
if err := m.natsServer.Open(); err != nil {
m.log.Error("Failed to start nats streaming server", zap.Error(err))
Expand Down

0 comments on commit e77c467

Please sign in to comment.