Skip to content

Commit

Permalink
switch to stdlib context
Browse files Browse the repository at this point in the history
  • Loading branch information
Asim Aslam committed Mar 3, 2018
1 parent 982e606 commit c9b40cb
Show file tree
Hide file tree
Showing 42 changed files with 53 additions and 102 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ It does the following:
package main

import (
"context"
"fmt"

micro "github.com/micro/go-micro"
proto "github.com/micro/examples/service/proto"
"golang.org/x/net/context"
)

type Greeter struct{}
Expand Down Expand Up @@ -180,11 +180,11 @@ The generated proto includes a greeter client to reduce boilerplate code.
package main

import (
"context"
"fmt"

micro "github.com/micro/go-micro"
proto "github.com/micro/examples/service/proto"
"golang.org/x/net/context"
)


Expand Down Expand Up @@ -230,9 +230,10 @@ A Function is a one time executing Service which exits after completing a reques
package main

import (
"context"

proto "github.com/micro/examples/function/proto"
"github.com/micro/go-micro"
"golang.org/x/net/context"
)

type Greeter struct{}
Expand Down
3 changes: 1 addition & 2 deletions broker/http_broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package broker

import (
"bytes"
"context"
"crypto/tls"
"errors"
"fmt"
Expand All @@ -26,8 +27,6 @@ import (
mnet "github.com/micro/misc/lib/net"
mls "github.com/micro/misc/lib/tls"
"github.com/pborman/uuid"

"golang.org/x/net/context"
)

// HTTP Broker is a point to point async broker
Expand Down
2 changes: 1 addition & 1 deletion broker/options.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package broker

import (
"context"
"crypto/tls"

"github.com/micro/go-micro/broker/codec"
"github.com/micro/go-micro/registry"
"golang.org/x/net/context"
)

type Options struct {
Expand Down
3 changes: 1 addition & 2 deletions client/backoff.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package client

import (
"context"
"math"
"time"

"golang.org/x/net/context"
)

type BackoffFunc func(ctx context.Context, req Request, attempts int) (time.Duration, error)
Expand Down
3 changes: 1 addition & 2 deletions client/backoff_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package client

import (
"context"
"math"
"testing"
"time"

"golang.org/x/net/context"
)

func TestBackoff(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
package client

import (
"context"
"time"

"golang.org/x/net/context"
)

// Client is the interface used to make requests to services.
Expand Down
36 changes: 1 addition & 35 deletions client/client_wrapper.go
Original file line number Diff line number Diff line change
@@ -1,41 +1,7 @@
package client

/*
Wrapper is a type of middleware for the go-micro client. It allows
the client to be "wrapped" so that requests and responses can be intercepted
to perform extra requirements such as auth, tracing, monitoring, logging, etc.
Example usage:
import (
"log"
"github.com/micro/go-micro/client"
)
type LogWrapper struct {
client.Client
}
func (l *LogWrapper) Call(ctx context.Context, req client.Request, rsp interface{}, opts ...client.CallOption) error {
log.Println("Making request to service " + req.Service() + " method " + req.Method())
return w.Client.Call(ctx, req, rsp)
}
func Wrapper(c client.Client) client.Client {
return &LogWrapper{c}
}
func main() {
c := client.NewClient(client.Wrap(Wrapper))
}
*/

import (
"golang.org/x/net/context"
"context"
)

// CallFunc represents the individual call func
Expand Down
2 changes: 1 addition & 1 deletion client/context.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package client

import (
"golang.org/x/net/context"
"context"
)

type clientKey struct{}
Expand Down
2 changes: 1 addition & 1 deletion client/mock/context.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package mock

import (
"golang.org/x/net/context"
"context"
)

type responseKey struct{}
Expand Down
3 changes: 1 addition & 2 deletions client/mock/mock.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package mock

import (
"context"
"fmt"
"reflect"
"sync"

"github.com/micro/go-micro/client"
"github.com/micro/go-micro/errors"

"golang.org/x/net/context"
)

var (
Expand Down
3 changes: 1 addition & 2 deletions client/mock/mock_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package mock

import (
"context"
"testing"

"github.com/micro/go-micro/errors"

"golang.org/x/net/context"
)

func TestClient(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions client/options.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package client

import (
"context"
"time"

"github.com/micro/go-micro/broker"
"github.com/micro/go-micro/codec"
"github.com/micro/go-micro/registry"
"github.com/micro/go-micro/selector"
"github.com/micro/go-micro/transport"

"golang.org/x/net/context"
)

type Options struct {
Expand Down
4 changes: 3 additions & 1 deletion client/retry.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package client

import "golang.org/x/net/context"
import (
"context"
)

// note that returning either false or a non-nil error will result in the call not being retried
type RetryFunc func(ctx context.Context, req Request, retryCount int, err error) (bool, error)
Expand Down
3 changes: 1 addition & 2 deletions client/rpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package client

import (
"bytes"
"context"
"fmt"
"sync"
"time"
Expand All @@ -12,8 +13,6 @@ import (
"github.com/micro/go-micro/metadata"
"github.com/micro/go-micro/selector"
"github.com/micro/go-micro/transport"

"golang.org/x/net/context"
)

type rpcClient struct {
Expand Down
3 changes: 1 addition & 2 deletions client/rpc_client_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package client

import (
"context"
"fmt"
"testing"

"github.com/micro/go-micro/registry"
"github.com/micro/go-micro/registry/mock"
"github.com/micro/go-micro/selector"

"golang.org/x/net/context"
)

func TestCallWrapper(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions client/rpc_stream.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package client

import (
"context"
"io"
"sync"

"golang.org/x/net/context"
)

// Implements the streamer interface
Expand Down
4 changes: 2 additions & 2 deletions cmd/options.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package cmd

import (
"context"

"github.com/micro/go-micro/broker"
"github.com/micro/go-micro/client"
"github.com/micro/go-micro/registry"
"github.com/micro/go-micro/selector"
"github.com/micro/go-micro/server"
"github.com/micro/go-micro/transport"

"golang.org/x/net/context"
)

type Options struct {
Expand Down
2 changes: 1 addition & 1 deletion function.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package micro

import (
"context"
"time"

"github.com/micro/go-micro/server"
"golang.org/x/net/context"
)

type function struct {
Expand Down
3 changes: 1 addition & 2 deletions function_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package micro

import (
"context"
"sync"
"testing"

"github.com/micro/go-micro/registry/mock"
proto "github.com/micro/go-micro/server/debug/proto"

"golang.org/x/net/context"
)

func TestFunction(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions go-micro.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
package micro

import (
"context"

"github.com/micro/go-micro/client"
"github.com/micro/go-micro/server"

"golang.org/x/net/context"
)

type serviceKey struct{}
Expand Down
2 changes: 1 addition & 1 deletion metadata/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
package metadata

import (
"golang.org/x/net/context"
"context"
)

type metaKey struct{}
Expand Down
3 changes: 1 addition & 2 deletions metadata/metadata_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package metadata

import (
"context"
"testing"

"golang.org/x/net/context"
)

func TestMetadataContext(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions options.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package micro

import (
"context"
"time"

"github.com/micro/cli"
Expand All @@ -11,8 +12,6 @@ import (
"github.com/micro/go-micro/selector"
"github.com/micro/go-micro/server"
"github.com/micro/go-micro/transport"

"golang.org/x/net/context"
)

type Options struct {
Expand Down
3 changes: 2 additions & 1 deletion publisher.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package micro

import (
"context"

"github.com/micro/go-micro/client"
"golang.org/x/net/context"
)

type publisher struct {
Expand Down
3 changes: 2 additions & 1 deletion registry/consul/options.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package consul

import (
"context"

consul "github.com/hashicorp/consul/api"
"github.com/micro/go-micro/registry"
"golang.org/x/net/context"
)

func Config(c *consul.Config) registry.Option {
Expand Down
3 changes: 1 addition & 2 deletions registry/options.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package registry

import (
"context"
"crypto/tls"
"time"

"golang.org/x/net/context"
)

type Options struct {
Expand Down
Loading

0 comments on commit c9b40cb

Please sign in to comment.