svc

package
v0.0.0-...-54005c8 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2017 License: Unlicense Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildParamMap

func BuildParamMap(urlTmpl string) map[string]int

BuildParamMap takes a string representing a url template and returns a map indicating the location of each parameter within that url, where the location is the index as if in a slash-separated sequence of path components. For example, given the url template:

"/v1/{a}/{b}"

The returned param map would look like:

map[string]int {
    "a": 2,
    "b": 3,
}

func DecodeGRPCCreateUserRequest

func DecodeGRPCCreateUserRequest(_ context.Context, grpcReq interface{}) (interface{}, error)

DecodeGRPCCreateUserRequest is a transport/grpc.DecodeRequestFunc that converts a gRPC createuser request to a user-domain createuser request. Primarily useful in a server.

func DecodeGRPCDeleteUserRequest

func DecodeGRPCDeleteUserRequest(_ context.Context, grpcReq interface{}) (interface{}, error)

DecodeGRPCDeleteUserRequest is a transport/grpc.DecodeRequestFunc that converts a gRPC deleteuser request to a user-domain deleteuser request. Primarily useful in a server.

func DecodeGRPCReadUserRequest

func DecodeGRPCReadUserRequest(_ context.Context, grpcReq interface{}) (interface{}, error)

DecodeGRPCReadUserRequest is a transport/grpc.DecodeRequestFunc that converts a gRPC readuser request to a user-domain readuser request. Primarily useful in a server.

func DecodeGRPCUpdateUserRequest

func DecodeGRPCUpdateUserRequest(_ context.Context, grpcReq interface{}) (interface{}, error)

DecodeGRPCUpdateUserRequest is a transport/grpc.DecodeRequestFunc that converts a gRPC updateuser request to a user-domain updateuser request. Primarily useful in a server.

func EncodeGRPCCreateUserResponse

func EncodeGRPCCreateUserResponse(_ context.Context, response interface{}) (interface{}, error)

EncodeGRPCCreateUserResponse is a transport/grpc.EncodeResponseFunc that converts a user-domain createuser response to a gRPC createuser reply. Primarily useful in a server.

func EncodeGRPCDeleteUserResponse

func EncodeGRPCDeleteUserResponse(_ context.Context, response interface{}) (interface{}, error)

EncodeGRPCDeleteUserResponse is a transport/grpc.EncodeResponseFunc that converts a user-domain deleteuser response to a gRPC deleteuser reply. Primarily useful in a server.

func EncodeGRPCReadUserResponse

func EncodeGRPCReadUserResponse(_ context.Context, response interface{}) (interface{}, error)

EncodeGRPCReadUserResponse is a transport/grpc.EncodeResponseFunc that converts a user-domain readuser response to a gRPC readuser reply. Primarily useful in a server.

func EncodeGRPCUpdateUserResponse

func EncodeGRPCUpdateUserResponse(_ context.Context, response interface{}) (interface{}, error)

EncodeGRPCUpdateUserResponse is a transport/grpc.EncodeResponseFunc that converts a user-domain updateuser response to a gRPC updateuser reply. Primarily useful in a server.

func EncodeHTTPGenericResponse

func EncodeHTTPGenericResponse(_ context.Context, w http.ResponseWriter, response interface{}) error

EncodeHTTPGenericResponse is a transport/http.EncodeResponseFunc that encodes the response as JSON to the response writer. Primarily useful in a server.

func MakeCreateUserEndpoint

func MakeCreateUserEndpoint(s pb.UsersServer) endpoint.Endpoint

func MakeDeleteUserEndpoint

func MakeDeleteUserEndpoint(s pb.UsersServer) endpoint.Endpoint

func MakeGRPCServer

func MakeGRPCServer(ctx context.Context, endpoints Endpoints) pb.UsersServer

MakeGRPCServer makes a set of endpoints available as a gRPC UsersServer.

func MakeHTTPHandler

func MakeHTTPHandler(ctx context.Context, endpoints Endpoints, logger log.Logger) http.Handler

MakeHTTPHandler returns a handler that makes a set of endpoints available on predefined paths.

func MakeReadUserEndpoint

func MakeReadUserEndpoint(s pb.UsersServer) endpoint.Endpoint

func MakeUpdateUserEndpoint

func MakeUpdateUserEndpoint(s pb.UsersServer) endpoint.Endpoint

func PathParams

func PathParams(url string, urlTmpl string) (map[string]string, error)

PathParams takes a url and a gRPC-annotation style url template, and returns a map of the named parameters in the template and their values in the given url.

PathParams does not support the entirety of the URL template syntax defined in third_party/googleapis/google/api/httprule.proto. Only a small subset of the functionality defined there is implemented here.

func RemoveBraces

func RemoveBraces(val string) string

RemoveBraces replace all curly braces in the provided string, opening and closing, with empty strings.

Types

type Endpoints

type Endpoints struct {
	CreateUserEndpoint endpoint.Endpoint
	ReadUserEndpoint   endpoint.Endpoint
	UpdateUserEndpoint endpoint.Endpoint
	DeleteUserEndpoint endpoint.Endpoint
}

Endpoints collects all of the endpoints that compose an add service. It's meant to be used as a helper struct, to collect all of the endpoints into a single parameter.

In a server, it's useful for functions that need to operate on a per-endpoint basis. For example, you might pass an Endpoints to a function that produces an http.Handler, with each method (endpoint) wired up to a specific path. (It is probably a mistake in design to invoke the Service methods on the Endpoints struct in a server.)

In a client, it's useful to collect individually constructed endpoints into a single type that implements the Service interface. For example, you might construct individual endpoints using transport/http.NewClient, combine them into an Endpoints, and return it to the caller as a Service.

func (Endpoints) CreateUser

func (e Endpoints) CreateUser(ctx context.Context, in *pb.User) (*pb.User, error)

func (Endpoints) DeleteUser

func (e Endpoints) DeleteUser(ctx context.Context, in *pb.User) (*pb.User, error)

func (Endpoints) ReadUser

func (e Endpoints) ReadUser(ctx context.Context, in *pb.User) (*pb.User, error)

func (Endpoints) UpdateUser

func (e Endpoints) UpdateUser(ctx context.Context, in *pb.User) (*pb.User, error)

func (*Endpoints) WrapAllExcept

func (e *Endpoints) WrapAllExcept(middleware endpoint.Middleware, excluded ...string)

WrapAllExcept wraps each Endpoint field of struct Endpoints with a go-kit/kit/endpoint.Middleware. Use this for applying a set of middlewares to every endpoint in the service. Optionally, endpoints can be passed in by name to be excluded from being wrapped. WrapAllExcept(middleware, "Status", "Ping")

Directories

Path Synopsis
client
grpc
Package grpc provides a gRPC client for the Users service.
Package grpc provides a gRPC client for the Users service.
http
Package http provides an HTTP client for the Users service.
Package http provides an HTTP client for the Users service.
cli

Jump to

Keyboard shortcuts

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