@@ -44,18 +44,18 @@ func newTestDialer() *testDialer {
44
44
// For instance, to test an async logger that have to dial 4 times before succeeding,
45
45
// the test should look like this:
46
46
//
47
- // d := newTestDialer() // Create a new stubbed dialer
48
- // cfg := Config{
49
- // Async: true,
50
- // // ...
51
- // }
52
- // f := newWithDialer(cfg, d) // Create a fluent logger using the stubbed dialer
53
- // f.EncodeAndPostData("tag_name", time.Unix(1482493046, 0), map[string]string{"foo": "bar"})
47
+ // d := newTestDialer() // Create a new stubbed dialer
48
+ // cfg := Config{
49
+ // Async: true,
50
+ // // ...
51
+ // }
52
+ // f := newWithDialer(cfg, d) // Create a fluent logger using the stubbed dialer
53
+ // f.EncodeAndPostData("tag_name", time.Unix(1482493046, 0), map[string]string{"foo": "bar"})
54
54
//
55
- // d.waitForNextDialing(false, false) // 1st dialing attempt fails
56
- // d.waitForNextDialing(false, false) // 2nd attempt fails too
57
- // d.waitForNextDialing(false, false) // 3rd attempt fails too
58
- // d.waitForNextDialing(true, false) // Finally the 4th attempt succeeds
55
+ // d.waitForNextDialing(false, false) // 1st dialing attempt fails
56
+ // d.waitForNextDialing(false, false) // 2nd attempt fails too
57
+ // d.waitForNextDialing(false, false) // 3rd attempt fails too
58
+ // d.waitForNextDialing(true, false) // Finally the 4th attempt succeeds
59
59
//
60
60
// Note that in the above example, the logger operates in async mode. As such,
61
61
// a call to Post, PostWithTime or EncodeAndPostData is needed *before* calling
@@ -66,20 +66,20 @@ func newTestDialer() *testDialer {
66
66
// case, you have to put the calls to newWithDialer() and to EncodeAndPostData()
67
67
// into their own goroutine. An example:
68
68
//
69
- // d := newTestDialer() // Create a new stubbed dialer
70
- // cfg := Config{
71
- // Async: false,
72
- // // ...
73
- // }
74
- // go func() {
75
- // f := newWithDialer(cfg, d) // Create a fluent logger using the stubbed dialer
76
- // f.Close()
77
- // }()
69
+ // d := newTestDialer() // Create a new stubbed dialer
70
+ // cfg := Config{
71
+ // Async: false,
72
+ // // ...
73
+ // }
74
+ // go func() {
75
+ // f := newWithDialer(cfg, d) // Create a fluent logger using the stubbed dialer
76
+ // f.Close()
77
+ // }()
78
78
//
79
- // d.waitForNextDialing(false, false) // 1st dialing attempt fails
80
- // d.waitForNextDialing(false, false) // 2nd attempt fails too
81
- // d.waitForNextDialing(false, false) // 3rd attempt fails too
82
- // d.waitForNextDialing(true, false) // Finally the 4th attempt succeeds
79
+ // d.waitForNextDialing(false, false) // 1st dialing attempt fails
80
+ // d.waitForNextDialing(false, false) // 2nd attempt fails too
81
+ // d.waitForNextDialing(false, false) // 3rd attempt fails too
82
+ // d.waitForNextDialing(true, false) // Finally the 4th attempt succeeds
83
83
//
84
84
// Moreover, waitForNextDialing() returns a *Conn which extends net.Conn to provide testing
85
85
// facilities. For instance, you can call waitForNextWrite() on these connections, to
@@ -90,24 +90,24 @@ func newTestDialer() *testDialer {
90
90
//
91
91
// Here's a full example:
92
92
//
93
- // d := newTestDialer()
94
- // cfg := Config{Async: true}
93
+ // d := newTestDialer()
94
+ // cfg := Config{Async: true}
95
95
//
96
- // f := newWithDialer(cfg, d)
97
- // f.EncodeAndPostData("tag_name", time.Unix(1482493046, 0), map[string]string{"foo": "bar"})
96
+ // f := newWithDialer(cfg, d)
97
+ // f.EncodeAndPostData("tag_name", time.Unix(1482493046, 0), map[string]string{"foo": "bar"})
98
98
//
99
- // conn := d.waitForNextDialing(true, false) // Accept the dialing
100
- // conn.waitForNextWrite(false, "") // Discard the 1st attempt to write the message
99
+ // conn := d.waitForNextDialing(true, false) // Accept the dialing
100
+ // conn.waitForNextWrite(false, "") // Discard the 1st attempt to write the message
101
101
//
102
- // conn := d.waitForNextDialing(true, false)
103
- // assertReceived(t, // t is *testing.T
104
- // conn.waitForNextWrite(true, ""),
105
- // "[\"tag_name\",1482493046,{\"foo\":\"bar\"},{}]")
102
+ // conn := d.waitForNextDialing(true, false)
103
+ // assertReceived(t, // t is *testing.T
104
+ // conn.waitForNextWrite(true, ""),
105
+ // "[\"tag_name\",1482493046,{\"foo\":\"bar\"},{}]")
106
106
//
107
- // f.EncodeAndPostData("something_else", time.Unix(1482493050, 0), map[string]string{"bar": "baz"})
108
- // assertReceived(t, // t is *testing.T
109
- // conn.waitForNextWrite(true, ""),
110
- // "[\"something_else\",1482493050,{\"bar\":\"baz\"},{}]")
107
+ // f.EncodeAndPostData("something_else", time.Unix(1482493050, 0), map[string]string{"bar": "baz"})
108
+ // assertReceived(t, // t is *testing.T
109
+ // conn.waitForNextWrite(true, ""),
110
+ // "[\"something_else\",1482493050,{\"bar\":\"baz\"},{}]")
111
111
//
112
112
// In this example, the 1st connection dialing succeeds but the 1st attempt to write the
113
113
// message is discarded. As the logger discards the connection whenever a message
@@ -303,7 +303,8 @@ func Test_New_itShouldUseUnixDomainSocketIfUnixSocketSpecified(t *testing.T) {
303
303
304
304
f , err := New (Config {
305
305
FluentNetwork : network ,
306
- FluentSocketPath : socketFile })
306
+ FluentSocketPath : socketFile ,
307
+ })
307
308
if err != nil {
308
309
t .Error (err )
309
310
return
@@ -316,7 +317,8 @@ func Test_New_itShouldUseUnixDomainSocketIfUnixSocketSpecified(t *testing.T) {
316
317
network = "unixxxx"
317
318
fUnknown , err := New (Config {
318
319
FluentNetwork : network ,
319
- FluentSocketPath : socketFile })
320
+ FluentSocketPath : socketFile ,
321
+ })
320
322
if _ , ok := err .(* ErrUnknownNetwork ); ! ok {
321
323
t .Errorf ("err type: %T" , err )
322
324
}
@@ -342,12 +344,12 @@ func Test_MarshalAsMsgpack(t *testing.T) {
342
344
f := & Fluent {Config : Config {}}
343
345
344
346
tag := "tag"
345
- var data = map [string ]string {
347
+ data : = map [string ]string {
346
348
"foo" : "bar" ,
347
- "hoge" : "hoge" }
349
+ "hoge" : "hoge" ,
350
+ }
348
351
tm := time .Unix (1267867237 , 0 )
349
352
result , err := f .EncodeData (tag , tm , data )
350
-
351
353
if err != nil {
352
354
t .Error (err )
353
355
}
@@ -375,7 +377,6 @@ func Test_SubSecondPrecision(t *testing.T) {
375
377
encodedData , err := fluent .EncodeData ("tag" , timestamp , map [string ]string {
376
378
"foo" : "bar" ,
377
379
})
378
-
379
380
// Assert no encoding errors and that the timestamp has been encoded into
380
381
// the message as expected.
381
382
if err != nil {
@@ -394,12 +395,12 @@ func Test_SubSecondPrecision(t *testing.T) {
394
395
func Test_MarshalAsJSON (t * testing.T ) {
395
396
f := & Fluent {Config : Config {MarshalAsJSON : true }}
396
397
397
- var data = map [string ]string {
398
+ data : = map [string ]string {
398
399
"foo" : "bar" ,
399
- "hoge" : "hoge" }
400
+ "hoge" : "hoge" ,
401
+ }
400
402
tm := time .Unix (1267867237 , 0 )
401
403
result , err := f .EncodeData ("tag" , tm , data )
402
-
403
404
if err != nil {
404
405
t .Error (err )
405
406
}
@@ -477,7 +478,10 @@ func TestPostWithTime(t *testing.T) {
477
478
_ = f .PostWithTime ("tag_name" , time .Unix (1482493046 , 0 ), map [string ]string {"foo" : "bar" })
478
479
_ = f .PostWithTime ("tag_name" , time .Unix (1482493050 , 0 ), map [string ]string {"fluentd" : "is awesome" })
479
480
_ = f .PostWithTime ("tag_name" , time .Unix (1634263200 , 0 ),
480
- struct {Welcome string `msg:"welcome"` ; cannot string }{"to use" , "see me" })
481
+ struct {
482
+ Welcome string `msg:"welcome"`
483
+ cannot string
484
+ }{"to use" , "see me" })
481
485
}()
482
486
483
487
conn := d .waitForNextDialing (true , false )
0 commit comments