scores

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: May 24, 2022 License: MIT Imports: 6 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ScoreServiceClient

type ScoreServiceClient struct {
	rpc.Client
}

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

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

NewHighScore captures a player's high score for the given game.

type ScoreServiceGateway added in v1.1.2

type ScoreServiceGateway struct {
	rpc.Gateway
	// contains filtered or unexported fields
}

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 (ScoreServiceGateway) NewHighScore added in v1.1.2

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 (*ScoreServiceProxy) NewHighScore

Jump to

Keyboard shortcuts

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