learn

package module
v0.0.0-...-1259dbd Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2016 License: MIT Imports: 15 Imported by: 0

README

learn

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeGRPCCreateUserRequest

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

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

func DecodeGRPCCreateUserResponse

func DecodeGRPCCreateUserResponse(_ context.Context, grpcReply interface{}) (interface{}, error)

DecodeGRPCCreateUserResponse is a transport/grpc.DecodeResponseFunc that converts a gRPC create user response to a user-domain create user response. Primarily useful in a client.

func DecodeGRPCGetUserRequest

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

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

func DecodeGRPCGetUserResponse

func DecodeGRPCGetUserResponse(_ context.Context, grpcReply interface{}) (interface{}, error)

DecodeGRPCGetUserResponse is a transport/grpc.DecodeResponseFunc that converts a gRPC get user response to a user-domain get user response. Primarily useful in a client.

func DecodeHTTPCreateUserRequest

func DecodeHTTPCreateUserRequest(_ context.Context, r *http.Request) (interface{}, error)

DecodeHTTPSumRequest is a transport/http.DecodeRequestFunc that decodes a JSON-encoded sum request from the HTTP request body. Primarily useful in a server.

func DecodeHTTPCreateUserResponse

func DecodeHTTPCreateUserResponse(_ context.Context, r *http.Response) (interface{}, error)

DecodeHTTPSumResponse is a transport/http.DecodeResponseFunc that decodes a JSON-encoded sum response from the HTTP response body. If the response has a non-200 status code, we will interpret that as an error and attempt to decode the specific error message from the response body. Primarily useful in a client.

func DecodeHTTPGetUserRequest

func DecodeHTTPGetUserRequest(_ context.Context, r *http.Request) (interface{}, error)

DecodeHTTPConcatRequest is a transport/http.DecodeRequestFunc that decodes a JSON-encoded concat request from the HTTP request body. Primarily useful in a server.

func DecodeHTTPGetUserResponse

func DecodeHTTPGetUserResponse(_ context.Context, r *http.Response) (interface{}, error)

DecodeHTTPConcatResponse is a transport/http.DecodeResponseFunc that decodes a JSON-encoded concat response from the HTTP response body. If the response has a non-200 status code, we will interpret that as an error and attempt to decode the specific error message from the response body. Primarily useful in a client.

func EncodeGRPCCreateUserRequest

func EncodeGRPCCreateUserRequest(_ context.Context, request interface{}) (interface{}, error)

EncodeGRPCCreateUserRequest is a transport/grpc.EncodeRequestFunc that converts a user-domain Create User request to a gRPC Create User request. Primarily useful in a client.

func EncodeGRPCCreateUserResponse

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

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

func EncodeGRPCGetUserRequest

func EncodeGRPCGetUserRequest(_ context.Context, request interface{}) (interface{}, error)

EncodeGRPCGetUserRequest is a transport/grpc.EncodeRequestFunc that converts a user-domain Get User request to a gRPC Get User request. Primarily useful in a client.

func EncodeGRPCGetUserResponse

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

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

func EncodeHTTPGenericRequest

func EncodeHTTPGenericRequest(_ context.Context, r *http.Request, request interface{}) error

EncodeHTTPGenericRequest is a transport/http.EncodeRequestFunc that JSON-encodes any request to the request body. Primarily useful in a client.

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 EndpointLoggingMiddleware

func EndpointLoggingMiddleware(logger log.Logger) endpoint.Middleware

func EndpointMetricsMiddleware

func EndpointMetricsMiddleware(duration metrics.TimeHistogram) endpoint.Middleware

func MakeCreateUserEndpoint

func MakeCreateUserEndpoint(s UserService) endpoint.Endpoint

func MakeGRPCServer

func MakeGRPCServer(ctx context.Context, endpoints Endpoints, logger log.Logger) pb.UserServiceServer

func MakeGetUserEndpoint

func MakeGetUserEndpoint(s UserService) endpoint.Endpoint

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.

Types

type CreateUserRequest

type CreateUserRequest struct {
	User *User
}

type CreateUserResponse

type CreateUserResponse struct {
	User *User
	Err  error
}

type Endpoints

type Endpoints struct {
	CreateUserEndpoint endpoint.Endpoint
	GetUserEndpoint    endpoint.Endpoint
}

func (Endpoints) CreateUser

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

CreateUser implements Service. Primarily useful in a client.

func (Endpoints) GetUser

func (e Endpoints) GetUser(ctx context.Context, id string) (*User, error)

GetUser implements Service. Primarily useful in a client.

type GetUserRequest

type GetUserRequest struct {
	Id string
}

type GetUserResponse

type GetUserResponse struct {
	User *User
	Err  error
}

type Middleware

type Middleware func(UserService) UserService

func ServiceLoggingMiddleware

func ServiceLoggingMiddleware(logger log.Logger) Middleware

func ServiceMetricsMiddleware

func ServiceMetricsMiddleware(gets metrics.Counter, creates metrics.Counter) Middleware

type User

type User struct {
	Id        string
	FirstName string
	LastName  string
	Email     string
	Username  string
}

type UserService

type UserService interface {
	CreateUser(cxt context.Context, user *User) (*User, error)
	GetUser(cxt context.Context, id string) (*User, error)
}

func NewBasicService

func NewBasicService() UserService

Directories

Path Synopsis
cmd
Package pb is a generated protocol buffer package.
Package pb is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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