Compare commits

...

33 Commits

Author SHA1 Message Date
6e6c31b5dd Merge pull request #69 from unistack-org/master
merge master
2021-12-28 09:30:34 +03:00
94929878fe Merge pull request #68 from unistack-org/improvements
improvements
2021-12-28 09:23:45 +03:00
8ce469a09e tracer: fixes
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-12-28 09:18:52 +03:00
88788776d2 Merge branch 'master' into v3 2021-12-16 15:04:08 +03:00
e143e2b547 client: allow to set metadata for message
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-12-16 15:03:42 +03:00
a36f99e30b Merge pull request #66 from unistack-org/minor_changes
config: add new error type
2021-11-30 07:35:27 +03:00
326ee53333 config: add new error type
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-11-30 07:34:49 +03:00
1244c5bb4d Merge pull request #65 from unistack-org/master
merge changes from master
2021-11-24 00:59:00 +03:00
4ccc8a9c85 Merge pull request #64 from unistack-org/minor_changes
minor changes
2021-11-24 00:58:21 +03:00
8a2e84d489 minor changes
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-11-24 00:57:59 +03:00
d29363b78d codec: add NewFrame helper
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-11-19 09:22:13 +03:00
734f751055 Merge pull request #63 from unistack-org/master
util/http: add type alias
2021-11-19 03:04:55 +03:00
55d8a9ee20 util/http: add type alias
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-11-19 03:04:08 +03:00
07c93042ba Merge pull request #62 from unistack-org/master
merge stable
2021-11-18 16:01:10 +03:00
b9bbfdf159 config: add watch option helper
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-11-18 15:57:14 +03:00
fbad257acc config: add helpers to load/save options (#60) 2021-11-18 15:46:30 +03:00
1829febb6e util/http: fix lint issues
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-11-09 17:07:52 +03:00
7838fa62a8 util/trie: import some code from chi router
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-11-09 16:34:05 +03:00
332803d8de update workflows
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-27 22:52:48 +03:00
11c868d476 Merge branch 'v3' 2021-10-27 22:51:58 +03:00
38d6e482d7 util/reflect: fix StructFields
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-27 22:51:35 +03:00
07d4085201 util/reflect: fix reflect methods
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-27 12:55:48 +03:00
45f30c0be3 util/reflect: ZeroFieldByPath and SetFieldByPath
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-26 14:12:37 +03:00
bcaea675a7 util/reflect: add method to zero struct field
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-25 14:41:19 +03:00
3087ba1d73 regen
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-23 23:45:53 +03:00
3f5b19497c meter: add Clone method
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-09 23:50:57 +03:00
37d937d7ae meter: add missing options
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-09 19:16:45 +03:00
7d68f2396e tracer: dont return noop from context
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-07 22:46:47 +03:00
0854a7ea72 micro: add simple test
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-07 20:59:27 +03:00
5eb0e56373 move all imports to own domain
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-02 19:55:07 +03:00
6af837fd25 fixup workflows
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-02 18:42:20 +03:00
ada59119cc util/http: add test case
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-02 18:34:22 +03:00
8abc913b28 codec: add MarshalAppend func
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-01 01:08:24 +03:00
172 changed files with 1621 additions and 876 deletions

View File

@@ -3,6 +3,7 @@ on:
push:
branches:
- master
- v3
jobs:
test:
name: test

View File

@@ -9,7 +9,7 @@
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
name: "codeql"
on:
workflow_run:
@@ -17,16 +17,16 @@ on:
types:
- completed
push:
branches: [ master ]
branches: [ master, v3 ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
branches: [ master, v3 ]
schedule:
- cron: '34 1 * * 0'
jobs:
analyze:
name: Analyze
name: analyze
runs-on: ubuntu-latest
permissions:
actions: read
@@ -42,11 +42,14 @@ jobs:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
steps:
- name: Checkout repository
- name: checkout
uses: actions/checkout@v2
- name: setup
uses: actions/setup-go@v2
with:
go-version: 1.16
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
- name: init
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
@@ -57,7 +60,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
- name: autobuild
uses: github/codeql-action/autobuild@v1
# Command-line programs to run using the OS shell.
@@ -71,5 +74,5 @@ jobs:
# make bootstrap
# make release
- name: Perform CodeQL Analysis
- name: analyze
uses: github/codeql-action/analyze@v1

View File

@@ -1,66 +1,31 @@
name: "prautomerge"
on:
workflow_run:
workflows: ["prbuild"]
types:
- completed
pull_request_target:
types: [assigned, opened, synchronize, reopened]
permissions:
contents: write
pull-requests: write
contents: write
jobs:
Dependabot-Automerge:
dependabot:
runs-on: ubuntu-latest
# Contains workaround to execute if dependabot updates the PR by checking for the base branch in the linked PR
# The the github.event.workflow_run.event value is 'push' and not 'pull_request'
# dont work with multiple workflows when last returns success
if: >-
github.event.workflow_run.conclusion == 'success'
&& github.actor == 'dependabot[bot]'
&& github.event.sender.login == 'dependabot[bot]'
&& github.event.sender.type == 'Bot'
&& (github.event.workflow_run.event == 'pull_request'
|| (github.event.workflow_run.event == 'push' && github.event.workflow_run.pull_requests[0].base.ref == github.event.repository.default_branch ))
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Approve Changes and Merge changes if label 'dependencies' is set
uses: actions/github-script@v5
- name: metadata
id: metadata
uses: dependabot/fetch-metadata@v1.1.1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
console.log(context.payload.workflow_run);
var labelNames = await github.paginate(
github.issues.listLabelsOnIssue,
{
repo: context.repo.repo,
owner: context.repo.owner,
issue_number: context.payload.workflow_run.pull_requests[0].number,
},
(response) => response.data.map(
(label) => label.name
)
);
console.log(labelNames);
if (labelNames.includes('dependencies')) {
console.log('Found label');
await github.pulls.createReview({
repo: context.repo.repo,
owner: context.repo.owner,
pull_number: context.payload.workflow_run.pull_requests[0].number,
event: 'APPROVE'
});
console.log('Approved PR');
await github.pulls.merge({
repo: context.repo.repo,
owner: context.repo.owner,
pull_number: context.payload.workflow_run.pull_requests[0].number,
});
console.log('Merged PR');
}
github-token: "${{ secrets.TOKEN }}"
- name: approve
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.TOKEN}}
- name: merge
if: ${{contains(steps.metadata.outputs.dependency-names, 'go.unistack.org')}}
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.TOKEN}}

View File

@@ -3,6 +3,7 @@ on:
pull_request:
branches:
- master
- v3
jobs:
test:
name: test

View File

@@ -1,13 +1,13 @@
package api
package api // import "go.unistack.org/micro/v3/api"
import (
"errors"
"regexp"
"strings"
"github.com/unistack-org/micro/v3/metadata"
"github.com/unistack-org/micro/v3/register"
"github.com/unistack-org/micro/v3/server"
"go.unistack.org/micro/v3/metadata"
"go.unistack.org/micro/v3/register"
"go.unistack.org/micro/v3/server"
)
// nolint: revive

View File

@@ -1,5 +1,5 @@
// Package handler provides http handlers
package handler
package handler // import "go.unistack.org/micro/v3/api/handler"
import (
"net/http"

View File

@@ -1,9 +1,9 @@
package handler
import (
"github.com/unistack-org/micro/v3/api/router"
"github.com/unistack-org/micro/v3/client"
"github.com/unistack-org/micro/v3/logger"
"go.unistack.org/micro/v3/api/router"
"go.unistack.org/micro/v3/client"
"go.unistack.org/micro/v3/logger"
)
// DefaultMaxRecvSize specifies max recv size for handler

View File

@@ -1,12 +1,12 @@
// Package grpc resolves a grpc service like /greeter.Say/Hello to greeter service
package grpc
package grpc // import "go.unistack.org/micro/v3/api/resolver/grpc"
import (
"errors"
"net/http"
"strings"
"github.com/unistack-org/micro/v3/api/resolver"
"go.unistack.org/micro/v3/api/resolver"
)
// Resolver struct

View File

@@ -1,10 +1,10 @@
// Package host resolves using http host
package host
package host // import "go.unistack.org/micro/v3/api/resolver/host"
import (
"net/http"
"github.com/unistack-org/micro/v3/api/resolver"
"go.unistack.org/micro/v3/api/resolver"
)
type hostResolver struct {

View File

@@ -3,7 +3,7 @@ package resolver
import (
"context"
"github.com/unistack-org/micro/v3/register"
"go.unistack.org/micro/v3/register"
)
// Options struct

View File

@@ -1,11 +1,11 @@
// Package path resolves using http path
package path
package path // import "go.unistack.org/micro/v3/api/resolver/path"
import (
"net/http"
"strings"
"github.com/unistack-org/micro/v3/api/resolver"
"go.unistack.org/micro/v3/api/resolver"
)
// Resolver the path resolver

View File

@@ -1,5 +1,5 @@
// Package resolver resolves a http request to an endpoint
package resolver
package resolver // import "go.unistack.org/micro/v3/api/resolver"
import (
"errors"

View File

@@ -1,14 +1,14 @@
// Package subdomain is a resolver which uses the subdomain to determine the domain to route to. It
// offloads the endpoint resolution to a child resolver which is provided in New.
package subdomain
package subdomain // import "go.unistack.org/micro/v3/api/resolver/subdomain"
import (
"net"
"net/http"
"strings"
"github.com/unistack-org/micro/v3/api/resolver"
"github.com/unistack-org/micro/v3/logger"
"go.unistack.org/micro/v3/api/resolver"
"go.unistack.org/micro/v3/logger"
"golang.org/x/net/publicsuffix"
)

View File

@@ -5,7 +5,7 @@ import (
"net/url"
"testing"
"github.com/unistack-org/micro/v3/api/resolver/vpath"
"go.unistack.org/micro/v3/api/resolver/vpath"
)
func TestResolve(t *testing.T) {

View File

@@ -1,5 +1,5 @@
// Package vpath resolves using http path and recognised versioned urls
package vpath
package vpath // import "go.unistack.org/micro/v3/api/resolver/vpath"
import (
"errors"
@@ -7,7 +7,7 @@ import (
"regexp"
"strings"
"github.com/unistack-org/micro/v3/api/resolver"
"go.unistack.org/micro/v3/api/resolver"
)
// NewResolver creates new vpath api resolver

View File

@@ -3,10 +3,10 @@ package router
import (
"context"
"github.com/unistack-org/micro/v3/api/resolver"
"github.com/unistack-org/micro/v3/api/resolver/vpath"
"github.com/unistack-org/micro/v3/logger"
"github.com/unistack-org/micro/v3/register"
"go.unistack.org/micro/v3/api/resolver"
"go.unistack.org/micro/v3/api/resolver/vpath"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/register"
)
// Options holds the options for api router

View File

@@ -1,10 +1,10 @@
// Package router provides api service routing
package router
package router // import "go.unistack.org/micro/v3/api/router"
import (
"net/http"
"github.com/unistack-org/micro/v3/api"
"go.unistack.org/micro/v3/api"
)
// DefaultRouter contains default router implementation

View File

@@ -1,12 +1,12 @@
// Package auth provides authentication and authorization capability
package auth
package auth // import "go.unistack.org/micro/v3/auth"
import (
"context"
"errors"
"time"
"github.com/unistack-org/micro/v3/metadata"
"go.unistack.org/micro/v3/metadata"
)
const (

View File

@@ -1,7 +1,7 @@
package auth
import (
"github.com/unistack-org/micro/v3/util/id"
"go.unistack.org/micro/v3/util/id"
)
type noopAuth struct {

View File

@@ -4,11 +4,11 @@ import (
"context"
"time"
"github.com/unistack-org/micro/v3/logger"
"github.com/unistack-org/micro/v3/metadata"
"github.com/unistack-org/micro/v3/meter"
"github.com/unistack-org/micro/v3/store"
"github.com/unistack-org/micro/v3/tracer"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/metadata"
"go.unistack.org/micro/v3/meter"
"go.unistack.org/micro/v3/store"
"go.unistack.org/micro/v3/tracer"
)
// NewOptions creates Options struct from slice of options

View File

@@ -1,11 +1,11 @@
// Package broker is an interface used for asynchronous messaging
package broker
package broker // import "go.unistack.org/micro/v3/broker"
import (
"context"
"errors"
"github.com/unistack-org/micro/v3/metadata"
"go.unistack.org/micro/v3/metadata"
)
// DefaultBroker default memory broker

View File

@@ -4,12 +4,12 @@ import (
"context"
"sync"
"github.com/unistack-org/micro/v3/logger"
"github.com/unistack-org/micro/v3/metadata"
maddr "github.com/unistack-org/micro/v3/util/addr"
"github.com/unistack-org/micro/v3/util/id"
mnet "github.com/unistack-org/micro/v3/util/net"
"github.com/unistack-org/micro/v3/util/rand"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/metadata"
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"
)
type memoryBroker struct {

View File

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

View File

@@ -5,11 +5,11 @@ import (
"crypto/tls"
"time"
"github.com/unistack-org/micro/v3/codec"
"github.com/unistack-org/micro/v3/logger"
"github.com/unistack-org/micro/v3/meter"
"github.com/unistack-org/micro/v3/register"
"github.com/unistack-org/micro/v3/tracer"
"go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/meter"
"go.unistack.org/micro/v3/register"
"go.unistack.org/micro/v3/tracer"
)
// Options struct

View File

@@ -1,5 +1,5 @@
// Package build is for building source into a package
package build
package build // import "go.unistack.org/micro/v3/build"
// Build is an interface for building packages
type Build interface {

View File

@@ -4,7 +4,7 @@ import (
"context"
"time"
"github.com/unistack-org/micro/v3/util/backoff"
"go.unistack.org/micro/v3/util/backoff"
)
// BackoffFunc is the backoff call func

View File

@@ -1,12 +1,12 @@
// Package client is an interface for an RPC client
package client
package client // import "go.unistack.org/micro/v3/client"
import (
"context"
"time"
"github.com/unistack-org/micro/v3/codec"
"github.com/unistack-org/micro/v3/metadata"
"go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v3/metadata"
)
var (
@@ -49,6 +49,7 @@ type Message interface {
Topic() string
Payload() interface{}
ContentType() string
Metadata() metadata.Metadata
}
// Request is the interface for a synchronous request used by Call or Stream

View File

@@ -4,15 +4,15 @@ import (
"context"
"sort"
"github.com/unistack-org/micro/v3/errors"
"github.com/unistack-org/micro/v3/router"
"go.unistack.org/micro/v3/errors"
"go.unistack.org/micro/v3/router"
)
// LookupFunc is used to lookup routes for a service
type LookupFunc func(context.Context, Request, CallOptions) ([]string, error)
// LookupRoute for a request using the router and then choose one using the selector
func LookupRoute(ctx context.Context, req Request, opts CallOptions) ([]string, error) {
func LookupRoute(_ context.Context, req Request, opts CallOptions) ([]string, error) {
// check to see if an address was provided as a call option
if len(opts.Address) > 0 {
return opts.Address, nil

View File

@@ -3,10 +3,10 @@ package client
import (
"context"
"github.com/unistack-org/micro/v3/broker"
"github.com/unistack-org/micro/v3/codec"
"github.com/unistack-org/micro/v3/errors"
"github.com/unistack-org/micro/v3/metadata"
"go.unistack.org/micro/v3/broker"
"go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v3/errors"
"go.unistack.org/micro/v3/metadata"
)
// DefaultCodecs will be used to encode/decode data
@@ -139,6 +139,10 @@ func (n *noopMessage) ContentType() string {
return n.opts.ContentType
}
func (n *noopMessage) Metadata() metadata.Metadata {
return n.opts.Metadata
}
func (n *noopClient) newCodec(contentType string) (codec.Codec, error) {
if cf, ok := n.opts.Codecs[contentType]; ok {
return cf, nil

View File

@@ -5,16 +5,17 @@ import (
"crypto/tls"
"time"
"github.com/unistack-org/micro/v3/broker"
"github.com/unistack-org/micro/v3/codec"
"github.com/unistack-org/micro/v3/logger"
"github.com/unistack-org/micro/v3/meter"
"github.com/unistack-org/micro/v3/network/transport"
"github.com/unistack-org/micro/v3/register"
"github.com/unistack-org/micro/v3/router"
"github.com/unistack-org/micro/v3/selector"
"github.com/unistack-org/micro/v3/selector/random"
"github.com/unistack-org/micro/v3/tracer"
"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/network/transport"
"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"
)
// Options holds client options
@@ -128,7 +129,7 @@ type PublishOptions struct {
// NewMessageOptions creates message options struct
func NewMessageOptions(opts ...MessageOption) MessageOptions {
options := MessageOptions{}
options := MessageOptions{Metadata: metadata.New(1)}
for _, o := range opts {
o(&options)
}
@@ -137,7 +138,10 @@ func NewMessageOptions(opts ...MessageOption) MessageOptions {
// MessageOptions holds client message options
type MessageOptions struct {
// Metadata additional metadata
Metadata metadata.Metadata
// ContentType specify content-type of message
// deprecated
ContentType string
}
@@ -517,6 +521,7 @@ func WithSelectOptions(sops ...selector.SelectOption) CallOption {
// Deprecated
func WithMessageContentType(ct string) MessageOption {
return func(o *MessageOptions) {
o.Metadata.Set(metadata.HeaderContentType, ct)
o.ContentType = ct
}
}
@@ -524,10 +529,18 @@ func WithMessageContentType(ct string) MessageOption {
// MessageContentType sets the message content type
func MessageContentType(ct string) MessageOption {
return func(o *MessageOptions) {
o.Metadata.Set(metadata.HeaderContentType, ct)
o.ContentType = ct
}
}
// MessageMetadata sets the message metadata
func MessageMetadata(k, v string) MessageOption {
return func(o *MessageOptions) {
o.Metadata.Set(k, v)
}
}
// StreamingRequest specifies that request is streaming
func StreamingRequest(b bool) RequestOption {
return func(o *RequestOptions) {

View File

@@ -3,7 +3,7 @@ package client
import (
"context"
"github.com/unistack-org/micro/v3/errors"
"go.unistack.org/micro/v3/errors"
)
// RetryFunc that returning either false or a non-nil error will result in the call not being retried
@@ -20,7 +20,7 @@ func RetryNever(ctx context.Context, req Request, retryCount int, err error) (bo
}
// RetryOnError retries a request on a 500 or timeout error
func RetryOnError(ctx context.Context, req Request, retryCount int, err error) (bool, error) {
func RetryOnError(_ context.Context, _ Request, _ int, err error) (bool, error) {
if err == nil {
return false, nil
}

View File

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

View File

@@ -1,11 +1,11 @@
// Package codec is an interface for encoding messages
package codec
package codec // import "go.unistack.org/micro/v3/codec"
import (
"errors"
"io"
"github.com/unistack-org/micro/v3/metadata"
"go.unistack.org/micro/v3/metadata"
)
// Message types
@@ -67,3 +67,20 @@ type Message struct {
func NewMessage(t MessageType) *Message {
return &Message{Type: t, Header: metadata.New(0)}
}
// MarshalAppend calls codec.Marshal(v) and returns the data appended to buf.
// If codec implements MarshalAppend, that is called instead.
func MarshalAppend(buf []byte, c Codec, v interface{}, opts ...Option) ([]byte, error) {
if nc, ok := c.(interface {
MarshalAppend([]byte, interface{}, ...Option) ([]byte, error)
}); ok {
return nc.MarshalAppend(buf, v, opts...)
}
mbuf, err := c.Marshal(v, opts...)
if err != nil {
return nil, err
}
return append(buf, mbuf...), nil
}

View File

@@ -5,29 +5,40 @@ type Frame struct {
Data []byte
}
// NewFrame returns new frame with data
func NewFrame(data []byte) *Frame {
return &Frame{Data: data}
}
// MarshalJSON returns frame data
func (m *Frame) MarshalJSON() ([]byte, error) {
return m.Data, nil
return m.Marshal()
}
// UnmarshalJSON set frame data
func (m *Frame) UnmarshalJSON(data []byte) error {
m.Data = data
return nil
return m.Unmarshal(data)
}
// ProtoMessage noop func
func (m *Frame) ProtoMessage() {}
// Reset resets frame
func (m *Frame) Reset() {
*m = Frame{}
}
// String returns frame as string
func (m *Frame) String() string {
return string(m.Data)
}
// Marshal returns frame data
func (m *Frame) Marshal() ([]byte, error) {
return m.Data, nil
}
// Unmarshal set frame data
func (m *Frame) Unmarshal(data []byte) error {
m.Data = data
return nil

View File

@@ -17,7 +17,7 @@ syntax = "proto3";
package micro.codec;
option cc_enable_arenas = true;
option go_package = "github.com/unistack-org/micro/v3/codec;codec";
option go_package = "go.unistack.org/micro/v3/codec;codec";
option java_multiple_files = true;
option java_outer_classname = "MicroCodec";
option java_package = "micro.codec";

View File

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

View File

@@ -1,5 +1,5 @@
// Package config is an interface for dynamic configuration.
package config
package config // import "go.unistack.org/micro/v3/config"
import (
"context"
@@ -23,6 +23,8 @@ var (
ErrInvalidStruct = errors.New("invalid struct specified")
// ErrWatcherStopped is returned when source watcher has been stopped
ErrWatcherStopped = errors.New("watcher stopped")
// ErrWatcherNotImplemented returned when config does not implement watch
ErrWatcherNotImplemented = errors.New("watcher not implemented")
)
// Config is an interface abstraction for dynamic configuration

View File

@@ -32,3 +32,33 @@ func SetOption(k, v interface{}) Option {
o.Context = context.WithValue(o.Context, k, v)
}
}
// SetSaveOption returns a function to setup a context with given value
func SetSaveOption(k, v interface{}) SaveOption {
return func(o *SaveOptions) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, k, v)
}
}
// SetLoadOption returns a function to setup a context with given value
func SetLoadOption(k, v interface{}) LoadOption {
return func(o *LoadOptions) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, k, v)
}
}
// SetWatchOption returns a function to setup a context with given value
func SetWatchOption(k, v interface{}) WatchOption {
return func(o *WatchOptions) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, k, v)
}
}

View File

@@ -2,13 +2,12 @@ package config
import (
"context"
"fmt"
"reflect"
"strconv"
"strings"
"github.com/imdario/mergo"
rutil "github.com/unistack-org/micro/v3/util/reflect"
rutil "go.unistack.org/micro/v3/util/reflect"
)
type defaultConfig struct {
@@ -271,7 +270,7 @@ func (c *defaultConfig) Name() string {
}
func (c *defaultConfig) Watch(ctx context.Context, opts ...WatchOption) (Watcher, error) {
return nil, fmt.Errorf("not implemented")
return nil, ErrWatcherNotImplemented
}
// NewConfig returns new default config source

View File

@@ -5,7 +5,7 @@ import (
"fmt"
"testing"
"github.com/unistack-org/micro/v3/config"
"go.unistack.org/micro/v3/config"
)
type Cfg struct {

View File

@@ -4,10 +4,10 @@ import (
"context"
"time"
"github.com/unistack-org/micro/v3/codec"
"github.com/unistack-org/micro/v3/logger"
"github.com/unistack-org/micro/v3/meter"
"github.com/unistack-org/micro/v3/tracer"
"go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/meter"
"go.unistack.org/micro/v3/tracer"
)
// Options hold the config options
@@ -66,6 +66,7 @@ type LoadOptions struct {
Struct interface{}
Override bool
Append bool
Context context.Context
}
func NewLoadOptions(opts ...LoadOption) LoadOptions {
@@ -102,7 +103,8 @@ type SaveOption func(o *SaveOptions)
// SaveOptions struct
type SaveOptions struct {
Struct interface{}
Struct interface{}
Context context.Context
}
// SaveStruct override struct for save to config

View File

@@ -1,6 +1,6 @@
// Package errors provides a way to return detailed information
// for an RPC request error. The error is normally JSON encoded.
package errors
package errors // import "go.unistack.org/micro/v3/errors"
import (
"encoding/json"
@@ -53,6 +53,22 @@ func (e *Error) Error() string {
return string(b)
}
/*
// Generator struct holds id of error
type Generator struct {
id string
}
// Generator can emit new error with static id
func NewGenerator(id string) *Generator {
return &Generator{id: id}
}
func (g *Generator) BadRequest(format string, args ...interface{}) error {
return BadRequest(g.id, format, args...)
}
*/
// New generates a custom error
func New(id, detail string, code int32) error {
return &Error{
@@ -75,121 +91,121 @@ func Parse(err string) *Error {
}
// BadRequest generates a 400 error.
func BadRequest(id, format string, a ...interface{}) error {
func BadRequest(id, format string, args ...interface{}) error {
return &Error{
ID: id,
Code: 400,
Detail: fmt.Sprintf(format, a...),
Detail: fmt.Sprintf(format, args...),
Status: http.StatusText(400),
}
}
// Unauthorized generates a 401 error.
func Unauthorized(id, format string, a ...interface{}) error {
func Unauthorized(id, format string, args ...interface{}) error {
return &Error{
ID: id,
Code: 401,
Detail: fmt.Sprintf(format, a...),
Detail: fmt.Sprintf(format, args...),
Status: http.StatusText(401),
}
}
// Forbidden generates a 403 error.
func Forbidden(id, format string, a ...interface{}) error {
func Forbidden(id, format string, args ...interface{}) error {
return &Error{
ID: id,
Code: 403,
Detail: fmt.Sprintf(format, a...),
Detail: fmt.Sprintf(format, args...),
Status: http.StatusText(403),
}
}
// NotFound generates a 404 error.
func NotFound(id, format string, a ...interface{}) error {
func NotFound(id, format string, args ...interface{}) error {
return &Error{
ID: id,
Code: 404,
Detail: fmt.Sprintf(format, a...),
Detail: fmt.Sprintf(format, args...),
Status: http.StatusText(404),
}
}
// MethodNotAllowed generates a 405 error.
func MethodNotAllowed(id, format string, a ...interface{}) error {
func MethodNotAllowed(id, format string, args ...interface{}) error {
return &Error{
ID: id,
Code: 405,
Detail: fmt.Sprintf(format, a...),
Detail: fmt.Sprintf(format, args...),
Status: http.StatusText(405),
}
}
// Timeout generates a 408 error.
func Timeout(id, format string, a ...interface{}) error {
func Timeout(id, format string, args ...interface{}) error {
return &Error{
ID: id,
Code: 408,
Detail: fmt.Sprintf(format, a...),
Detail: fmt.Sprintf(format, args...),
Status: http.StatusText(408),
}
}
// Conflict generates a 409 error.
func Conflict(id, format string, a ...interface{}) error {
func Conflict(id, format string, args ...interface{}) error {
return &Error{
ID: id,
Code: 409,
Detail: fmt.Sprintf(format, a...),
Detail: fmt.Sprintf(format, args...),
Status: http.StatusText(409),
}
}
// InternalServerError generates a 500 error.
func InternalServerError(id, format string, a ...interface{}) error {
func InternalServerError(id, format string, args ...interface{}) error {
return &Error{
ID: id,
Code: 500,
Detail: fmt.Sprintf(format, a...),
Detail: fmt.Sprintf(format, args...),
Status: http.StatusText(500),
}
}
// NotImplemented generates a 501 error
func NotImplemented(id, format string, a ...interface{}) error {
func NotImplemented(id, format string, args ...interface{}) error {
return &Error{
ID: id,
Code: 501,
Detail: fmt.Sprintf(format, a...),
Detail: fmt.Sprintf(format, args...),
Status: http.StatusText(501),
}
}
// BadGateway generates a 502 error
func BadGateway(id, format string, a ...interface{}) error {
func BadGateway(id, format string, args ...interface{}) error {
return &Error{
ID: id,
Code: 502,
Detail: fmt.Sprintf(format, a...),
Detail: fmt.Sprintf(format, args...),
Status: http.StatusText(502),
}
}
// ServiceUnavailable generates a 503 error
func ServiceUnavailable(id, format string, a ...interface{}) error {
func ServiceUnavailable(id, format string, args ...interface{}) error {
return &Error{
ID: id,
Code: 503,
Detail: fmt.Sprintf(format, a...),
Detail: fmt.Sprintf(format, args...),
Status: http.StatusText(503),
}
}
// GatewayTimeout generates a 504 error
func GatewayTimeout(id, format string, a ...interface{}) error {
func GatewayTimeout(id, format string, args ...interface{}) error {
return &Error{
ID: id,
Code: 504,
Detail: fmt.Sprintf(format, a...),
Detail: fmt.Sprintf(format, args...),
Status: http.StatusText(504),
}
}

View File

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

View File

@@ -7,12 +7,12 @@ import (
"sync"
"github.com/silas/dag"
"github.com/unistack-org/micro/v3/client"
"github.com/unistack-org/micro/v3/codec"
"github.com/unistack-org/micro/v3/logger"
"github.com/unistack-org/micro/v3/metadata"
"github.com/unistack-org/micro/v3/store"
"github.com/unistack-org/micro/v3/util/id"
"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"
)
type microFlow struct {

View File

@@ -1,5 +1,5 @@
// Package flow is an interface used for saga pattern microservice workflow
package flow
package flow // import "go.unistack.org/micro/v3/flow"
import (
"context"
@@ -7,7 +7,7 @@ import (
"sync"
"sync/atomic"
"github.com/unistack-org/micro/v3/metadata"
"go.unistack.org/micro/v3/metadata"
)
var (

View File

@@ -4,11 +4,11 @@ import (
"context"
"time"
"github.com/unistack-org/micro/v3/client"
"github.com/unistack-org/micro/v3/logger"
"github.com/unistack-org/micro/v3/meter"
"github.com/unistack-org/micro/v3/store"
"github.com/unistack-org/micro/v3/tracer"
"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"
)
// Option func

View File

@@ -6,7 +6,7 @@ import (
"context"
"time"
"github.com/unistack-org/micro/v3/server"
"go.unistack.org/micro/v3/server"
)
// Function is a one time executing Service

View File

@@ -8,7 +8,7 @@ import (
"sync"
"testing"
"github.com/unistack-org/micro/v3/register"
"go.unistack.org/micro/v3/register"
)
func TestFunction(t *testing.T) {

6
go.mod
View File

@@ -1,14 +1,14 @@
module github.com/unistack-org/micro/v3
module go.unistack.org/micro/v3
go 1.16
require (
github.com/ef-ds/deque v1.0.4
github.com/golang-jwt/jwt/v4 v4.1.0
github.com/golang-jwt/jwt/v4 v4.2.0
github.com/imdario/mergo v0.3.12
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/silas/dag v0.0.0-20210626123444-3804bac2d6d4
github.com/unistack-org/micro-proto v0.0.9
go.unistack.org/micro-proto/v3 v3.1.0
golang.org/x/net v0.0.0-20210928044308-7d9f5e0b762b
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
)

14
go.sum
View File

@@ -1,9 +1,7 @@
github.com/ef-ds/deque v1.0.4 h1:iFAZNmveMT9WERAkqLJ+oaABF9AcVQ5AjXem/hroniI=
github.com/ef-ds/deque v1.0.4/go.mod h1:gXDnTC3yqvBcHbq2lcExjtAcVrOnJCbMcZXmuj8Z4tg=
github.com/golang-jwt/jwt/v4 v4.0.0 h1:RAqyYixv1p7uEnocuy8P1nru5wprCh/MH2BIlW5z5/o=
github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg=
github.com/golang-jwt/jwt/v4 v4.1.0 h1:XUgk2Ex5veyVFVeLm0xhusUTQybEbexJXrvPNOKkSY0=
github.com/golang-jwt/jwt/v4 v4.1.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg=
github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU=
github.com/golang-jwt/jwt/v4 v4.2.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
@@ -11,14 +9,10 @@ github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
github.com/silas/dag v0.0.0-20210121180416-41cf55125c34 h1:vBfVmA5mZhsQa2jr1FOL9nfA37N/jnbBmi5XUfviVTI=
github.com/silas/dag v0.0.0-20210121180416-41cf55125c34/go.mod h1:7RTUFBdIRC9nZ7/3RyRNH1bdqIShrDejd1YbLwgPS+I=
github.com/silas/dag v0.0.0-20210626123444-3804bac2d6d4 h1:fOH64AB0C3ixGf9emky61STvPJL3smxJg+1Zwx1oCdg=
github.com/silas/dag v0.0.0-20210626123444-3804bac2d6d4/go.mod h1:7RTUFBdIRC9nZ7/3RyRNH1bdqIShrDejd1YbLwgPS+I=
github.com/unistack-org/micro-proto v0.0.9 h1:KrWLS4FUX7UAWNAilQf70uad6ZPf/0EudeddCXllRVc=
github.com/unistack-org/micro-proto v0.0.9/go.mod h1:Cckwmzd89gvS7ThxzZp9kQR/EOdksFQcsTAtDDyKwrg=
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d h1:20cMwl2fHAzkJMEA+8J4JgqBQcQGzbisXo31MIeenXI=
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
go.unistack.org/micro-proto/v3 v3.1.0 h1:q39FwjFiRZn+Ux/tt+d3bJTmDtsQQWa+3SLYVo1vLfA=
go.unistack.org/micro-proto/v3 v3.1.0/go.mod h1:DpRhYCBXlmSJ/AAXTmntvlh7kQkYU6eFvlmYAx4BQS8=
golang.org/x/net v0.0.0-20210928044308-7d9f5e0b762b h1:eB48h3HiRycXNy8E0Gf5e0hv7YT6Kt14L/D73G1fuwo=
golang.org/x/net v0.0.0-20210928044308-7d9f5e0b762b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

View File

@@ -1,5 +1,5 @@
// Package logger provides a log interface
package logger
package logger // import "go.unistack.org/micro/v3/logger"
import (
"context"

View File

@@ -1,10 +1,10 @@
package logger
package logger // import "go.unistack.org/micro/v3/logger/wrapper"
import (
"context"
"reflect"
rutil "github.com/unistack-org/micro/v3/util/reflect"
rutil "go.unistack.org/micro/v3/util/reflect"
)
// LogFunc function used for Log method

View File

@@ -5,9 +5,9 @@ import (
"context"
"fmt"
"github.com/unistack-org/micro/v3/client"
"github.com/unistack-org/micro/v3/logger"
"github.com/unistack-org/micro/v3/server"
"go.unistack.org/micro/v3/client"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/server"
)
var (

View File

@@ -1,5 +1,5 @@
// Package metadata is a way of defining message headers
package metadata
package metadata // import "go.unistack.org/micro/v3/metadata"
import (
"net/textproto"

View File

@@ -1,12 +1,12 @@
package meter
//go:generate sh -c "protoc -I./handler -I../ -I$(go list -f '{{ .Dir }}' -m github.com/unistack-org/micro-proto) --go-micro_out='components=micro|http|server',standalone=false,debug=true,paths=source_relative:./handler handler/handler.proto"
//go:generate sh -c "protoc -I./handler -I../ -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go-micro_out='components=micro|http|server',standalone=false,debug=true,paths=source_relative:./handler handler/handler.proto"
import (
// import required packages
_ "github.com/unistack-org/micro-proto/api"
_ "go.unistack.org/micro-proto/v3/api"
// import required packages
_ "github.com/unistack-org/micro-proto/openapiv2"
_ "go.unistack.org/micro-proto/v3/openapiv3"
)

View File

@@ -1,12 +1,12 @@
package handler
package handler // import "go.unistack.org/micro/v3/meter/handler"
import (
"bytes"
"context"
"github.com/unistack-org/micro/v3/codec"
"github.com/unistack-org/micro/v3/errors"
"github.com/unistack-org/micro/v3/meter"
"go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v3/errors"
"go.unistack.org/micro/v3/meter"
)
// guard to fail early

View File

@@ -1,24 +1,20 @@
syntax = "proto3";
package micro.meter.handler;
option go_package = "github.com/unistack-org/micro/v3/meter/handler;handler";
option go_package = "go.unistack.org/micro/v3/meter/handler;handler";
import "api/annotations.proto";
import "openapiv2/annotations.proto";
import "openapiv3/annotations.proto";
import "codec/frame.proto";
service Meter {
rpc Metrics(micro.codec.Frame) returns (micro.codec.Frame) {
option (micro.openapiv2.openapiv2_operation) = {
option (micro.openapiv3.openapiv3_operation) = {
operation_id: "Metrics";
responses: {
response_code: {
name: "default";
value: {
json_reference: {
description: "Error response";
_ref: "micro.codec.Frame";
};
default: {
reference: {
_ref: "micro.codec.Frame";
};
};
};

View File

@@ -1,14 +1,13 @@
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
// protoc-gen-go-micro version: v3.4.2
// protoc-gen-go-micro version: v3.5.2
// source: handler.proto
package handler
import (
context "context"
api "github.com/unistack-org/micro/v3/api"
codec "github.com/unistack-org/micro/v3/codec"
api "go.unistack.org/micro/v3/api"
codec "go.unistack.org/micro/v3/codec"
)
var (

View File

@@ -1,15 +1,14 @@
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
// protoc-gen-go-micro version: v3.4.2
// protoc-gen-go-micro version: v3.5.2
// source: handler.proto
package handler
import (
context "context"
api "github.com/unistack-org/micro/v3/api"
codec "github.com/unistack-org/micro/v3/codec"
server "github.com/unistack-org/micro/v3/server"
api "go.unistack.org/micro/v3/api"
codec "go.unistack.org/micro/v3/codec"
server "go.unistack.org/micro/v3/server"
)
type meterServer struct {

View File

@@ -1,5 +1,5 @@
// Package meter is for instrumentation
package meter
package meter // import "go.unistack.org/micro/v3/meter"
import (
"io"
@@ -28,17 +28,31 @@ var (
// Meter is an interface for collecting and instrumenting metrics
type Meter interface {
// Name returns meter name
Name() string
// Init initialize meter
Init(opts ...Option) error
// Clone create meter copy with new options
Clone(opts ...Option) Meter
// Counter get or create counter
Counter(name string, labels ...string) Counter
// FloatCounter get or create float counter
FloatCounter(name string, labels ...string) FloatCounter
// Gauge get or create gauge
Gauge(name string, fn func() float64, labels ...string) Gauge
// Set create new meter metrics set
Set(opts ...Option) Meter
// Histogram get or create histogram
Histogram(name string, labels ...string) Histogram
// Summary get or create summary
Summary(name string, labels ...string) Summary
// SummaryExt get or create summary with spcified quantiles and window time
SummaryExt(name string, window time.Duration, quantiles []float64, labels ...string) Summary
// Write writes metrics to io.Writer
Write(w io.Writer, opts ...Option) error
// Options returns meter options
Options() Options
// String return meter type
String() string
}

View File

@@ -15,6 +15,15 @@ func NewMeter(opts ...Option) Meter {
return &noopMeter{opts: NewOptions(opts...)}
}
// Clone return old meter with new options
func (r *noopMeter) Clone(opts ...Option) Meter {
options := r.opts
for _, o := range opts {
o(&options)
}
return &noopMeter{opts: options}
}
func (r *noopMeter) Name() string {
return r.opts.Name
}

View File

@@ -3,7 +3,7 @@ package meter
import (
"context"
"github.com/unistack-org/micro/v3/logger"
"go.unistack.org/micro/v3/logger"
)
// Option powers the configuration for metrics implementations:
@@ -51,6 +51,20 @@ func NewOptions(opt ...Option) Options {
return opts
}
// LabelPrefix sets the labels prefix
func LabelPrefix(pref string) Option {
return func(o *Options) {
o.LabelPrefix = pref
}
}
// MetricPrefix sets the metric prefix
func MetricPrefix(pref string) Option {
return func(o *Options) {
o.MetricPrefix = pref
}
}
// Context sets the metrics context
func Context(ctx context.Context) Option {
return func(o *Options) {

View File

@@ -1,13 +1,13 @@
package wrapper
package wrapper // import "go.unistack.org/micro/v3/meter/wrapper"
import (
"context"
"fmt"
"time"
"github.com/unistack-org/micro/v3/client"
"github.com/unistack-org/micro/v3/meter"
"github.com/unistack-org/micro/v3/server"
"go.unistack.org/micro/v3/client"
"go.unistack.org/micro/v3/meter"
"go.unistack.org/micro/v3/server"
)
var (

1
micro.go Normal file
View File

@@ -0,0 +1 @@
package micro // import "go.unistack.org/micro/v3"

View File

@@ -1,35 +0,0 @@
// +build ignore
// Package model is an interface for data modelling
package model
// Model provides an interface for data modelling
type Model interface {
// Initialise options
Init(...Option) error
// NewEntity creates a new entity to store or access
NewEntity(name string, value interface{}) Entity
// Create a value
Create(Entity) error
// Read values
Read(...ReadOption) ([]Entity, error)
// Update the value
Update(Entity) error
// Delete an entity
Delete(...DeleteOption) error
// Implementation of the model
String() string
}
type Entity interface {
// Unique id of the entity
Id() string
// Name of the entity
Name() string
// The value associated with the entity
Value() interface{}
// Attributes of the entity
Attributes() map[string]interface{}
// Read a value as a concrete type
Read(v interface{}) error
}

View File

@@ -1,41 +0,0 @@
// +build ignore
// Package model is an interface for data modelling
package model
import (
"github.com/unistack-org/micro/v3/codec"
"github.com/unistack-org/micro/v3/logger"
"github.com/unistack-org/micro/v3/store"
"github.com/unistack-org/micro/v3/sync"
)
type Options struct {
// Database to write to
Database string
// for serialising
Codec codec.Codec
// for locking
Sync sync.Sync
// for storage
Store store.Store
// for logger
Logger logger.Logger
}
type Option func(o *Options)
// Logger sets the logger
func Logger(l logger.Logger) Option {
return func(o *Options) {
o.Logger = l
}
}
type ReadOptions struct{}
type ReadOption func(o *ReadOptions)
type DeleteOptions struct{}
type DeleteOption func(o *DeleteOptions)

View File

@@ -1,9 +1,9 @@
// Package network is for creating internetworks
package network
package network // import "go.unistack.org/micro/v3/network"
import (
"github.com/unistack-org/micro/v3/client"
"github.com/unistack-org/micro/v3/server"
"go.unistack.org/micro/v3/client"
"go.unistack.org/micro/v3/server"
)
// Error is network node errors

View File

@@ -1,13 +1,13 @@
package network
import (
"github.com/unistack-org/micro/v3/logger"
"github.com/unistack-org/micro/v3/meter"
"github.com/unistack-org/micro/v3/network/tunnel"
"github.com/unistack-org/micro/v3/proxy"
"github.com/unistack-org/micro/v3/router"
"github.com/unistack-org/micro/v3/tracer"
"github.com/unistack-org/micro/v3/util/id"
"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"
)
// Option func

View File

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

View File

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

View File

@@ -1,11 +1,11 @@
// Package transport is an interface for synchronous connection based communication
package transport
package transport // import "go.unistack.org/micro/v3/network/transport"
import (
"context"
"time"
"github.com/unistack-org/micro/v3/metadata"
"go.unistack.org/micro/v3/metadata"
)
var (

View File

@@ -1,15 +1,15 @@
// Package broker is a tunnel broker
package broker
package broker // import "go.unistack.org/micro/v3/network/tunnel/broker"
import (
"context"
"fmt"
"github.com/unistack-org/micro/v3/broker"
"github.com/unistack-org/micro/v3/logger"
"github.com/unistack-org/micro/v3/metadata"
"github.com/unistack-org/micro/v3/network/transport"
"github.com/unistack-org/micro/v3/network/tunnel"
"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"
)
type tunBroker struct {

View File

@@ -3,11 +3,11 @@ package tunnel
import (
"time"
"github.com/unistack-org/micro/v3/logger"
"github.com/unistack-org/micro/v3/meter"
"github.com/unistack-org/micro/v3/network/transport"
"github.com/unistack-org/micro/v3/tracer"
"github.com/unistack-org/micro/v3/util/id"
"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"
)
var (

View File

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

View File

@@ -1,12 +1,12 @@
// Package transport provides a tunnel transport
package transport
package transport // import "go.unistack.org/micro/v3/network/tunnel/transport"
import (
"context"
"fmt"
"github.com/unistack-org/micro/v3/network/transport"
"github.com/unistack-org/micro/v3/network/tunnel"
"go.unistack.org/micro/v3/network/transport"
"go.unistack.org/micro/v3/network/tunnel"
)
type tunTransport struct {

View File

@@ -1,12 +1,12 @@
// Package tunnel provides gre network tunnelling
package tunnel
package tunnel // import "go.unistack.org/micro/v3/network/transport/tunnel"
import (
"context"
"errors"
"time"
"github.com/unistack-org/micro/v3/network/transport"
"go.unistack.org/micro/v3/network/transport"
)
// DefaultTunnel contains default tunnel implementation

View File

@@ -5,18 +5,18 @@ import (
"fmt"
"time"
"github.com/unistack-org/micro/v3/auth"
"github.com/unistack-org/micro/v3/broker"
"github.com/unistack-org/micro/v3/client"
"github.com/unistack-org/micro/v3/config"
"github.com/unistack-org/micro/v3/logger"
"github.com/unistack-org/micro/v3/metadata"
"github.com/unistack-org/micro/v3/meter"
"github.com/unistack-org/micro/v3/register"
"github.com/unistack-org/micro/v3/router"
"github.com/unistack-org/micro/v3/server"
"github.com/unistack-org/micro/v3/store"
"github.com/unistack-org/micro/v3/tracer"
"go.unistack.org/micro/v3/auth"
"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"
)
// Options for micro service

View File

@@ -1,5 +1,5 @@
// Package http enables the http profiler
package http
package http // import "go.unistack.org/micro/v3/profiler/http"
import (
"context"
@@ -7,7 +7,7 @@ import (
"net/http/pprof"
"sync"
profile "github.com/unistack-org/micro/v3/profiler"
profile "go.unistack.org/micro/v3/profiler"
)
type httpProfile struct {

View File

@@ -1,5 +1,5 @@
// Package pprof provides a pprof profiler which writes output to /tmp/[name].{cpu,mem}.pprof
package pprof
package pprof // import "go.unistack.org/micro/v3/profiler/pprof"
import (
"os"
@@ -9,7 +9,7 @@ import (
"sync"
"time"
profile "github.com/unistack-org/micro/v3/profiler"
profile "go.unistack.org/micro/v3/profiler"
)
type profiler struct {

View File

@@ -1,5 +1,5 @@
// Package profiler is for profilers
package profiler
package profiler // import "go.unistack.org/micro/v3/profiler"
// Profiler interface
type Profiler interface {

View File

@@ -2,11 +2,11 @@
package proxy
import (
"github.com/unistack-org/micro/v3/client"
"github.com/unistack-org/micro/v3/logger"
"github.com/unistack-org/micro/v3/meter"
"github.com/unistack-org/micro/v3/router"
"github.com/unistack-org/micro/v3/tracer"
"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"
)
// Options for proxy

View File

@@ -1,10 +1,10 @@
// Package proxy is a transparent proxy built on the micro/server
package proxy
package proxy // import "go.unistack.org/micro/v3/proxy"
import (
"context"
"github.com/unistack-org/micro/v3/server"
"go.unistack.org/micro/v3/server"
)
// DefaultEndpoint holds default proxy address

View File

@@ -6,7 +6,7 @@ import (
"unicode"
"unicode/utf8"
"github.com/unistack-org/micro/v3/metadata"
"go.unistack.org/micro/v3/metadata"
)
// ExtractValue from reflect.Type from specified depth

View File

@@ -51,6 +51,4 @@ func TestExtractEndpoint(t *testing.T) {
if endpoints[0].Response != "TestResponse" {
t.Fatalf("Expected TestResponse got %s", endpoints[0].Response)
}
t.Logf("XXX %#+v\n", endpoints[0])
}

View File

@@ -6,8 +6,8 @@ import (
"sync"
"time"
"github.com/unistack-org/micro/v3/logger"
"github.com/unistack-org/micro/v3/util/id"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/util/id"
)
var (

View File

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

View File

@@ -1,11 +1,11 @@
// Package register is an interface for service discovery
package register
package register // import "go.unistack.org/micro/v3/register"
import (
"context"
"errors"
"github.com/unistack-org/micro/v3/metadata"
"go.unistack.org/micro/v3/metadata"
)
const (

View File

@@ -1,5 +1,5 @@
// Package dns resolves names to dns records
package dns
package dns // import "go.unistack.org/micro/v3/resolver/dns"
import (
"context"
@@ -7,7 +7,7 @@ import (
"sync"
"time"
"github.com/unistack-org/micro/v3/resolver"
"go.unistack.org/micro/v3/resolver"
)
// Resolver is a DNS network resolve

View File

@@ -1,11 +1,11 @@
// Package dnssrv resolves names to dns srv records
package dnssrv
package dnssrv // import "go.unistack.org/micro/v3/resolver/dnssrv"
import (
"fmt"
"net"
"github.com/unistack-org/micro/v3/resolver"
"go.unistack.org/micro/v3/resolver"
)
// Resolver is a DNS network resolve

View File

@@ -1,5 +1,5 @@
// Package http resolves names to network addresses using a http request
package http
package http // import "go.unistack.org/micro/v3/resolver/http"
import (
"encoding/json"
@@ -8,7 +8,7 @@ import (
"net/http"
"net/url"
"github.com/unistack-org/micro/v3/resolver"
"go.unistack.org/micro/v3/resolver"
)
// nolint: golint,revive

View File

@@ -1,8 +1,8 @@
// Package noop is a noop resolver
package noop
package noop // import "go.unistack.org/micro/v3/resolver/noop"
import (
"github.com/unistack-org/micro/v3/resolver"
"go.unistack.org/micro/v3/resolver"
)
// Resolver contains noop resolver

View File

@@ -1,11 +1,11 @@
// Package register resolves names using the micro register
package register
package register // import "go.unistack.org/micro/v3/resolver/registry"
import (
"context"
"github.com/unistack-org/micro/v3/register"
"github.com/unistack-org/micro/v3/resolver"
"go.unistack.org/micro/v3/register"
"go.unistack.org/micro/v3/resolver"
)
// Resolver is a register network resolver

View File

@@ -1,5 +1,5 @@
// Package resolver resolves network names to addresses
package resolver
package resolver // import "go.unistack.org/micro/v3/resolver"
// Resolver is network resolver. It's used to find network nodes
// via the name to connect to. This is done based on Network.Name().

View File

@@ -1,8 +1,8 @@
// Package static is a static resolver
package static
package static // import "go.unistack.org/micro/v3/resolver/static"
import (
"github.com/unistack-org/micro/v3/resolver"
"go.unistack.org/micro/v3/resolver"
)
// Resolver returns a static list of nodes. In the event the node list

View File

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

View File

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

View File

@@ -1,5 +1,5 @@
// Package router provides a network routing control plane
package router
package router // import "go.unistack.org/micro/v3/router"
import (
"errors"

View File

@@ -4,8 +4,8 @@ import (
"context"
"io"
"github.com/unistack-org/micro/v3/client"
"github.com/unistack-org/micro/v3/logger"
"go.unistack.org/micro/v3/client"
"go.unistack.org/micro/v3/logger"
)
// Options configure runtime

View File

@@ -1,11 +1,11 @@
// Package runtime is a service runtime manager
package runtime
package runtime // import "go.unistack.org/micro/v3/runtime"
import (
"errors"
"time"
"github.com/unistack-org/micro/v3/metadata"
"go.unistack.org/micro/v3/metadata"
)
// ErrAlreadyExists error

View File

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

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