MCPcopy Create free account

hub / github.com/Evertras/go-interface-examples / functions

Functions51 in github.com/Evertras/go-interface-examples

↓ 3 callersFunctionNew
New creates a new Leaderboard ready to do leaderboard things Accept interfaces, return implementations!
local-interfaces/leaderboard/leaderboard.go:43
↓ 3 callersFunctionNewGSLDataStore
NewGSLDataStore returns a GSLDataStore ready to tell us about the GSL
outside-world/less-velociraptors/data.go:14
↓ 3 callersMethodNotifyTopPlayers
NotifyTopPlayers will send a notification to the top X players
local-interfaces/leaderboard/leaderboard.go:51
↓ 3 callersFunctiongslCurrentChampionHandler
Creates a handler that writes the current champion to the client. Now we're creating a handler and 'injecting' the data store that it will use to get
outside-world/less-velociraptors/server.go:15
↓ 3 callersFunctiongslCurrentChampionHandler
Creates a handler that writes the current champion to the client. Now our handler is saying something very powerful. It's saying "I need something t
outside-world/no-velociraptors/server.go:23
↓ 2 callersFunctionDeleteUserHandler
DeleteUserHandler creates an HTTP handler that deletes a user from the store
local-interfaces/handlers/user.go:40
↓ 2 callersMethodGetCurrentChampion
()
outside-world/no-velociraptors/server.go:15
↓ 1 callersMethodDeleteUser
(ctx context.Context, id string)
local-interfaces/handlers/user.go:19
↓ 1 callersMethodGetTopUsers
(ctx context.Context, count int)
local-interfaces/leaderboard/leaderboard.go:23
↓ 1 callersMethodGetUserScore
(ctx context.Context, id string)
local-interfaces/handlers/user.go:18
↓ 1 callersFunctionGetUserScoreHandler
GetUserScoreHandler creates an HTTP handler that can get a user's score
local-interfaces/handlers/user.go:23
↓ 1 callersFunctionNew
New returns a new Notifier ready to send notifications Doesn't actually do anything, but real code will do stuff here...
local-interfaces/notifications/notifier.go:18
↓ 1 callersFunctionNew
New returns a new Db ready to do Db things. Notice we don't provide an interface here! We only provide the concrete implementation. Accept interfac
local-interfaces/db/db.go:17
↓ 1 callersFunctionNewGSLDataStore
NewGSLDataStore returns a GSLDataStore ready to tell us about the GSL
outside-world/no-velociraptors/data.go:14
↓ 1 callersMethodNotifyTopScore
(ctx context.Context, id string, score int)
local-interfaces/leaderboard/leaderboard.go:31
↓ 1 callersFunctiongslCurrentChampionHandler
(res http.ResponseWriter, req *http.Request)
outside-world/simple/server.go:7
↓ 1 callersFunctiongslCurrentChampionHandler
(res http.ResponseWriter, req *http.Request)
outside-world/velociraptors/server.go:9
↓ 1 callersFunctionrunServer
Runs the server on the specified address with the given data store Notice we added the data store here as a parameter. To run our server, we must ha
outside-world/less-velociraptors/server.go:34
↓ 1 callersFunctionrunServer
Runs a server that lets us see GSL info
outside-world/simple/server.go:13
↓ 1 callersFunctionrunServer
(address string)
outside-world/velociraptors/server.go:23
↓ 1 callersFunctionrunServer
Runs the server on the specified address with the given data store Our server is
outside-world/no-velociraptors/server.go:40
MethodAwardPoints
AwardPoints gives points to all the users in the ids array
local-interfaces/db/db.go:75
MethodCreateUser
CreateUser creates a user starting with a score of 0
local-interfaces/db/db.go:53
MethodDeleteUser
(ctx context.Context, id string)
local-interfaces/handlers/user_test.go:22
MethodDeleteUser
DeleteUser deletes a user with the given ID
local-interfaces/db/db.go:59
MethodGetCurrentChampion
GetCurrentChampion returns the name of the current GSL champion
outside-world/less-velociraptors/data.go:21
MethodGetCurrentChampion
We match the interface that our handler requires, so we can pass it in to the handler
outside-world/no-velociraptors/server_test.go:18
MethodGetCurrentChampion
GetCurrentChampion returns the name of the current GSL champion
outside-world/no-velociraptors/data.go:21
MethodGetTopUsers
(ctx context.Context, count int)
local-interfaces/leaderboard/leaderboard_test.go:18
MethodGetTopUsers
GetTopUsers returns the top X users ranked by score Note that it makes sense here to return full user information, or at least some struct that conta
local-interfaces/db/db.go:69
MethodGetUser
GetUser returns a user's full information from the database Notice this returns a User, which is part of this package. This means that any interface
local-interfaces/db/db.go:33
MethodGetUserScore
(ctx context.Context, id string)
local-interfaces/handlers/user_test.go:18
MethodGetUserScore
GetUserScore returns a user's score from their ID Notice this function signature doesn't contain any package-specific types, which means any interfac
local-interfaces/db/db.go:47
MethodNotifyPasswordUpdate
NotifyPasswordUpdate notifies a user that their password has been updated
local-interfaces/notifications/notifier.go:32
MethodNotifyTopScore
NotifyTopScore sends a notification to a user about their top score
local-interfaces/notifications/notifier.go:23
MethodNotifyTopScore
(ctx context.Context, id string, count int)
local-interfaces/leaderboard/leaderboard_test.go:27
FunctionTestDeleteUserDeletesUserIDFromBody
(t *testing.T)
local-interfaces/handlers/user_test.go:56
FunctionTestGSLCurrentChampionIsTY
(t *testing.T)
outside-world/less-velociraptors/server_test.go:9
FunctionTestGSLCurrentChampionIsTY
(t *testing.T)
outside-world/simple/server_test.go:8
FunctionTestGSLCurrentChampionIsTY
(t *testing.T)
outside-world/velociraptors/server_test.go:9
FunctionTestGSLCurrentChampionReturned
(t *testing.T)
outside-world/no-velociraptors/server_test.go:26
FunctionTestGSLCurrentChampionReturns500WhenFileDoesntExist
On the bright side, we can add this test now!
outside-world/less-velociraptors/server_test.go:41
FunctionTestGSLCurrentChampionReturns500WhenGetterFails
This test is even more sensible now
outside-world/no-velociraptors/server_test.go:54
FunctionTestGetUserScoreHandlerReturnsScore
(t *testing.T)
local-interfaces/handlers/user_test.go:32
FunctionTestNotifyTopPlayersErrorsWhenGetterFails
(t *testing.T)
local-interfaces/leaderboard/leaderboard_test.go:37
FunctionTestNotifyTopPlayersSendsNotificationsToSpecifiedNumberOfPlayers
(t *testing.T)
local-interfaces/leaderboard/leaderboard_test.go:59
Functionmain
()
outside-world/less-velociraptors/main.go:7
Functionmain
()
outside-world/simple/main.go:7
Functionmain
()
outside-world/velociraptors/main.go:7
Functionmain
()
outside-world/no-velociraptors/main.go:7
Functionmain
()
local-interfaces/cmd/main.go:12