Moving cruftier services that are only used for tests under a test repo

This commit is contained in:
Janos Dobronszki
2020-10-15 16:54:27 +02:00
parent 7c2f9737cb
commit d86531e5e9
37 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
package handler
import (
"context"
log "github.com/micro/micro/v3/service/logger"
idiomatic "github.com/micro/services/template/proto"
)
type Idiomatic struct{}
// Call is a single request handler called via client.Call or the generated client code
func (e *Idiomatic) Call(ctx context.Context, req *idiomatic.Request, rsp *idiomatic.Response) error {
log.Info("Received Idiomatic.Call request")
rsp.Msg = "Hello " + req.Name
return nil
}
// Stream is a server side stream handler called via client.Stream or the generated client code
func (e *Idiomatic) Stream(ctx context.Context, req *idiomatic.StreamingRequest, stream idiomatic.Idiomatic_StreamStream) error {
log.Infof("Received Idiomatic.Stream request with count: %d", req.Count)
for i := 0; i < int(req.Count); i++ {
log.Infof("Responding: %d", i)
if err := stream.Send(&idiomatic.StreamingResponse{
Count: int64(i),
}); err != nil {
return err
}
}
return nil
}
// PingPong is a bidirectional stream handler called via client.Stream or the generated client code
func (e *Idiomatic) PingPong(ctx context.Context, stream idiomatic.Idiomatic_PingPongStream) error {
for {
req, err := stream.Recv()
if err != nil {
return err
}
log.Infof("Got ping %v", req.Stroke)
if err := stream.Send(&idiomatic.Pong{Stroke: req.Stroke}); err != nil {
return err
}
}
}