Documentation
¶
Overview ¶
Code generated by Frodo - DO NOT EDIT.
Timestamp: Tue, 10 May 2022 16:25:35 EDT Source: scores/score_service.go Generator: https://github.com/monadicstack/frodo
Code generated by Frodo - DO NOT EDIT.
Timestamp: Tue, 10 May 2022 16:25:34 EDT Source: scores/score_service.go Generator: https://github.com/monadicstack/frodo
Index ¶
- type ScoreServiceClient
- func (client *ScoreServiceClient) HighScoresForGame(ctx context.Context, request *scores.HighScoresForGameRequest) (*scores.HighScoresForGameResponse, error)
- func (client *ScoreServiceClient) NewHighScore(ctx context.Context, request *scores.NewHighScoreRequest) (*scores.NewHighScoreResponse, error)
- type ScoreServiceGateway
- func (gw ScoreServiceGateway) HighScoresForGame(ctx context.Context, request *scores.HighScoresForGameRequest) (*scores.HighScoresForGameResponse, error)
- func (gw ScoreServiceGateway) NewHighScore(ctx context.Context, request *scores.NewHighScoreRequest) (*scores.NewHighScoreResponse, error)
- func (gw ScoreServiceGateway) ServeHTTP(w http.ResponseWriter, req *http.Request)
- type ScoreServiceProxy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ScoreServiceClient ¶
ScoreServiceClient manages all interaction w/ a remote ScoreService instance by letting you invoke functions on this instance as if you were doing it locally (hence... RPC client). You shouldn't instantiate this manually. Instead, you should utilize the NewScoreServiceClient() function to properly set this up.
func NewScoreServiceClient ¶
func NewScoreServiceClient(address string, options ...rpc.ClientOption) *ScoreServiceClient
NewScoreServiceClient creates an RPC client that conforms to the ScoreService interface, but delegates work to remote instances. You must supply the base address of the remote service gateway instance or the load balancer for that service.
ScoreService is a shared leaderboard service that tracks the high scores that people have achieved while playing various games.
func (*ScoreServiceClient) HighScoresForGame ¶
func (client *ScoreServiceClient) HighScoresForGame(ctx context.Context, request *scores.HighScoresForGameRequest) (*scores.HighScoresForGameResponse, error)
HighScoresForGame fetches the top "N" high scores achieved by any player for the specified game. If you don't specify the HowMany value, this will default to returning the top 5 scores.
Frodo Notes: The request has 2 attributes. The GameID field will be populated via the path parameters, but HowMany will be specified via the query string. The auto-generated clients will do this by default under the hood, but if you use curl/Postman, that's how you would supply that (e.g. "/v2/game/2/highscore?howMany=3" for the top 3).
func (*ScoreServiceClient) NewHighScore ¶
func (client *ScoreServiceClient) NewHighScore(ctx context.Context, request *scores.NewHighScoreRequest) (*scores.NewHighScoreResponse, error)
NewHighScore captures a player's high score for the given game.
type ScoreServiceGateway ¶ added in v1.1.2
func NewScoreServiceGateway ¶
func NewScoreServiceGateway(service scores.ScoreService, options ...rpc.GatewayOption) ScoreServiceGateway
NewScoreServiceGateway accepts your "real" ScoreService instance (the thing that really does the work), and exposes it to other services/clients over RPC. The rpc.Gateway it returns implements http.Handler, so you can pass it to any standard library HTTP server of your choice.
// How to fire up your service for RPC and/or your REST API
service := scores.ScoreService{ /* set up to your liking */ }
gateway := scores.NewScoreServiceGateway(service)
http.ListenAndServe(":8080", gateway)
The default instance works well enough, but you can supply additional options such as WithMiddleware() which accepts any negroni-compatible middleware handlers.
func (ScoreServiceGateway) HighScoresForGame ¶ added in v1.1.2
func (gw ScoreServiceGateway) HighScoresForGame(ctx context.Context, request *scores.HighScoresForGameRequest) (*scores.HighScoresForGameResponse, error)
func (ScoreServiceGateway) NewHighScore ¶ added in v1.1.2
func (gw ScoreServiceGateway) NewHighScore(ctx context.Context, request *scores.NewHighScoreRequest) (*scores.NewHighScoreResponse, error)
func (ScoreServiceGateway) ServeHTTP ¶ added in v1.1.2
func (gw ScoreServiceGateway) ServeHTTP(w http.ResponseWriter, req *http.Request)
type ScoreServiceProxy ¶
type ScoreServiceProxy struct {
Service scores.ScoreService
}
ScoreServiceProxy fully implements the ScoreService interface, but delegates all operations to a "real" instance of the service. You can embed this type in a struct of your choice so you can "override" or decorate operations as you see fit. Any operations on ScoreService that you don't explicitly define will simply delegate to the default implementation of the underlying 'Service' value.
Since you have access to the underlying service, you are able to both implement custom handling logic AND call the "real" implementation, so this can be used as special middleware that applies to only certain operations.
func (*ScoreServiceProxy) HighScoresForGame ¶
func (proxy *ScoreServiceProxy) HighScoresForGame(ctx context.Context, request *scores.HighScoresForGameRequest) (*scores.HighScoresForGameResponse, error)
func (*ScoreServiceProxy) NewHighScore ¶
func (proxy *ScoreServiceProxy) NewHighScore(ctx context.Context, request *scores.NewHighScoreRequest) (*scores.NewHighScoreResponse, error)