@@ -45,18 +45,18 @@ func newTestDialer() *testDialer {
45
45
// For instance, to test an async logger that have to dial 4 times before succeeding,
46
46
// the test should look like this:
47
47
//
48
- // d := newTestDialer() // Create a new stubbed dialer
49
- // cfg := Config{
50
- // Async: true,
51
- // // ...
52
- // }
53
- // f := newWithDialer(cfg, d) // Create a fluent logger using the stubbed dialer
54
- // f.EncodeAndPostData("tag_name", time.Unix(1482493046, 0), map[string]string{"foo": "bar"})
48
+ // d := newTestDialer() // Create a new stubbed dialer
49
+ // cfg := Config{
50
+ // Async: true,
51
+ // // ...
52
+ // }
53
+ // f := newWithDialer(cfg, d) // Create a fluent logger using the stubbed dialer
54
+ // f.EncodeAndPostData("tag_name", time.Unix(1482493046, 0), map[string]string{"foo": "bar"})
55
55
//
56
- // d.waitForNextDialing(false, false) // 1st dialing attempt fails
57
- // d.waitForNextDialing(false, false) // 2nd attempt fails too
58
- // d.waitForNextDialing(false, false) // 3rd attempt fails too
59
- // d.waitForNextDialing(true, false) // Finally the 4th attempt succeeds
56
+ // d.waitForNextDialing(false, false) // 1st dialing attempt fails
57
+ // d.waitForNextDialing(false, false) // 2nd attempt fails too
58
+ // d.waitForNextDialing(false, false) // 3rd attempt fails too
59
+ // d.waitForNextDialing(true, false) // Finally the 4th attempt succeeds
60
60
//
61
61
// Note that in the above example, the logger operates in async mode. As such,
62
62
// a call to Post, PostWithTime or EncodeAndPostData is needed *before* calling
@@ -67,20 +67,20 @@ func newTestDialer() *testDialer {
67
67
// case, you have to put the calls to newWithDialer() and to EncodeAndPostData()
68
68
// into their own goroutine. An example:
69
69
//
70
- // d := newTestDialer() // Create a new stubbed dialer
71
- // cfg := Config{
72
- // Async: false,
73
- // // ...
74
- // }
75
- // go func() {
76
- // f := newWithDialer(cfg, d) // Create a fluent logger using the stubbed dialer
77
- // f.Close()
78
- // }()
70
+ // d := newTestDialer() // Create a new stubbed dialer
71
+ // cfg := Config{
72
+ // Async: false,
73
+ // // ...
74
+ // }
75
+ // go func() {
76
+ // f := newWithDialer(cfg, d) // Create a fluent logger using the stubbed dialer
77
+ // f.Close()
78
+ // }()
79
79
//
80
- // d.waitForNextDialing(false, false) // 1st dialing attempt fails
81
- // d.waitForNextDialing(false, false) // 2nd attempt fails too
82
- // d.waitForNextDialing(false, false) // 3rd attempt fails too
83
- // d.waitForNextDialing(true, false) // Finally the 4th attempt succeeds
80
+ // d.waitForNextDialing(false, false) // 1st dialing attempt fails
81
+ // d.waitForNextDialing(false, false) // 2nd attempt fails too
82
+ // d.waitForNextDialing(false, false) // 3rd attempt fails too
83
+ // d.waitForNextDialing(true, false) // Finally the 4th attempt succeeds
84
84
//
85
85
// Moreover, waitForNextDialing() returns a *Conn which extends net.Conn to provide testing
86
86
// facilities. For instance, you can call waitForNextWrite() on these connections, to
@@ -91,24 +91,24 @@ func newTestDialer() *testDialer {
91
91
//
92
92
// Here's a full example:
93
93
//
94
- // d := newTestDialer()
95
- // cfg := Config{Async: true}
94
+ // d := newTestDialer()
95
+ // cfg := Config{Async: true}
96
96
//
97
- // f := newWithDialer(cfg, d)
98
- // f.EncodeAndPostData("tag_name", time.Unix(1482493046, 0), map[string]string{"foo": "bar"})
97
+ // f := newWithDialer(cfg, d)
98
+ // f.EncodeAndPostData("tag_name", time.Unix(1482493046, 0), map[string]string{"foo": "bar"})
99
99
//
100
- // conn := d.waitForNextDialing(true, false) // Accept the dialing
101
- // conn.waitForNextWrite(false, "") // Discard the 1st attempt to write the message
100
+ // conn := d.waitForNextDialing(true, false) // Accept the dialing
101
+ // conn.waitForNextWrite(false, "") // Discard the 1st attempt to write the message
102
102
//
103
- // conn := d.waitForNextDialing(true, false)
104
- // assertReceived(t, // t is *testing.T
105
- // conn.waitForNextWrite(true, ""),
106
- // "[\"tag_name\",1482493046,{\"foo\":\"bar\"},{}]")
103
+ // conn := d.waitForNextDialing(true, false)
104
+ // assertReceived(t, // t is *testing.T
105
+ // conn.waitForNextWrite(true, ""),
106
+ // "[\"tag_name\",1482493046,{\"foo\":\"bar\"},{}]")
107
107
//
108
- // f.EncodeAndPostData("something_else", time.Unix(1482493050, 0), map[string]string{"bar": "baz"})
109
- // assertReceived(t, // t is *testing.T
110
- // conn.waitForNextWrite(true, ""),
111
- // "[\"something_else\",1482493050,{\"bar\":\"baz\"},{}]")
108
+ // f.EncodeAndPostData("something_else", time.Unix(1482493050, 0), map[string]string{"bar": "baz"})
109
+ // assertReceived(t, // t is *testing.T
110
+ // conn.waitForNextWrite(true, ""),
111
+ // "[\"something_else\",1482493050,{\"bar\":\"baz\"},{}]")
112
112
//
113
113
// In this example, the 1st connection dialing succeeds but the 1st attempt to write the
114
114
// message is discarded. As the logger discards the connection whenever a message
@@ -296,7 +296,8 @@ func Test_New_itShouldUseUnixDomainSocketIfUnixSocketSpecified(t *testing.T) {
296
296
297
297
f , err := New (Config {
298
298
FluentNetwork : network ,
299
- FluentSocketPath : socketFile })
299
+ FluentSocketPath : socketFile ,
300
+ })
300
301
if err != nil {
301
302
t .Error (err )
302
303
return
@@ -309,7 +310,8 @@ func Test_New_itShouldUseUnixDomainSocketIfUnixSocketSpecified(t *testing.T) {
309
310
network = "unixxxx"
310
311
fUnknown , err := New (Config {
311
312
FluentNetwork : network ,
312
- FluentSocketPath : socketFile })
313
+ FluentSocketPath : socketFile ,
314
+ })
313
315
if _ , ok := err .(* ErrUnknownNetwork ); ! ok {
314
316
t .Errorf ("err type: %T" , err )
315
317
}
@@ -335,12 +337,12 @@ func Test_MarshalAsMsgpack(t *testing.T) {
335
337
f := & Fluent {Config : Config {}}
336
338
337
339
tag := "tag"
338
- var data = map [string ]string {
340
+ data : = map [string ]string {
339
341
"foo" : "bar" ,
340
- "hoge" : "hoge" }
342
+ "hoge" : "hoge" ,
343
+ }
341
344
tm := time .Unix (1267867237 , 0 )
342
345
result , err := f .EncodeData (tag , tm , data )
343
-
344
346
if err != nil {
345
347
t .Error (err )
346
348
}
@@ -368,7 +370,6 @@ func Test_SubSecondPrecision(t *testing.T) {
368
370
encodedData , err := fluent .EncodeData ("tag" , timestamp , map [string ]string {
369
371
"foo" : "bar" ,
370
372
})
371
-
372
373
// Assert no encoding errors and that the timestamp has been encoded into
373
374
// the message as expected.
374
375
if err != nil {
@@ -387,12 +388,12 @@ func Test_SubSecondPrecision(t *testing.T) {
387
388
func Test_MarshalAsJSON (t * testing.T ) {
388
389
f := & Fluent {Config : Config {MarshalAsJSON : true }}
389
390
390
- var data = map [string ]string {
391
+ data : = map [string ]string {
391
392
"foo" : "bar" ,
392
- "hoge" : "hoge" }
393
+ "hoge" : "hoge" ,
394
+ }
393
395
tm := time .Unix (1267867237 , 0 )
394
396
result , err := f .EncodeData ("tag" , tm , data )
395
-
396
397
if err != nil {
397
398
t .Error (err )
398
399
}
@@ -472,7 +473,10 @@ func TestPostWithTime(t *testing.T) {
472
473
_ = f .PostWithTime ("tag_name" , time .Unix (1482493046 , 0 ), map [string ]string {"foo" : "bar" })
473
474
_ = f .PostWithTime ("tag_name" , time .Unix (1482493050 , 0 ), map [string ]string {"fluentd" : "is awesome" })
474
475
_ = f .PostWithTime ("tag_name" , time .Unix (1634263200 , 0 ),
475
- struct {Welcome string `msg:"welcome"` ; cannot string }{"to use" , "see me" })
476
+ struct {
477
+ Welcome string `msg:"welcome"`
478
+ cannot string
479
+ }{"to use" , "see me" })
476
480
}()
477
481
478
482
conn := d .waitForNextDialing (true , false )
0 commit comments