Compare commits

...

2 Commits
v3 ... v4

Author SHA1 Message Date
816abc2bbc add copy metadata from grpc-go (#386)
Some checks failed
coverage / build (push) Failing after 1m5s
test / test (push) Successful in 2m10s
Co-authored-by: Василий Толстов <v.tolstov@unistack.org>
Co-authored-by: Vasiliy Tolstov <v.tolstov@unistack.org>
Co-authored-by: vtolstov <vtolstov@users.noreply.github.com>
Reviewed-on: #386
Co-authored-by: Evstigneev Denis <danteevstigneev@yandex.ru>
Co-committed-by: Evstigneev Denis <danteevstigneev@yandex.ru>
2025-01-25 15:57:55 +03:00
f3f2a9b737 move to v4
Some checks failed
coverage / build (push) Failing after 56s
test / test (push) Successful in 2m30s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2025-01-25 15:48:10 +03:00
101 changed files with 580 additions and 294 deletions

View File

@ -6,8 +6,8 @@ import (
"errors"
"time"
"go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v3/metadata"
"go.unistack.org/micro/v4/codec"
"go.unistack.org/micro/v4/metadata"
)
// DefaultBroker default memory broker

View File

@ -4,14 +4,14 @@ import (
"context"
"sync"
"go.unistack.org/micro/v3/broker"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/metadata"
"go.unistack.org/micro/v3/options"
maddr "go.unistack.org/micro/v3/util/addr"
"go.unistack.org/micro/v3/util/id"
mnet "go.unistack.org/micro/v3/util/net"
"go.unistack.org/micro/v3/util/rand"
"go.unistack.org/micro/v4/broker"
"go.unistack.org/micro/v4/logger"
"go.unistack.org/micro/v4/metadata"
"go.unistack.org/micro/v4/options"
maddr "go.unistack.org/micro/v4/util/addr"
"go.unistack.org/micro/v4/util/id"
mnet "go.unistack.org/micro/v4/util/net"
"go.unistack.org/micro/v4/util/rand"
)
type memoryBroker struct {

View File

@ -5,8 +5,8 @@ import (
"fmt"
"testing"
"go.unistack.org/micro/v3/broker"
"go.unistack.org/micro/v3/metadata"
"go.unistack.org/micro/v4/broker"
"go.unistack.org/micro/v4/metadata"
)
func TestMemoryBatchBroker(t *testing.T) {

View File

@ -4,7 +4,7 @@ import (
"context"
"strings"
"go.unistack.org/micro/v3/options"
"go.unistack.org/micro/v4/options"
)
type NoopBroker struct {

View File

@ -5,13 +5,13 @@ import (
"crypto/tls"
"time"
"go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/meter"
"go.unistack.org/micro/v3/options"
"go.unistack.org/micro/v3/register"
"go.unistack.org/micro/v3/sync"
"go.unistack.org/micro/v3/tracer"
"go.unistack.org/micro/v4/codec"
"go.unistack.org/micro/v4/logger"
"go.unistack.org/micro/v4/meter"
"go.unistack.org/micro/v4/options"
"go.unistack.org/micro/v4/register"
"go.unistack.org/micro/v4/sync"
"go.unistack.org/micro/v4/tracer"
)
// Options struct

View File

@ -5,7 +5,7 @@ import (
"math"
"time"
"go.unistack.org/micro/v3/util/backoff"
"go.unistack.org/micro/v4/util/backoff"
)
// BackoffFunc is the backoff call func

View File

@ -5,8 +5,8 @@ import (
"context"
"time"
"go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v3/metadata"
"go.unistack.org/micro/v4/codec"
"go.unistack.org/micro/v4/metadata"
)
var (

View File

@ -4,8 +4,8 @@ import (
"context"
"sort"
"go.unistack.org/micro/v3/errors"
"go.unistack.org/micro/v3/router"
"go.unistack.org/micro/v4/errors"
"go.unistack.org/micro/v4/router"
)
// LookupFunc is used to lookup routes for a service

View File

@ -7,14 +7,14 @@ import (
"strconv"
"time"
"go.unistack.org/micro/v3/broker"
"go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v3/errors"
"go.unistack.org/micro/v3/metadata"
"go.unistack.org/micro/v3/options"
"go.unistack.org/micro/v3/selector"
"go.unistack.org/micro/v3/semconv"
"go.unistack.org/micro/v3/tracer"
"go.unistack.org/micro/v4/broker"
"go.unistack.org/micro/v4/codec"
"go.unistack.org/micro/v4/errors"
"go.unistack.org/micro/v4/metadata"
"go.unistack.org/micro/v4/options"
"go.unistack.org/micro/v4/selector"
"go.unistack.org/micro/v4/semconv"
"go.unistack.org/micro/v4/tracer"
)
// DefaultCodecs will be used to encode/decode data

View File

@ -6,17 +6,17 @@ import (
"net"
"time"
"go.unistack.org/micro/v3/broker"
"go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/metadata"
"go.unistack.org/micro/v3/meter"
"go.unistack.org/micro/v3/options"
"go.unistack.org/micro/v3/register"
"go.unistack.org/micro/v3/router"
"go.unistack.org/micro/v3/selector"
"go.unistack.org/micro/v3/selector/random"
"go.unistack.org/micro/v3/tracer"
"go.unistack.org/micro/v4/broker"
"go.unistack.org/micro/v4/codec"
"go.unistack.org/micro/v4/logger"
"go.unistack.org/micro/v4/metadata"
"go.unistack.org/micro/v4/meter"
"go.unistack.org/micro/v4/options"
"go.unistack.org/micro/v4/register"
"go.unistack.org/micro/v4/router"
"go.unistack.org/micro/v4/selector"
"go.unistack.org/micro/v4/selector/random"
"go.unistack.org/micro/v4/tracer"
)
// Options holds client options

View File

@ -3,7 +3,7 @@ package client
import (
"context"
"go.unistack.org/micro/v3/errors"
"go.unistack.org/micro/v4/errors"
)
// RetryFunc that returning either false or a non-nil error will result in the call not being retried

View File

@ -5,7 +5,7 @@ import (
"fmt"
"testing"
"go.unistack.org/micro/v3/errors"
"go.unistack.org/micro/v4/errors"
)
func TestRetryAlways(t *testing.T) {

View File

@ -1,7 +1,7 @@
package client
import (
"go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v4/codec"
)
type testRequest struct {

View File

@ -3,7 +3,7 @@ package cluster
import (
"context"
"go.unistack.org/micro/v3/metadata"
"go.unistack.org/micro/v4/metadata"
)
// Message sent to member in cluster

View File

@ -3,9 +3,9 @@ package codec
import (
"context"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/meter"
"go.unistack.org/micro/v3/tracer"
"go.unistack.org/micro/v4/logger"
"go.unistack.org/micro/v4/meter"
"go.unistack.org/micro/v4/tracer"
)
// Option func

View File

@ -9,10 +9,10 @@ import (
"dario.cat/mergo"
"github.com/google/uuid"
"go.unistack.org/micro/v3/options"
mid "go.unistack.org/micro/v3/util/id"
rutil "go.unistack.org/micro/v3/util/reflect"
mtime "go.unistack.org/micro/v3/util/time"
"go.unistack.org/micro/v4/options"
mid "go.unistack.org/micro/v4/util/id"
rutil "go.unistack.org/micro/v4/util/reflect"
mtime "go.unistack.org/micro/v4/util/time"
)
type defaultConfig struct {
@ -210,7 +210,7 @@ func fillValue(value reflect.Value, val string) error {
return err
}
value.Set(reflect.ValueOf(v))
case value.Type().String() == "time.Duration" && value.Type().PkgPath() == "go.unistack.org/micro/v3/util/time":
case value.Type().String() == "time.Duration" && value.Type().PkgPath() == "go.unistack.org/micro/v4/util/time":
v, err := mtime.ParseDuration(val)
if err != nil {
return err

View File

@ -7,8 +7,8 @@ import (
"testing"
"time"
"go.unistack.org/micro/v3/config"
mtime "go.unistack.org/micro/v3/util/time"
"go.unistack.org/micro/v4/config"
mtime "go.unistack.org/micro/v4/util/time"
)
type cfg struct {

View File

@ -4,11 +4,11 @@ import (
"context"
"time"
"go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/meter"
"go.unistack.org/micro/v3/options"
"go.unistack.org/micro/v3/tracer"
"go.unistack.org/micro/v4/codec"
"go.unistack.org/micro/v4/logger"
"go.unistack.org/micro/v4/meter"
"go.unistack.org/micro/v4/options"
"go.unistack.org/micro/v4/tracer"
)
// Options hold the config options

View File

@ -3,7 +3,7 @@ package micro
import (
"context"
"go.unistack.org/micro/v3/client"
"go.unistack.org/micro/v4/client"
)
// Event is used to publish messages to a topic

View File

@ -6,12 +6,12 @@ import (
"sync"
"github.com/silas/dag"
"go.unistack.org/micro/v3/client"
"go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/metadata"
"go.unistack.org/micro/v3/store"
"go.unistack.org/micro/v3/util/id"
"go.unistack.org/micro/v4/client"
"go.unistack.org/micro/v4/codec"
"go.unistack.org/micro/v4/logger"
"go.unistack.org/micro/v4/metadata"
"go.unistack.org/micro/v4/store"
"go.unistack.org/micro/v4/util/id"
)
type microFlow struct {

View File

@ -7,7 +7,7 @@ import (
"sync"
"sync/atomic"
"go.unistack.org/micro/v3/metadata"
"go.unistack.org/micro/v4/metadata"
)
var (

View File

@ -4,11 +4,11 @@ import (
"context"
"time"
"go.unistack.org/micro/v3/client"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/meter"
"go.unistack.org/micro/v3/store"
"go.unistack.org/micro/v3/tracer"
"go.unistack.org/micro/v4/client"
"go.unistack.org/micro/v4/logger"
"go.unistack.org/micro/v4/meter"
"go.unistack.org/micro/v4/store"
"go.unistack.org/micro/v4/tracer"
)
// Option func

View File

@ -5,7 +5,7 @@ import (
"fmt"
"testing"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v4/logger"
)
func TestFSMStart(t *testing.T) {

12
go.mod
View File

@ -1,11 +1,11 @@
module go.unistack.org/micro/v3
module go.unistack.org/micro/v4
go 1.22.0
require (
dario.cat/mergo v1.0.1
github.com/DATA-DOG/go-sqlmock v1.5.2
github.com/KimMachineGun/automemlimit v0.6.1
github.com/KimMachineGun/automemlimit v0.7.0
github.com/ash3in/uuidv8 v1.2.0
github.com/google/uuid v1.6.0
github.com/matoous/go-nanoid v1.5.1
@ -14,8 +14,8 @@ require (
go.uber.org/automaxprocs v1.6.0
go.unistack.org/micro-proto/v3 v3.4.1
golang.org/x/sync v0.10.0
google.golang.org/grpc v1.69.2
google.golang.org/protobuf v1.36.1
google.golang.org/grpc v1.69.4
google.golang.org/protobuf v1.36.3
gopkg.in/yaml.v3 v3.0.1
)
@ -36,8 +36,8 @@ require (
github.com/stretchr/testify v1.10.0 // indirect
go.uber.org/goleak v1.3.0 // indirect
golang.org/x/exp v0.0.0-20241210194714-1829a127f884 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/net v0.34.0 // indirect
golang.org/x/sys v0.29.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241216192217-9240e9c98484 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
)

View File

@ -8,7 +8,7 @@ import (
"slices"
"time"
"go.unistack.org/micro/v3/meter"
"go.unistack.org/micro/v4/meter"
)
// Option func signature

View File

@ -13,9 +13,9 @@ import (
"sync/atomic"
"time"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/semconv"
"go.unistack.org/micro/v3/tracer"
"go.unistack.org/micro/v4/logger"
"go.unistack.org/micro/v4/semconv"
"go.unistack.org/micro/v4/tracer"
)
const (

View File

@ -12,9 +12,9 @@ import (
"time"
"github.com/google/uuid"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/metadata"
"go.unistack.org/micro/v3/util/buffer"
"go.unistack.org/micro/v4/logger"
"go.unistack.org/micro/v4/metadata"
"go.unistack.org/micro/v4/util/buffer"
)
// always first to have proper check

View File

@ -8,7 +8,7 @@ import (
"strconv"
"strings"
"go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v4/codec"
)
const sf = "0-+# "

View File

@ -5,7 +5,7 @@ import (
"strings"
"testing"
"go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v4/codec"
)
func TestUnwrap(t *testing.T) {

View File

@ -1,3 +1,5 @@
//go:build !exclude
// Package metadata is a way of defining message headers
package metadata

View File

@ -1,3 +1,5 @@
//go:build !exclude
// Package metadata is a way of defining message headers
package metadata

282
metadata/metadata_grpc.go Normal file
View File

@ -0,0 +1,282 @@
//go:build exclude
// Package metadata TODO need compare with micro metadata
package metadata // import "google.golang.org/grpc/metadata"
import (
"context"
"fmt"
"strings"
)
// MD is a mapping from metadata keys to values. Users should use the following
// two convenience functions New and Pairs to generate MD.
type MD map[string][]string
type Metadata map[string]string
// New creates an MD from a given key-value map.
//
// Only the following ASCII characters are allowed in keys:
// - digits: 0-9
// - uppercase letters: A-Z (normalized to lower)
// - lowercase letters: a-z
// - special characters: -_.
//
// Uppercase letters are automatically converted to lowercase.
//
// Keys beginning with "grpc-" are reserved for grpc-internal use only and may
// result in errors if set in metadata.
func New(m map[string]string) MD {
md := make(MD, len(m))
for k, val := range m {
key := strings.ToLower(k)
md[key] = append(md[key], val)
}
return md
}
// Pairs returns an MD formed by the mapping of key, value ...
// Pairs panics if len(kv) is odd.
//
// Only the following ASCII characters are allowed in keys:
// - digits: 0-9
// - uppercase letters: A-Z (normalized to lower)
// - lowercase letters: a-z
// - special characters: -_.
//
// Uppercase letters are automatically converted to lowercase.
//
// Keys beginning with "grpc-" are reserved for grpc-internal use only and may
// result in errors if set in metadata.
func Pairs(kv ...string) MD {
if len(kv)%2 == 1 {
panic(fmt.Sprintf("metadata: Pairs got the odd number of input pairs for metadata: %d", len(kv)))
}
md := make(MD, len(kv)/2)
for i := 0; i < len(kv); i += 2 {
key := strings.ToLower(kv[i])
md[key] = append(md[key], kv[i+1])
}
return md
}
// Len returns the number of items in md.
func (md MD) Len() int {
return len(md)
}
// Copy returns a copy of md.
func (md MD) Copy() MD {
out := make(MD, len(md))
for k, v := range md {
out[k] = copyOf(v)
}
return out
}
// Get obtains the values for a given key.
//
// k is converted to lowercase before searching in md.
func (md MD) Get(k string) []string {
k = strings.ToLower(k)
return md[k]
}
// Set sets the value of a given key with a slice of values.
//
// k is converted to lowercase before storing in md.
func (md MD) Set(k string, vals ...string) {
if len(vals) == 0 {
return
}
k = strings.ToLower(k)
md[k] = vals
}
// Append adds the values to key k, not overwriting what was already stored at
// that key.
//
// k is converted to lowercase before storing in md.
func (md MD) Append(k string, vals ...string) {
if len(vals) == 0 {
return
}
k = strings.ToLower(k)
md[k] = append(md[k], vals...)
}
// Delete removes the values for a given key k which is converted to lowercase
// before removing it from md.
func (md MD) Delete(k string) {
k = strings.ToLower(k)
delete(md, k)
}
// Join joins any number of mds into a single MD.
//
// The order of values for each key is determined by the order in which the mds
// containing those values are presented to Join.
func Join(mds ...MD) MD {
out := MD{}
for _, md := range mds {
for k, v := range md {
out[k] = append(out[k], v...)
}
}
return out
}
type mdIncomingKey struct{}
type mdOutgoingKey struct{}
// NewIncomingContext creates a new context with incoming md attached. md must
// not be modified after calling this function.
func NewIncomingContext(ctx context.Context, md Metadata) context.Context {
in := make(MD, len(md))
for k, v := range md {
in[k] = []string{v}
}
return context.WithValue(ctx, mdIncomingKey{}, in)
}
// NewOutgoingContext creates a new context with outgoing md attached. If used
// in conjunction with AppendToOutgoingContext, NewOutgoingContext will
// overwrite any previously-appended metadata. md must not be modified after
// calling this function.
func NewOutgoingContext(ctx context.Context, md Metadata) context.Context {
out := make(MD, len(md))
for k, v := range md {
out[k] = []string{v}
}
return context.WithValue(ctx, mdOutgoingKey{}, rawMD{md: out})
}
// AppendToOutgoingContext returns a new context with the provided kv merged
// with any existing metadata in the context. Please refer to the documentation
// of Pairs for a description of kv.
func AppendToOutgoingContext(ctx context.Context, kv ...string) context.Context {
if len(kv)%2 == 1 {
panic(fmt.Sprintf("metadata: AppendToOutgoingContext got an odd number of input pairs for metadata: %d", len(kv)))
}
md, _ := ctx.Value(mdOutgoingKey{}).(rawMD)
added := make([][]string, len(md.added)+1)
copy(added, md.added)
kvCopy := make([]string, 0, len(kv))
for i := 0; i < len(kv); i += 2 {
kvCopy = append(kvCopy, strings.ToLower(kv[i]), kv[i+1])
}
added[len(added)-1] = kvCopy
return context.WithValue(ctx, mdOutgoingKey{}, rawMD{md: md.md, added: added})
}
// FromIncomingContext returns the incoming metadata in ctx if it exists.
//
// All keys in the returned MD are lowercase.
func FromIncomingContext(ctx context.Context) (Metadata, bool) {
md, ok := ctx.Value(mdIncomingKey{}).(MD)
if !ok {
return nil, false
}
out := make(Metadata, len(md))
for k, v := range md {
// We need to manually convert all keys to lower case, because MD is a
// map, and there's no guarantee that the MD attached to the context is
// created using our helper functions.
if len(v) > 0 {
key := strings.ToLower(k)
out[key] = v[0]
}
}
return out, true
}
// ValueFromIncomingContext returns the metadata value corresponding to the metadata
// key from the incoming metadata if it exists. Keys are matched in a case insensitive
// manner.
func ValueFromIncomingContext(ctx context.Context, key string) []string {
md, ok := ctx.Value(mdIncomingKey{}).(MD)
if !ok {
return nil
}
if v, ok := md[key]; ok {
return copyOf(v)
}
for k, v := range md {
// Case insensitive comparison: MD is a map, and there's no guarantee
// that the MD attached to the context is created using our helper
// functions.
if strings.EqualFold(k, key) {
return copyOf(v)
}
}
return nil
}
func copyOf(v []string) []string {
vals := make([]string, len(v))
copy(vals, v)
return vals
}
// fromOutgoingContextRaw returns the un-merged, intermediary contents of rawMD.
//
// Remember to perform strings.ToLower on the keys, for both the returned MD (MD
// is a map, there's no guarantee it's created using our helper functions) and
// the extra kv pairs (AppendToOutgoingContext doesn't turn them into
// lowercase).
func fromOutgoingContextRaw(ctx context.Context) (MD, [][]string, bool) {
raw, ok := ctx.Value(mdOutgoingKey{}).(rawMD)
if !ok {
return nil, nil, false
}
return raw.md, raw.added, true
}
// FromOutgoingContext returns the outgoing metadata in ctx if it exists.
//
// All keys in the returned MD are lowercase.
func FromOutgoingContext(ctx context.Context) (Metadata, bool) {
raw, ok := ctx.Value(mdOutgoingKey{}).(rawMD)
if !ok {
return nil, false
}
mdSize := len(raw.md)
for i := range raw.added {
mdSize += len(raw.added[i]) / 2
}
out := make(Metadata, mdSize)
for k, v := range raw.md {
// We need to manually convert all keys to lower case, because MD is a
// map, and there's no guarantee that the MD attached to the context is
// created using our helper functions.
if len(v) > 0 {
key := strings.ToLower(k)
out[key] = v[0]
}
}
for _, added := range raw.added {
if len(added)%2 == 1 {
panic(fmt.Sprintf("metadata: FromOutgoingContext got an odd number of input pairs for metadata: %d", len(added)))
}
for i := 0; i < len(added); i += 2 {
key := strings.ToLower(added[i])
out[key] = added[i+1]
}
}
return out, ok
}
type rawMD struct {
md MD
added [][]string
}

View File

@ -3,21 +3,21 @@ package micro
import (
"reflect"
"go.unistack.org/micro/v3/broker"
"go.unistack.org/micro/v3/client"
"go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v3/flow"
"go.unistack.org/micro/v3/fsm"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/meter"
"go.unistack.org/micro/v3/register"
"go.unistack.org/micro/v3/resolver"
"go.unistack.org/micro/v3/router"
"go.unistack.org/micro/v3/selector"
"go.unistack.org/micro/v3/server"
"go.unistack.org/micro/v3/store"
"go.unistack.org/micro/v3/sync"
"go.unistack.org/micro/v3/tracer"
"go.unistack.org/micro/v4/broker"
"go.unistack.org/micro/v4/client"
"go.unistack.org/micro/v4/codec"
"go.unistack.org/micro/v4/flow"
"go.unistack.org/micro/v4/fsm"
"go.unistack.org/micro/v4/logger"
"go.unistack.org/micro/v4/meter"
"go.unistack.org/micro/v4/register"
"go.unistack.org/micro/v4/resolver"
"go.unistack.org/micro/v4/router"
"go.unistack.org/micro/v4/selector"
"go.unistack.org/micro/v4/server"
"go.unistack.org/micro/v4/store"
"go.unistack.org/micro/v4/sync"
"go.unistack.org/micro/v4/tracer"
)
func As(b any, target any) bool {

View File

@ -6,8 +6,8 @@ import (
"reflect"
"testing"
"go.unistack.org/micro/v3/broker"
"go.unistack.org/micro/v3/fsm"
"go.unistack.org/micro/v4/broker"
"go.unistack.org/micro/v4/fsm"
)
func TestAs(t *testing.T) {

View File

@ -2,8 +2,8 @@
package network
import (
"go.unistack.org/micro/v3/client"
"go.unistack.org/micro/v3/server"
"go.unistack.org/micro/v4/client"
"go.unistack.org/micro/v4/server"
)
// Error is network node errors

View File

@ -1,13 +1,13 @@
package network
import (
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/meter"
"go.unistack.org/micro/v3/network/tunnel"
"go.unistack.org/micro/v3/proxy"
"go.unistack.org/micro/v3/router"
"go.unistack.org/micro/v3/tracer"
"go.unistack.org/micro/v3/util/id"
"go.unistack.org/micro/v4/logger"
"go.unistack.org/micro/v4/meter"
"go.unistack.org/micro/v4/network/tunnel"
"go.unistack.org/micro/v4/proxy"
"go.unistack.org/micro/v4/router"
"go.unistack.org/micro/v4/tracer"
"go.unistack.org/micro/v4/util/id"
)
// Option func

View File

@ -8,9 +8,9 @@ import (
"sync"
"time"
maddr "go.unistack.org/micro/v3/util/addr"
mnet "go.unistack.org/micro/v3/util/net"
"go.unistack.org/micro/v3/util/rand"
maddr "go.unistack.org/micro/v4/util/addr"
mnet "go.unistack.org/micro/v4/util/net"
"go.unistack.org/micro/v4/util/rand"
)
type memorySocket struct {

View File

@ -5,10 +5,10 @@ import (
"crypto/tls"
"time"
"go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/meter"
"go.unistack.org/micro/v3/tracer"
"go.unistack.org/micro/v4/codec"
"go.unistack.org/micro/v4/logger"
"go.unistack.org/micro/v4/meter"
"go.unistack.org/micro/v4/tracer"
)
// Options struct holds the transport options

View File

@ -5,7 +5,7 @@ import (
"context"
"time"
"go.unistack.org/micro/v3/metadata"
"go.unistack.org/micro/v4/metadata"
)
var (

View File

@ -5,11 +5,11 @@ import (
"context"
"fmt"
"go.unistack.org/micro/v3/broker"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/metadata"
"go.unistack.org/micro/v3/network/transport"
"go.unistack.org/micro/v3/network/tunnel"
"go.unistack.org/micro/v4/broker"
"go.unistack.org/micro/v4/logger"
"go.unistack.org/micro/v4/metadata"
"go.unistack.org/micro/v4/network/transport"
"go.unistack.org/micro/v4/network/tunnel"
)
type tunBroker struct {

View File

@ -3,11 +3,11 @@ package tunnel
import (
"time"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/meter"
"go.unistack.org/micro/v3/network/transport"
"go.unistack.org/micro/v3/tracer"
"go.unistack.org/micro/v3/util/id"
"go.unistack.org/micro/v4/logger"
"go.unistack.org/micro/v4/meter"
"go.unistack.org/micro/v4/network/transport"
"go.unistack.org/micro/v4/tracer"
"go.unistack.org/micro/v4/util/id"
)
var (

View File

@ -1,8 +1,8 @@
package transport
import (
"go.unistack.org/micro/v3/network/transport"
"go.unistack.org/micro/v3/network/tunnel"
"go.unistack.org/micro/v4/network/transport"
"go.unistack.org/micro/v4/network/tunnel"
)
type tunListener struct {

View File

@ -5,8 +5,8 @@ import (
"context"
"fmt"
"go.unistack.org/micro/v3/network/transport"
"go.unistack.org/micro/v3/network/tunnel"
"go.unistack.org/micro/v4/network/transport"
"go.unistack.org/micro/v4/network/tunnel"
)
type tunTransport struct {

View File

@ -6,7 +6,7 @@ import (
"errors"
"time"
"go.unistack.org/micro/v3/network/transport"
"go.unistack.org/micro/v4/network/transport"
)
// DefaultTunnel contains default tunnel implementation

View File

@ -5,17 +5,17 @@ import (
"fmt"
"time"
"go.unistack.org/micro/v3/broker"
"go.unistack.org/micro/v3/client"
"go.unistack.org/micro/v3/config"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/metadata"
"go.unistack.org/micro/v3/meter"
"go.unistack.org/micro/v3/register"
"go.unistack.org/micro/v3/router"
"go.unistack.org/micro/v3/server"
"go.unistack.org/micro/v3/store"
"go.unistack.org/micro/v3/tracer"
"go.unistack.org/micro/v4/broker"
"go.unistack.org/micro/v4/client"
"go.unistack.org/micro/v4/config"
"go.unistack.org/micro/v4/logger"
"go.unistack.org/micro/v4/metadata"
"go.unistack.org/micro/v4/meter"
"go.unistack.org/micro/v4/register"
"go.unistack.org/micro/v4/router"
"go.unistack.org/micro/v4/server"
"go.unistack.org/micro/v4/store"
"go.unistack.org/micro/v4/tracer"
)
// Options for micro service

View File

@ -7,7 +7,7 @@ import (
"net/http/pprof"
"sync"
profile "go.unistack.org/micro/v3/profiler"
profile "go.unistack.org/micro/v4/profiler"
)
type httpProfile struct {

View File

@ -9,7 +9,7 @@ import (
"sync"
"time"
profile "go.unistack.org/micro/v3/profiler"
profile "go.unistack.org/micro/v4/profiler"
)
type profiler struct {

View File

@ -2,11 +2,11 @@
package proxy
import (
"go.unistack.org/micro/v3/client"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/meter"
"go.unistack.org/micro/v3/router"
"go.unistack.org/micro/v3/tracer"
"go.unistack.org/micro/v4/client"
"go.unistack.org/micro/v4/logger"
"go.unistack.org/micro/v4/meter"
"go.unistack.org/micro/v4/router"
"go.unistack.org/micro/v4/tracer"
)
// Options for proxy

View File

@ -4,7 +4,7 @@ package proxy
import (
"context"
"go.unistack.org/micro/v3/server"
"go.unistack.org/micro/v4/server"
)
// DefaultEndpoint holds default proxy address

View File

@ -6,9 +6,9 @@ import (
"sync"
"time"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/register"
"go.unistack.org/micro/v3/util/id"
"go.unistack.org/micro/v4/logger"
"go.unistack.org/micro/v4/register"
"go.unistack.org/micro/v4/util/id"
)
var (

View File

@ -7,7 +7,7 @@ import (
"testing"
"time"
"go.unistack.org/micro/v3/register"
"go.unistack.org/micro/v4/register"
)
var testData = map[string][]*register.Service{

View File

@ -5,10 +5,10 @@ import (
"crypto/tls"
"time"
"go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/meter"
"go.unistack.org/micro/v3/tracer"
"go.unistack.org/micro/v4/codec"
"go.unistack.org/micro/v4/logger"
"go.unistack.org/micro/v4/meter"
"go.unistack.org/micro/v4/tracer"
)
// Options holds options for register

View File

@ -5,7 +5,7 @@ import (
"context"
"errors"
"go.unistack.org/micro/v3/metadata"
"go.unistack.org/micro/v4/metadata"
)
const (

View File

@ -7,7 +7,7 @@ import (
"sync"
"time"
"go.unistack.org/micro/v3/resolver"
"go.unistack.org/micro/v4/resolver"
)
// Resolver is a DNS network resolve

View File

@ -5,7 +5,7 @@ import (
"fmt"
"net"
"go.unistack.org/micro/v3/resolver"
"go.unistack.org/micro/v4/resolver"
)
// Resolver is a DNS network resolve

View File

@ -8,7 +8,7 @@ import (
"net/http"
"net/url"
"go.unistack.org/micro/v3/resolver"
"go.unistack.org/micro/v4/resolver"
)
// nolint: golint,revive

View File

@ -2,7 +2,7 @@
package noop
import (
"go.unistack.org/micro/v3/resolver"
"go.unistack.org/micro/v4/resolver"
)
// Resolver contains noop resolver

View File

@ -4,8 +4,8 @@ package register
import (
"context"
"go.unistack.org/micro/v3/register"
"go.unistack.org/micro/v3/resolver"
"go.unistack.org/micro/v4/register"
"go.unistack.org/micro/v4/resolver"
)
// Resolver is a register network resolver

View File

@ -2,7 +2,7 @@
package static
import (
"go.unistack.org/micro/v3/resolver"
"go.unistack.org/micro/v4/resolver"
)
// Resolver returns a static list of nodes. In the event the node list

View File

@ -3,9 +3,9 @@ package router
import (
"context"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/register"
"go.unistack.org/micro/v3/util/id"
"go.unistack.org/micro/v4/logger"
"go.unistack.org/micro/v4/register"
"go.unistack.org/micro/v4/util/id"
)
// Options are router options

View File

@ -3,7 +3,7 @@ package router
import (
"hash/fnv"
"go.unistack.org/micro/v3/metadata"
"go.unistack.org/micro/v4/metadata"
)
var (

View File

@ -1,8 +1,8 @@
package random
import (
"go.unistack.org/micro/v3/selector"
"go.unistack.org/micro/v3/util/rand"
"go.unistack.org/micro/v4/selector"
"go.unistack.org/micro/v4/util/rand"
)
type random struct{}

View File

@ -3,7 +3,7 @@ package random
import (
"testing"
"go.unistack.org/micro/v3/selector"
"go.unistack.org/micro/v4/selector"
)
func TestRandom(t *testing.T) {

View File

@ -1,8 +1,8 @@
package roundrobin
import (
"go.unistack.org/micro/v3/selector"
"go.unistack.org/micro/v3/util/rand"
"go.unistack.org/micro/v4/selector"
"go.unistack.org/micro/v4/util/rand"
)
// NewSelector returns an initialised round robin selector

View File

@ -3,7 +3,7 @@ package roundrobin
import (
"testing"
"go.unistack.org/micro/v3/selector"
"go.unistack.org/micro/v4/selector"
)
func TestRoundRobin(t *testing.T) {

View File

@ -1,6 +1,6 @@
package server
import "go.unistack.org/micro/v3/errors"
import "go.unistack.org/micro/v4/errors"
type Error struct {
id string

View File

@ -3,7 +3,7 @@ package server
import (
"testing"
"go.unistack.org/micro/v3/errors"
"go.unistack.org/micro/v4/errors"
)
func TestError(t *testing.T) {

View File

@ -9,16 +9,16 @@ import (
"sync"
"time"
"go.unistack.org/micro/v3/broker"
"go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v3/errors"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/metadata"
"go.unistack.org/micro/v3/options"
"go.unistack.org/micro/v3/register"
maddr "go.unistack.org/micro/v3/util/addr"
mnet "go.unistack.org/micro/v3/util/net"
"go.unistack.org/micro/v3/util/rand"
"go.unistack.org/micro/v4/broker"
"go.unistack.org/micro/v4/codec"
"go.unistack.org/micro/v4/errors"
"go.unistack.org/micro/v4/logger"
"go.unistack.org/micro/v4/metadata"
"go.unistack.org/micro/v4/options"
"go.unistack.org/micro/v4/register"
maddr "go.unistack.org/micro/v4/util/addr"
mnet "go.unistack.org/micro/v4/util/net"
"go.unistack.org/micro/v4/util/rand"
)
// DefaultCodecs will be used to encode/decode

View File

@ -5,12 +5,12 @@ import (
"fmt"
"testing"
"go.unistack.org/micro/v3/broker"
"go.unistack.org/micro/v3/client"
"go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/options"
"go.unistack.org/micro/v3/server"
"go.unistack.org/micro/v4/broker"
"go.unistack.org/micro/v4/client"
"go.unistack.org/micro/v4/codec"
"go.unistack.org/micro/v4/logger"
"go.unistack.org/micro/v4/options"
"go.unistack.org/micro/v4/server"
)
type TestHandler struct {

View File

@ -7,16 +7,16 @@ import (
"sync"
"time"
"go.unistack.org/micro/v3/broker"
"go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/metadata"
"go.unistack.org/micro/v3/meter"
"go.unistack.org/micro/v3/options"
"go.unistack.org/micro/v3/register"
msync "go.unistack.org/micro/v3/sync"
"go.unistack.org/micro/v3/tracer"
"go.unistack.org/micro/v3/util/id"
"go.unistack.org/micro/v4/broker"
"go.unistack.org/micro/v4/codec"
"go.unistack.org/micro/v4/logger"
"go.unistack.org/micro/v4/metadata"
"go.unistack.org/micro/v4/meter"
"go.unistack.org/micro/v4/options"
"go.unistack.org/micro/v4/register"
msync "go.unistack.org/micro/v4/sync"
"go.unistack.org/micro/v4/tracer"
"go.unistack.org/micro/v4/util/id"
)
// Option func

View File

@ -4,10 +4,10 @@ import (
"net"
"time"
"go.unistack.org/micro/v3/metadata"
"go.unistack.org/micro/v3/register"
"go.unistack.org/micro/v3/util/addr"
"go.unistack.org/micro/v3/util/backoff"
"go.unistack.org/micro/v4/metadata"
"go.unistack.org/micro/v4/register"
"go.unistack.org/micro/v4/util/addr"
"go.unistack.org/micro/v4/util/backoff"
)
var (

View File

@ -5,8 +5,8 @@ import (
"context"
"time"
"go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v3/metadata"
"go.unistack.org/micro/v4/codec"
"go.unistack.org/micro/v4/metadata"
)
// DefaultServer default server

View File

@ -9,17 +9,17 @@ import (
"github.com/KimMachineGun/automemlimit/memlimit"
"go.uber.org/automaxprocs/maxprocs"
"go.unistack.org/micro/v3/broker"
"go.unistack.org/micro/v3/client"
"go.unistack.org/micro/v3/config"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/meter"
"go.unistack.org/micro/v3/register"
"go.unistack.org/micro/v3/router"
"go.unistack.org/micro/v3/server"
"go.unistack.org/micro/v3/store"
"go.unistack.org/micro/v3/tracer"
utildns "go.unistack.org/micro/v3/util/dns"
"go.unistack.org/micro/v4/broker"
"go.unistack.org/micro/v4/client"
"go.unistack.org/micro/v4/config"
"go.unistack.org/micro/v4/logger"
"go.unistack.org/micro/v4/meter"
"go.unistack.org/micro/v4/register"
"go.unistack.org/micro/v4/router"
"go.unistack.org/micro/v4/server"
"go.unistack.org/micro/v4/store"
"go.unistack.org/micro/v4/tracer"
utildns "go.unistack.org/micro/v4/util/dns"
)
func init() {

View File

@ -5,16 +5,16 @@ import (
"reflect"
"testing"
"go.unistack.org/micro/v3/broker"
"go.unistack.org/micro/v3/client"
"go.unistack.org/micro/v3/config"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/meter"
"go.unistack.org/micro/v3/register"
"go.unistack.org/micro/v3/router"
"go.unistack.org/micro/v3/server"
"go.unistack.org/micro/v3/store"
"go.unistack.org/micro/v3/tracer"
"go.unistack.org/micro/v4/broker"
"go.unistack.org/micro/v4/client"
"go.unistack.org/micro/v4/config"
"go.unistack.org/micro/v4/logger"
"go.unistack.org/micro/v4/meter"
"go.unistack.org/micro/v4/register"
"go.unistack.org/micro/v4/router"
"go.unistack.org/micro/v4/server"
"go.unistack.org/micro/v4/store"
"go.unistack.org/micro/v4/tracer"
)
func TestClient(t *testing.T) {

View File

@ -8,8 +8,8 @@ import (
"time"
cache "github.com/patrickmn/go-cache"
"go.unistack.org/micro/v3/options"
"go.unistack.org/micro/v3/store"
"go.unistack.org/micro/v4/options"
"go.unistack.org/micro/v4/store"
)
// NewStore returns a memory store

View File

@ -5,7 +5,7 @@ import (
"testing"
"time"
"go.unistack.org/micro/v3/store"
"go.unistack.org/micro/v4/store"
)
type testHook struct {

View File

@ -5,8 +5,8 @@ import (
"sync"
"sync/atomic"
"go.unistack.org/micro/v3/options"
"go.unistack.org/micro/v3/util/id"
"go.unistack.org/micro/v4/options"
"go.unistack.org/micro/v4/util/id"
)
var _ Store = (*noopStore)(nil)

View File

@ -5,12 +5,12 @@ import (
"crypto/tls"
"time"
"go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/metadata"
"go.unistack.org/micro/v3/meter"
"go.unistack.org/micro/v3/options"
"go.unistack.org/micro/v3/tracer"
"go.unistack.org/micro/v4/codec"
"go.unistack.org/micro/v4/logger"
"go.unistack.org/micro/v4/metadata"
"go.unistack.org/micro/v4/meter"
"go.unistack.org/micro/v4/options"
"go.unistack.org/micro/v4/tracer"
)
// Options contains configuration for the Store

View File

@ -3,9 +3,9 @@ package sync
import (
"time"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/meter"
"go.unistack.org/micro/v3/tracer"
"go.unistack.org/micro/v4/logger"
"go.unistack.org/micro/v4/meter"
"go.unistack.org/micro/v4/tracer"
)
// Options holds the sync options

View File

@ -4,8 +4,8 @@ import (
"context"
"time"
"go.unistack.org/micro/v3/tracer"
"go.unistack.org/micro/v3/util/id"
"go.unistack.org/micro/v4/tracer"
"go.unistack.org/micro/v4/util/id"
)
var _ tracer.Tracer = (*Tracer)(nil)

View File

@ -7,9 +7,9 @@ import (
"strings"
"testing"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/logger/slog"
"go.unistack.org/micro/v3/tracer"
"go.unistack.org/micro/v4/logger"
"go.unistack.org/micro/v4/logger/slog"
"go.unistack.org/micro/v4/tracer"
)
func TestLoggerWithTracer(t *testing.T) {

View File

@ -4,7 +4,7 @@ import (
"context"
"time"
"go.unistack.org/micro/v3/util/id"
"go.unistack.org/micro/v4/util/id"
)
var _ Tracer = (*noopTracer)(nil)

View File

@ -3,7 +3,7 @@ package tracer
import (
"context"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v4/logger"
)
type SpanStatus int

View File

@ -4,7 +4,7 @@ package tracer
import (
"context"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v4/logger"
)
var (

View File

@ -7,8 +7,8 @@ import (
"sync"
"time"
"go.unistack.org/micro/v3/meter"
"go.unistack.org/micro/v3/semconv"
"go.unistack.org/micro/v4/meter"
"go.unistack.org/micro/v4/semconv"
)
// DialFunc is a [net.Resolver.Dial] function.

View File

@ -8,7 +8,7 @@ import (
"sync/atomic"
"time"
"go.unistack.org/micro/v3/tracer"
"go.unistack.org/micro/v4/tracer"
grpc_codes "google.golang.org/grpc/codes"
"google.golang.org/grpc/peer"
"google.golang.org/grpc/stats"

View File

@ -23,7 +23,7 @@ import (
"strings"
"sync"
"go.unistack.org/micro/v3/tracer"
"go.unistack.org/micro/v4/tracer"
)
const (

View File

@ -8,8 +8,8 @@ import (
"net/http"
"strings"
"go.unistack.org/micro/v3/metadata"
"go.unistack.org/micro/v3/selector/random"
"go.unistack.org/micro/v4/metadata"
"go.unistack.org/micro/v4/selector/random"
)
// Write sets the status and body on a http ResponseWriter

View File

@ -9,10 +9,10 @@ import (
"net/http"
"testing"
"go.unistack.org/micro/v3/register"
"go.unistack.org/micro/v3/register/memory"
"go.unistack.org/micro/v3/router"
regRouter "go.unistack.org/micro/v3/router/register"
"go.unistack.org/micro/v4/register"
"go.unistack.org/micro/v4/register/memory"
"go.unistack.org/micro/v4/router"
regRouter "go.unistack.org/micro/v4/router/register"
)
func TestRoundTripper(t *testing.T) {

View File

@ -1,6 +1,6 @@
package http
import "go.unistack.org/micro/v3/router"
import "go.unistack.org/micro/v4/router"
// Options struct
type Options struct {

View File

@ -4,8 +4,8 @@ import (
"errors"
"net/http"
"go.unistack.org/micro/v3/router"
"go.unistack.org/micro/v3/selector"
"go.unistack.org/micro/v4/router"
"go.unistack.org/micro/v4/selector"
)
type roundTripper struct {

View File

@ -4,7 +4,7 @@ package jitter
import (
"time"
"go.unistack.org/micro/v3/util/rand"
"go.unistack.org/micro/v4/util/rand"
)
// Random returns a random time to jitter with max cap specified

View File

@ -4,7 +4,7 @@ import (
"context"
"time"
"go.unistack.org/micro/v3/util/rand"
"go.unistack.org/micro/v4/util/rand"
)
// Ticker is similar to time.Ticker but ticks at random intervals between

View File

@ -6,7 +6,7 @@ import (
"testing"
"time"
rutil "go.unistack.org/micro/v3/util/reflect"
rutil "go.unistack.org/micro/v4/util/reflect"
)
func TestStructFields(t *testing.T) {

View File

@ -4,8 +4,8 @@ import (
"context"
"time"
"go.unistack.org/micro/v3/register"
jitter "go.unistack.org/micro/v3/util/jitter"
"go.unistack.org/micro/v4/register"
jitter "go.unistack.org/micro/v4/util/jitter"
)
func addNodes(old, neu []*register.Node) []*register.Node {

View File

@ -4,7 +4,7 @@ import (
"os"
"testing"
"go.unistack.org/micro/v3/register"
"go.unistack.org/micro/v4/register"
)
func TestRemove(t *testing.T) {

View File

@ -5,7 +5,7 @@ import (
"sync"
"time"
"go.unistack.org/micro/v3/util/id"
"go.unistack.org/micro/v4/util/id"
)
// Buffer is ring buffer

View File

@ -4,7 +4,7 @@ package socket
import (
"io"
"go.unistack.org/micro/v3/network/transport"
"go.unistack.org/micro/v4/network/transport"
)
// Socket is our pseudo socket for transport.Socket

View File

@ -5,10 +5,10 @@ import (
"context"
"sync"
"go.unistack.org/micro/v3/client"
"go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v3/metadata"
"go.unistack.org/micro/v3/server"
"go.unistack.org/micro/v4/client"
"go.unistack.org/micro/v4/codec"
"go.unistack.org/micro/v4/metadata"
"go.unistack.org/micro/v4/server"
)
// Stream interface

View File

@ -16,10 +16,10 @@ import (
"time"
sqlmock "github.com/DATA-DOG/go-sqlmock"
"go.unistack.org/micro/v3/client"
"go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v3/errors"
"go.unistack.org/micro/v3/metadata"
"go.unistack.org/micro/v4/client"
"go.unistack.org/micro/v4/codec"
"go.unistack.org/micro/v4/errors"
"go.unistack.org/micro/v4/metadata"
"golang.org/x/sync/errgroup"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"

Some files were not shown because too many files have changed in this diff Show More