Compare commits

..

6 Commits

Author SHA1 Message Date
116eed51e3 Merge branch 'v3' into hasql-v3
Some checks failed
test / test (pull_request) Failing after 15m45s
lint / lint (pull_request) Failing after 15m58s
coverage / build (pull_request) Failing after 16m10s
2025-09-20 23:01:14 +03:00
e09c34c691 split files
Some checks failed
coverage / build (pull_request) Failing after 4m6s
test / test (pull_request) Failing after 16m18s
lint / lint (pull_request) Failing after 16m37s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2025-09-20 23:00:57 +03:00
ffd5e416c8 split files
Some checks failed
lint / lint (pull_request) Failing after 3m56s
test / test (pull_request) Failing after 15m58s
coverage / build (pull_request) Failing after 16m18s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2025-09-20 22:58:33 +03:00
vtolstov
3cef42f776 Apply Code Coverage Badge
Some checks failed
coverage / build (pull_request) Successful in 2m14s
lint / lint (pull_request) Failing after 2m40s
test / test (pull_request) Failing after 17m12s
2025-09-19 08:44:33 +00:00
4de9431df0 initial cluster sql support
Some checks failed
test / test (push) Failing after 19m49s
coverage / build (push) Failing after 19m59s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2025-09-19 11:39:26 +03:00
19e3288b1d initial cluster sql support
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2025-09-19 11:39:03 +03:00
7 changed files with 23 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
# Micro # Micro
![Coverage](https://img.shields.io/badge/Coverage-34.1%25-yellow) ![Coverage](https://img.shields.io/badge/Coverage-33.6%25-yellow)
[![License](https://img.shields.io/:license-apache-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![License](https://img.shields.io/:license-apache-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Doc](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat-square)](https://pkg.go.dev/go.unistack.org/micro/v3?tab=overview) [![Doc](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat-square)](https://pkg.go.dev/go.unistack.org/micro/v3?tab=overview)
[![Status](https://git.unistack.org/unistack-org/micro/actions/workflows/job_tests.yml/badge.svg?branch=v3)](https://git.unistack.org/unistack-org/micro/actions?query=workflow%3Abuild+branch%3Av3+event%3Apush) [![Status](https://git.unistack.org/unistack-org/micro/actions/workflows/job_tests.yml/badge.svg?branch=v3)](https://git.unistack.org/unistack-org/micro/actions?query=workflow%3Abuild+branch%3Av3+event%3Apush)

View File

@@ -17,6 +17,11 @@ import (
"go.unistack.org/micro/v3/tracer" "go.unistack.org/micro/v3/tracer"
) )
// DefaultCodecs will be used to encode/decode data
var DefaultCodecs = map[string]codec.Codec{
"application/octet-stream": codec.NewCodec(),
}
type noopClient struct { type noopClient struct {
funcPublish FuncPublish funcPublish FuncPublish
funcBatchPublish FuncBatchPublish funcBatchPublish FuncBatchPublish
@@ -173,6 +178,9 @@ func (n *noopClient) newCodec(contentType string) (codec.Codec, error) {
if cf, ok := n.opts.Codecs[contentType]; ok { if cf, ok := n.opts.Codecs[contentType]; ok {
return cf, nil return cf, nil
} }
if cf, ok := DefaultCodecs[contentType]; ok {
return cf, nil
}
return nil, codec.ErrUnknownContentType return nil, codec.ErrUnknownContentType
} }

View File

@@ -3,8 +3,6 @@ package client
import ( import (
"context" "context"
"testing" "testing"
"go.unistack.org/micro/v3/codec"
) )
type testHook struct { type testHook struct {
@@ -21,7 +19,7 @@ func (t *testHook) Publish(fn FuncPublish) FuncPublish {
func TestNoopHook(t *testing.T) { func TestNoopHook(t *testing.T) {
h := &testHook{} h := &testHook{}
c := NewClient(Codec("application/octet-stream", codec.NewCodec()), Hooks(HookPublish(h.Publish))) c := NewClient(Hooks(HookPublish(h.Publish)))
if err := c.Init(); err != nil { if err := c.Init(); err != nil {
t.Fatal(err) t.Fatal(err)

View File

@@ -198,7 +198,7 @@ func NewOptions(opts ...Option) Options {
options := Options{ options := Options{
Context: context.Background(), Context: context.Background(),
ContentType: DefaultContentType, ContentType: DefaultContentType,
Codecs: make(map[string]codec.Codec), Codecs: DefaultCodecs,
CallOptions: CallOptions{ CallOptions: CallOptions{
Context: context.Background(), Context: context.Background(),
Backoff: DefaultBackoff, Backoff: DefaultBackoff,

2
go.mod
View File

@@ -1,6 +1,6 @@
module go.unistack.org/micro/v3 module go.unistack.org/micro/v3
go 1.24.0 go 1.23.0
require ( require (
dario.cat/mergo v1.0.1 dario.cat/mergo v1.0.1

View File

@@ -62,7 +62,7 @@ func TestTime(t *testing.T) {
WithHandlerFunc(slog.NewTextHandler), WithHandlerFunc(slog.NewTextHandler),
logger.WithAddStacktrace(true), logger.WithAddStacktrace(true),
logger.WithTimeFunc(func() time.Time { logger.WithTimeFunc(func() time.Time {
return time.Unix(0, 0).UTC() return time.Unix(0, 0)
}), }),
) )
if err := l.Init(logger.WithFields("key1", "val1")); err != nil { if err := l.Init(logger.WithFields("key1", "val1")); err != nil {
@@ -71,7 +71,8 @@ func TestTime(t *testing.T) {
l.Error(ctx, "msg1", errors.New("err")) l.Error(ctx, "msg1", errors.New("err"))
if !bytes.Contains(buf.Bytes(), []byte(`timestamp=1970-01-01T00:00:00.000000000Z`)) { if !bytes.Contains(buf.Bytes(), []byte(`timestamp=1970-01-01T03:00:00.000000000+03:00`)) &&
!bytes.Contains(buf.Bytes(), []byte(`timestamp=1970-01-01T00:00:00.000000000Z`)) {
t.Fatalf("logger error not works, buf contains: %s", buf.Bytes()) t.Fatalf("logger error not works, buf contains: %s", buf.Bytes())
} }
} }

View File

@@ -21,6 +21,11 @@ import (
"go.unistack.org/micro/v3/util/rand" "go.unistack.org/micro/v3/util/rand"
) )
// DefaultCodecs will be used to encode/decode
var DefaultCodecs = map[string]codec.Codec{
"application/octet-stream": codec.NewCodec(),
}
const ( const (
defaultContentType = "application/json" defaultContentType = "application/json"
) )
@@ -88,6 +93,9 @@ func (n *noopServer) newCodec(contentType string) (codec.Codec, error) {
if cf, ok := n.opts.Codecs[contentType]; ok { if cf, ok := n.opts.Codecs[contentType]; ok {
return cf, nil return cf, nil
} }
if cf, ok := DefaultCodecs[contentType]; ok {
return cf, nil
}
return nil, codec.ErrUnknownContentType return nil, codec.ErrUnknownContentType
} }