Skip to content

Commit 230c9d2

Browse files
committed
fix
1 parent 716dc02 commit 230c9d2

5 files changed

Lines changed: 30 additions & 19 deletions

File tree

‎e2e/start_work_test.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ func TestE2EStabilityWorkCase(t *testing.T) {
186186
onlyConfigure: true,
187187
},
188188
{
189-
name: "file_socket",
189+
name: "file_socket_tcp",
190190
e2eTest: &file_socket.Config{
191191
Count: 10,
192192
Network: "tcp",
@@ -195,7 +195,7 @@ func TestE2EStabilityWorkCase(t *testing.T) {
195195
cfgPath: "./file_socket/config.yml",
196196
},
197197
{
198-
name: "file_socket",
198+
name: "file_socket_udp",
199199
e2eTest: &file_socket.Config{
200200
Count: 10,
201201
Network: "udp",

‎plugin/README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,8 @@ pipelines:
914914
It sends events to a socket endpoint.
915915
Supports TCP, UDP, and Unix socket protocols.
916916

917-
Events are sent in batches serialized as newline-delimited JSON, compatible with the socket input plugin.
917+
Events are sent in batches serialized as newline-delimited JSON by default, compatible with the socket input plugin.
918+
The delimiter used to separate messages is configurable and can be changed in the plugin configuration (default: `\n`).
918919
If a network error occurs, the batch will be retried according to the backoff settings.
919920

920921
Supports [dead queue](/plugin/output/README.md#dead-queue).

‎plugin/output/README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ pipelines:
153153
It sends events to a socket endpoint.
154154
Supports TCP, UDP, and Unix socket protocols.
155155
156-
Events are sent in batches serialized as newline-delimited JSON, compatible with the socket input plugin.
156+
Events are sent in batches serialized as newline-delimited JSON by default, compatible with the socket input plugin.
157+
The delimiter used to separate messages is configurable and can be changed in the plugin configuration (default: `\n`).
157158
If a network error occurs, the batch will be retried according to the backoff settings.
158159

159160
Supports [dead queue](/plugin/output/README.md#dead-queue).

‎plugin/output/socket/README.md‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
It sends events to a socket endpoint.
33
Supports TCP, UDP, and Unix socket protocols.
44

5-
Events are sent in batches serialized as newline-delimited JSON, compatible with the socket input plugin.
5+
Events are sent in batches serialized as newline-delimited JSON by default, compatible with the socket input plugin.
6+
The delimiter used to separate messages is configurable and can be changed in the plugin configuration (default: `\n`).
67
If a network error occurs, the batch will be retried according to the backoff settings.
78

89
Supports [dead queue](/plugin/output/README.md#dead-queue).
@@ -17,6 +18,7 @@ pipelines:
1718
type: socket
1819
network: tcp
1920
address: ':6666'
21+
delimiter: '\t'
2022
...
2123
```
2224
---
@@ -29,6 +31,7 @@ pipelines:
2931
type: socket
3032
network: tcp
3133
address: ':6666'
34+
delimiter: '\n'
3235
ca_cert: './client.pem'
3336
private_key: './client.key'
3437
...
@@ -76,6 +79,12 @@ Examples:
7679

7780
<br>
7881

82+
**`delimiter`** *`string`* *`default=\n`*
83+
84+
Delimiter to append after each event. Must be exactly one byte.
85+
86+
<br>
87+
7988
**`ca_cert`** *`string`*
8089

8190
Client certificate in PEM encoding. This can be a path or the contents of the file.
@@ -100,6 +109,7 @@ It defines how much time to wait for the connection.
100109

101110
Timeout for writing a single batch to the socket.
102111
> Set to `0` to disable.
112+
> **Must be at least `1s` if non-zero.**
103113
104114
<br>
105115

@@ -159,11 +169,5 @@ Multiplier for exponential increase of retention between retries
159169

160170
<br>
161171

162-
**`delimiter`** *`string`* *`default=\n`*
163-
164-
Delimiter to append after each event. Must be exactly one byte.
165-
166-
<br>
167-
168172

169173
<br>*Generated using [__insane-doc__](https://github.com/vitkovskii/insane-doc)*

‎plugin/output/socket/socket.go‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/ozontech/file.d/fd"
1212
"github.com/ozontech/file.d/metric"
1313
"github.com/ozontech/file.d/pipeline"
14+
"github.com/ozontech/file.d/xtime"
1415
"github.com/ozontech/file.d/xtls"
1516
"go.uber.org/zap"
1617
"go.uber.org/zap/zapcore"
@@ -20,7 +21,8 @@ import (
2021
It sends events to a socket endpoint.
2122
Supports TCP, UDP, and Unix socket protocols.
2223
23-
Events are sent in batches serialized as newline-delimited JSON, compatible with the socket input plugin.
24+
Events are sent in batches serialized as newline-delimited JSON by default, compatible with the socket input plugin.
25+
The delimiter used to separate messages is configurable and can be changed in the plugin configuration (default: `\n`).
2426
If a network error occurs, the batch will be retried according to the backoff settings.
2527
2628
Supports [dead queue](/plugin/output/README.md#dead-queue).
@@ -36,6 +38,7 @@ pipelines:
3638
type: socket
3739
network: tcp
3840
address: ':6666'
41+
delimiter: '\t'
3942
...
4043
```
4144
---
@@ -48,6 +51,7 @@ pipelines:
4851
type: socket
4952
network: tcp
5053
address: ':6666'
54+
delimiter: '\n'
5155
ca_cert: './client.pem'
5256
private_key: './client.key'
5357
...
@@ -118,6 +122,12 @@ type Config struct {
118122
// > - /tmp/filed.sock
119123
Address string `json:"address" required:"true"` // *
120124

125+
// > @3@4@5@6
126+
// >
127+
// > Delimiter to append after each event. Must be exactly one byte.
128+
Delimiter string `json:"delimiter" default:"\n"` // *
129+
Delimiter_ byte
130+
121131
// > @3@4@5@6
122132
// >
123133
// > Client certificate in PEM encoding. This can be a path or the contents of the file.
@@ -140,6 +150,7 @@ type Config struct {
140150
// >
141151
// > Timeout for writing a single batch to the socket.
142152
// >> Set to `0` to disable.
153+
// >> **Must be at least `1s` if non-zero.**
143154
WriteTimeout cfg.Duration `json:"write_timeout" default:"5s" parse:"duration"` // *
144155
WriteTimeout_ time.Duration
145156

@@ -195,12 +206,6 @@ type Config struct {
195206
// >
196207
// > Multiplier for exponential increase of retention between retries
197208
RetentionExponentMultiplier int `json:"retention_exponentially_multiplier" default:"2"` // *
198-
199-
// > @3@4@5@6
200-
// >
201-
// > Delimiter to append after each event. Must be exactly one byte.
202-
Delimiter string `json:"delimiter" default:"\n"` // *
203-
Delimiter_ byte
204209
}
205210

206211
type data struct {
@@ -357,7 +362,7 @@ func (p *Plugin) out(workerData *pipeline.WorkerData, batch *pipeline.Batch) err
357362
data.outBuf = outBuf
358363

359364
if p.config.WriteTimeout_ > 0 {
360-
_ = data.conn.SetWriteDeadline(time.Now().Add(p.config.WriteTimeout_))
365+
_ = data.conn.SetWriteDeadline(xtime.GetInaccurateTime().Add(p.config.WriteTimeout_))
361366
}
362367

363368
if err := writeAll(data.conn, data.outBuf); err != nil {

0 commit comments

Comments
 (0)