Documentation ¶
Index ¶
- func DecodeAccountsRequest(_ context.Context, r *http.Request) (interface{}, error)
- func DecodeSubmitTransferRequest(_ context.Context, r *http.Request) (interface{}, error)
- func DecodeTransfersRequest(_ context.Context, r *http.Request) (interface{}, error)
- func EncodeResponse(_ context.Context, w http.ResponseWriter, response interface{}) error
- func MakeAccountsEndpoint(svc WalletService) endpoint.Endpoint
- func MakeSubmitTransferEndpoint(svc WalletService) endpoint.Endpoint
- func MakeTransfersEndpoint(svc WalletService) endpoint.Endpoint
- func NewHTTPTransport(svc WalletService) http.Handler
- type WalletService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeAccountsRequest ¶
DecodeAccountsRequest exported to be accessible from outside the package (from main)
func DecodeSubmitTransferRequest ¶
DecodeSubmitTransferRequest exported to be accessible from outside the package (from main)
func DecodeTransfersRequest ¶
DecodeTransfersRequest exported to be accessible from outside the package (from main)
func EncodeResponse ¶
func EncodeResponse(_ context.Context, w http.ResponseWriter, response interface{}) error
EncodeResponse exported to be accessible from outside the package (from main)
func MakeAccountsEndpoint ¶
func MakeAccountsEndpoint(svc WalletService) endpoint.Endpoint
MakeAccountsEndpoint is an endpoint constructor that takes a service and constructs individual endpoints for the method GetTable method
func MakeSubmitTransferEndpoint ¶
func MakeSubmitTransferEndpoint(svc WalletService) endpoint.Endpoint
MakeSubmitTransferEndpoint is an endpoint constructor that takes a service and constructs individual endpoints for the method GetTable method
func MakeTransfersEndpoint ¶
func MakeTransfersEndpoint(svc WalletService) endpoint.Endpoint
MakeTransfersEndpoint is an endpoint constructor that takes a service and constructs individual endpoints for the method GetTable method
func NewHTTPTransport ¶
func NewHTTPTransport(svc WalletService) http.Handler
NewHTTPTransport creates a new JSON over HTTP transport
Types ¶
type WalletService ¶
type WalletService interface { GetTable(string) ([]string, error) DoTransfer(string, string, string) (string, error) }
WalletService is the inteface to be used from outside the package that provides operations on accounts. GetTable is a method that can be used to get either the Accounts or Transfers table from the Postgres db, basically fetching the information about accounts or about all registered transfes. It takes an input sting as the name of the table (Accounts or Tansfers) and return a slice of strings containing all the entries in the specific table and a error (nil if the method ran successfully) DoTransfer is the method that actually implements the wallet's fund transfer functionality from one account to another. It takes 3 input strings (the source account, the destination account and the transferred amount) and returns a status string (like "successful") and an error.
func NewInstrumenting ¶
func NewInstrumenting(requestCount metrics.Counter, requestLatency metrics.Histogram, next WalletService) WalletService
NewInstrumenting is how the instrumenting middleware (instrumentingMiddleware struct) is constructed (the function is exported so it can be used from outside the package)
func NewLogging ¶
func NewLogging(logger log.Logger, next WalletService) WalletService
NewLogging is how the logging middleware (loggingMiddleware struct) is constructed (the function is exported so it can be used from outside the package)
func NewService ¶
func NewService() (WalletService, int, error)
NewService exported to be accessible from outside the package (from main) NewService is necessary because we need the ability to create a sqlDBTx stuct from outside the package (like from main)