util

package
v0.0.0-...-63088e7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SampleOrders = []order.Order{
	order.Order{
		Id:   "22f4ee36-2c3e-450f-bb65-36e52656b183",
		User: "0a30cbc7-91f1-4637-832f-9ddb9978e1c5",
		Items: []string{
			"6ab9e0c2-e7be-4120-a3e9-62c39b7dbfd7",
			"4415fede-7462-4f12-b87f-ede596ec6ee2",
		},
	},
	order.Order{
		Id:   "034735ae-b5c8-47dd-9b59-30eacc62473a",
		User: "0a30cbc7-91f1-4637-832f-9ddb9978e1c5",
		Items: []string{
			"6962f4ff-b752-4103-b90c-1f9bcec30913",
			"dff79aa1-6b13-4aeb-8dca-22a45322a293",
		},
	},
	order.Order{
		Id:   "4b2f25c3-f0fb-4640-9fc8-a3066a8022f6",
		User: "d6dd61c4-75a6-4424-91b2-ab740501c94f",
		Items: []string{
			"5d210689-cca7-4e81-8437-05b20f658ad0",
		},
	},
}

SampleOrders is sample order data for testing.

View Source
var SampleUsers = []user.User{
	user.User{
		Id:      "0a30cbc7-91f1-4637-832f-9ddb9978e1c5",
		Name:    "User One",
		Address: "1234 5th Street",
	},
	user.User{
		Id:      "d6dd61c4-75a6-4424-91b2-ab740501c94f",
		Name:    "User Two",
		Address: "6th Ave",
	},
	user.User{
		Id:      "32cc174b-3586-4263-9c67-fce988d246ca",
		Name:    "User Three",
		Address: "Down by the river",
	},
}

SampleUsers is sample user data for testing.

Functions

func CopyZipkinHeaders

func CopyZipkinHeaders(next http.Handler) http.Handler

CopyZipkinHeaders copies request headers to the request context.

func IsAlreadyExistsError

func IsAlreadyExistsError(err error) bool

IsAlreadyExistsError determines if the error is a AlreadyExists grpc error

func IsInvalidArgumentError

func IsInvalidArgumentError(err error) bool

IsInvalidArgumentError determines if the error is a InvalidArgument grpc error

func IsNotFoundError

func IsNotFoundError(err error) bool

IsNotFoundError determines if the error is a NotFound grpc error

func NewAlreadyExistsError

func NewAlreadyExistsError(kind, name string) error

NewAlreadyExistsError creates a new AlreadyExists grpc error

func NewDefaultLogger

func NewDefaultLogger() (*zap.Logger, error)

NewDefaultLogger creates a new logger with our prefered options

func NewInvalidArgumentError

func NewInvalidArgumentError(kind, name string) error

NewInvalidArgumentError creates a new InvalidArgument grpc error

func NewNotFoundError

func NewNotFoundError(kind, name string) error

NewNotFoundError creates a new NotFound grpc error

func UnaryClientInterceptor

func UnaryClientInterceptor() func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error

UnaryClientInterceptor returns a new unary client interceptor for copying metadata

func UnaryServerInterceptor

func UnaryServerInterceptor() grpc.UnaryServerInterceptor

UnaryServerInterceptor returns a new unary server interceptor for copying metadata

func UnaryServerSleeperInterceptor

func UnaryServerSleeperInterceptor(t time.Duration) grpc.UnaryServerInterceptor

UnaryServerSleeperInterceptor returns a new unary server interceptor that sleeps for a random amount of time

Types

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is a wrapper for a grpc and an http server

func NewServer

func NewServer(g *grpc.Server, gAddr string, h *http.Server, hAddr string) *Server

func (*Server) Run

func (s *Server) Run() error

Run generally does not return

func (*Server) Stop

func (s *Server) Stop()

Stop ...

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL