add ability to work with protoset
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
@@ -1,22 +1,30 @@
|
||||
package config
|
||||
|
||||
import "io"
|
||||
import (
|
||||
"io"
|
||||
|
||||
mtime "go.unistack.org/micro/v3/util/time"
|
||||
yaml "gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Services []*Service `json:"services,omitempty" yaml:"services,omitempty"`
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
Addr string `json:"addr,omitempty" yaml:"addr,omitempty"`
|
||||
Checks []Check `json:"checks,omitempty" yaml:"checks,omitempty"`
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
Addr string `json:"addr,omitempty" yaml:"addr,omitempty"`
|
||||
Type string `json:"type,omitempty" yaml:"type,omitempty"`
|
||||
Reflection bool `json:"reflection,omitempty" yaml:"reflection,omitempty"`
|
||||
Protoset string `json:"protoset,omitempty" yaml:"protoset,omitempty"`
|
||||
Checks []*Check `json:"checks,omitempty" yaml:"checks,omitempty"`
|
||||
TLSVerify *bool `json:"tls_verify,omitempty" yaml:"tls_verify,omitempty"`
|
||||
}
|
||||
|
||||
type Check struct {
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
Type string `json:"type,omitempty" yaml:"type,omitempty"`
|
||||
Data string `json:"data,omitempty" yaml:"data,omitempty"`
|
||||
Timeout string `json:"timeout,omitempty" yaml:"timeout,omitempty"`
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
Data string `json:"data,omitempty" yaml:"data,omitempty"`
|
||||
Timeout mtime.Duration `json:"timeout,omitempty" yaml:"timeout,omitempty"`
|
||||
}
|
||||
|
||||
func (cfg *Config) Parse(r io.Reader) error {
|
||||
|
30
pkg/grpcconn/grpcconn.go
Normal file
30
pkg/grpcconn/grpcconn.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package grpcconn
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"go.unistack.org/micro/v3/client"
|
||||
"go.unistack.org/micro/v3/logger"
|
||||
)
|
||||
|
||||
func Call(ctx context.Context, l logger.Logger, c client.Client, addr string, td time.Duration, req client.Request, rsp interface{}) error {
|
||||
var err error
|
||||
uid, err := uuid.NewRandom()
|
||||
if err != nil {
|
||||
l.Error(ctx, "failed to generate x-request-id", err)
|
||||
return err
|
||||
}
|
||||
|
||||
err = c.Call(ctx, req, rsp,
|
||||
client.WithAddress(addr),
|
||||
client.WithRequestTimeout(td),
|
||||
// client.WithContentType("application/json"),
|
||||
)
|
||||
if err != nil {
|
||||
l.Error(ctx, "call failed", "x-request-id", uid.String(), err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
14
pkg/grpcconn/protoset.go
Normal file
14
pkg/grpcconn/protoset.go
Normal file
@@ -0,0 +1,14 @@
|
||||
//go:build ignore
|
||||
|
||||
package grpcconn
|
||||
|
||||
import (
|
||||
"github.com/emicklei/proto"
|
||||
"github.com/jhump/protoreflect/desc"
|
||||
)
|
||||
|
||||
var protoSets = map[string]*desc.FileDescriptor
|
||||
|
||||
func GetMessage(service string, method string) (proto.Message, error) {
|
||||
return nil, nil
|
||||
}
|
Reference in New Issue
Block a user