-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
116 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright 2022 YBCZ, Inc. All rights reserved. | ||
// | ||
// Use of this source code is governed by a MIT license | ||
// that can be found in the LICENSE file in the root of the source | ||
// tree. | ||
|
||
package mqms | ||
|
||
import ( | ||
"encoding/json" | ||
"github.com/google/uuid" | ||
"log" | ||
"testing" | ||
"time" | ||
) | ||
|
||
type testHandler struct { | ||
} | ||
|
||
func (t testHandler) Pub(evtRaw json.RawMessage, duration time.Duration) (err error) { | ||
log.Println(string(evtRaw), duration) | ||
return | ||
} | ||
|
||
func (t testHandler) Save(evtID uuid.UUID, evtRaw json.RawMessage, duration time.Duration) (err error) { | ||
log.Println(evtID, string(evtRaw), duration) | ||
return | ||
} | ||
|
||
func (t testHandler) Trace(trace Trace) { | ||
raw, _ := json.Marshal(trace) | ||
log.Println(string(raw)) | ||
} | ||
|
||
func (t testHandler) Log(l string) { | ||
log.Println(l) | ||
} | ||
|
||
func (t testHandler) Fail(evtID uuid.UUID, evtRaw json.RawMessage, err error, stack []string) { | ||
log.Println(evtID, string(evtRaw), err, stack) | ||
} | ||
|
||
func (t testHandler) DoRead() (list []Row, err error) { | ||
return | ||
} | ||
|
||
func (t testHandler) HttpTrace(ht HttpTrace) { | ||
raw, _ := json.Marshal(ht) | ||
log.Println(string(raw)) | ||
} | ||
|
||
var _ IEngineHandler = &testHandler{} | ||
|
||
func TestMqmsTrace(t *testing.T) { | ||
log.SetFlags(log.Ltime | log.Lshortfile) | ||
var h = new(testHandler) | ||
engine := New(h) | ||
engine.Item("test", func(c *Context) (err error) { | ||
//err = c.Error(errors.New("test error")) | ||
return | ||
}) | ||
engine.Emit("test", "F") | ||
time.Sleep(time.Hour) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters