mirror of
https://github.com/go-micro/go-micro.git
synced 2024-12-18 08:26:38 +02:00
1db36357d5
* feat(logger): add logger option to all components * fix: refactor api/rpc.go * fix: refactor api/stream.go * fix: api/options.go comment * fix(logger): do not use logger.Helper internally * fix(logger): fix comments * fix(logger): use level.Enabled method * fix: rename mlogger to log * fix: run go fmt * fix: log level * fix: factories Co-authored-by: Mohamed MHAMDI <mmhamdi@hubside.com> Co-authored-by: Davincible <david.brouwer.99@gmail.com>
73 lines
1.1 KiB
Go
73 lines
1.1 KiB
Go
package web_test
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"sync"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/urfave/cli/v2"
|
|
"go-micro.dev/v4"
|
|
"go-micro.dev/v4/logger"
|
|
"go-micro.dev/v4/web"
|
|
)
|
|
|
|
func TestWeb(t *testing.T) {
|
|
for i := 0; i < 10; i++ {
|
|
fmt.Println("Test nr", i)
|
|
testFunc()
|
|
}
|
|
}
|
|
|
|
func testFunc() {
|
|
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*250)
|
|
defer cancel()
|
|
|
|
s := micro.NewService(
|
|
micro.Name("test"),
|
|
micro.Context(ctx),
|
|
micro.HandleSignal(false),
|
|
micro.Flags(
|
|
&cli.StringFlag{
|
|
Name: "test.timeout",
|
|
},
|
|
&cli.BoolFlag{
|
|
Name: "test.v",
|
|
},
|
|
&cli.StringFlag{
|
|
Name: "test.run",
|
|
},
|
|
&cli.StringFlag{
|
|
Name: "test.testlogfile",
|
|
},
|
|
),
|
|
)
|
|
w := web.NewService(
|
|
web.MicroService(s),
|
|
web.Context(ctx),
|
|
web.HandleSignal(false),
|
|
)
|
|
//s.Init()
|
|
//w.Init()
|
|
|
|
var wg sync.WaitGroup
|
|
wg.Add(2)
|
|
go func() {
|
|
defer wg.Done()
|
|
err := s.Run()
|
|
if err != nil {
|
|
logger.Logf(logger.ErrorLevel, "micro run error: %v", err)
|
|
}
|
|
}()
|
|
go func() {
|
|
defer wg.Done()
|
|
err := w.Run()
|
|
if err != nil {
|
|
logger.Logf(logger.ErrorLevel, "web run error: %v", err)
|
|
}
|
|
}()
|
|
|
|
wg.Wait()
|
|
}
|