Commit 83c151e9 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 8b93ac4c
...@@ -28,23 +28,10 @@ import ( ...@@ -28,23 +28,10 @@ import (
"golang.org/x/sync/errgroup" "golang.org/x/sync/errgroup"
"lab.nexedi.com/kirr/go123/exc" "lab.nexedi.com/kirr/go123/exc"
"lab.nexedi.com/kirr/go123/myname" //"lab.nexedi.com/kirr/go123/myname"
"lab.nexedi.com/kirr/go123/xerr" "lab.nexedi.com/kirr/go123/xerr"
) )
// run function which raises exception, and return exception as error, if any
// XXX -> exc.Runx ?
func runx(xf func()) (err error) {
//here := my.FuncName()
here := myname.Func()
defer exc.Catch(func(e *exc.Error) {
err = exc.Addcallingcontext(here, e)
})
xf()
return
}
// XXX move me out of here ? // XXX move me out of here ?
type workGroup struct { type workGroup struct {
*errgroup.Group *errgroup.Group
...@@ -53,7 +40,7 @@ type workGroup struct { ...@@ -53,7 +40,7 @@ type workGroup struct {
// like errgroup.Go but translates exceptions to errors // like errgroup.Go but translates exceptions to errors
func (wg *workGroup) Gox(xf func ()) { func (wg *workGroup) Gox(xf func ()) {
wg.Go(func() error { wg.Go(func() error {
return runx(xf) return exc.Runx(xf)
}) })
} }
...@@ -178,14 +165,9 @@ func TestNodeLink(t *testing.T) { ...@@ -178,14 +165,9 @@ func TestNodeLink(t *testing.T) {
} }
xwait(wg) xwait(wg)
// TODO (?) every func: run with exception catcher (including t.Fatal) // check raw exchange works
// if caught:
// * ctx.cancel
// * wait all for finish
// * rethrough in main
nl1, nl2 = nodeLinkPipe() nl1, nl2 = nodeLinkPipe()
// check raw exchange works
wg, ctx := WorkGroupCtx(context.Background()) wg, ctx := WorkGroupCtx(context.Background())
wg.Gox(func() { wg.Gox(func() {
// send ping; wait for pong // send ping; wait for pong
...@@ -214,9 +196,9 @@ func TestNodeLink(t *testing.T) { ...@@ -214,9 +196,9 @@ func TestNodeLink(t *testing.T) {
xwait(wgclose) xwait(wgclose)
/*
// test 1 channels on top of nodelink // test 1 channels on top of nodelink
nl1, nl2 = nodeLinkPipe()
c1 := nl1.NewConn() c1 := nl1.NewConn()
nl2.HandleNewConn(func(c *Conn) { nl2.HandleNewConn(func(c *Conn) {
pkt := xrecv(c) // XXX t.Fatal() must be called from main goroutine -> context.Cancel ? pkt := xrecv(c) // XXX t.Fatal() must be called from main goroutine -> context.Cancel ?
...@@ -229,5 +211,4 @@ func TestNodeLink(t *testing.T) { ...@@ -229,5 +211,4 @@ func TestNodeLink(t *testing.T) {
// TODO check pkt2 is pkt1 + small modification // TODO check pkt2 is pkt1 + small modification
// test 2 channels with replies comming in reversed time order // test 2 channels with replies comming in reversed time order
*/
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment