Skip to content

Commit 5b04f68

Browse files
committed
Rename AsyncStop to ForceStopAsyncSend
Signed-off-by: JamesJJ <jj@fcg.fyi>
1 parent 61880ab commit 5b04f68

File tree

4 files changed

+31
-31
lines changed

4 files changed

+31
-31
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ Since the default is zero value, Write will not time out.
6969
Enable asynchronous I/O (connect and write) for sending events to Fluentd.
7070
The default is false.
7171

72-
### AsyncStop
72+
### ForceStopAsyncSend
7373

74-
Enables discarding bufferred events when Close() is called in Async mode. If Fluentd is continuously unavailable, Close() will block forever otherwise.
74+
When Async is enabled, immediately discard the event queue on close() and return (instead of trying MaxRetry times for each event in the queue before returning)
7575
The default is false.
7676

7777
### RequestAck

fluent/fluent.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,19 @@ const (
3737
)
3838

3939
type Config struct {
40-
FluentPort int `json:"fluent_port"`
41-
FluentHost string `json:"fluent_host"`
42-
FluentNetwork string `json:"fluent_network"`
43-
FluentSocketPath string `json:"fluent_socket_path"`
44-
Timeout time.Duration `json:"timeout"`
45-
WriteTimeout time.Duration `json:"write_timeout"`
46-
BufferLimit int `json:"buffer_limit"`
47-
RetryWait int `json:"retry_wait"`
48-
MaxRetry int `json:"max_retry"`
49-
MaxRetryWait int `json:"max_retry_wait"`
50-
TagPrefix string `json:"tag_prefix"`
51-
Async bool `json:"async"`
52-
AsyncStop bool `json:"async_stop"`
40+
FluentPort int `json:"fluent_port"`
41+
FluentHost string `json:"fluent_host"`
42+
FluentNetwork string `json:"fluent_network"`
43+
FluentSocketPath string `json:"fluent_socket_path"`
44+
Timeout time.Duration `json:"timeout"`
45+
WriteTimeout time.Duration `json:"write_timeout"`
46+
BufferLimit int `json:"buffer_limit"`
47+
RetryWait int `json:"retry_wait"`
48+
MaxRetry int `json:"max_retry"`
49+
MaxRetryWait int `json:"max_retry_wait"`
50+
TagPrefix string `json:"tag_prefix"`
51+
Async bool `json:"async"`
52+
ForceStopAsyncSend bool `json:"force_stop_async_send"`
5353
// Deprecated: Use Async instead
5454
AsyncConnect bool `json:"async_connect"`
5555
MarshalAsJSON bool `json:"marshal_as_json"`
@@ -307,7 +307,7 @@ func (f *Fluent) EncodeData(tag string, tm time.Time, message interface{}) (msg
307307
// Close closes the connection, waiting for pending logs to be sent
308308
func (f *Fluent) Close() (err error) {
309309
if f.Config.Async {
310-
if f.Config.AsyncStop {
310+
if f.Config.ForceStopAsyncSend {
311311
f.stopRunning <- true
312312
close(f.stopRunning)
313313
}
@@ -360,7 +360,7 @@ func (f *Fluent) run() {
360360
if stopRunning || !ok {
361361
drainEvents = true
362362
}
363-
default:
363+
default:
364364
}
365365
select {
366366
case entry, ok := <-f.pending:

fluent/fluent_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -249,19 +249,19 @@ func TestJsonConfig(t *testing.T) {
249249
}
250250
var got Config
251251
expect := Config{
252-
FluentPort: 8888,
253-
FluentHost: "localhost",
254-
FluentNetwork: "tcp",
255-
FluentSocketPath: "/var/tmp/fluent.sock",
256-
Timeout: 3000,
257-
WriteTimeout: 6000,
258-
BufferLimit: 10,
259-
RetryWait: 5,
260-
MaxRetry: 3,
261-
TagPrefix: "fluent",
262-
Async: false,
263-
AsyncStop: false,
264-
MarshalAsJSON: true,
252+
FluentPort: 8888,
253+
FluentHost: "localhost",
254+
FluentNetwork: "tcp",
255+
FluentSocketPath: "/var/tmp/fluent.sock",
256+
Timeout: 3000,
257+
WriteTimeout: 6000,
258+
BufferLimit: 10,
259+
RetryWait: 5,
260+
MaxRetry: 3,
261+
TagPrefix: "fluent",
262+
Async: false,
263+
ForceStopAsyncSend: false,
264+
MarshalAsJSON: true,
265265
}
266266

267267
err = json.Unmarshal(b, &got)

fluent/testdata/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
"max_retry":3,
1111
"tag_prefix":"fluent",
1212
"async": false,
13-
"async_stop": false,
13+
"force_stop_async_send": false,
1414
"marshal_as_json": true
1515
}

0 commit comments

Comments
 (0)