Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query Service #616

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions api/proto/query_service/query_service.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
syntax = "proto3";
package query_service;
option go_package = "github.com/domino14/liwords/rpc/api/proto/query_service";

// GetGamesRequest should be designed to make all fields of a game accessible
// to a query

// type game struct {
// gorm.Model
// UUID string `gorm:"type:varchar(24);index"`
//
// Player0ID uint `gorm:"foreignKey"`
// Player0 user.User
//
// Player1ID uint `gorm:"foreignKey"`
// Player1 user.User
//
// ReadyFlag uint // When both players are ready, this game starts.
//
// Timers datatypes.JSON // A JSON blob containing the game timers.
//
// Started bool
// GameEndReason int `gorm:"index"`
// WinnerIdx int
// LoserIdx int
//
// Quickdata datatypes.JSON // A JSON blob containing the game quickdata.
//
// // Protobuf representations of the game request and history.
// Request []byte
// History []byte
//
// Stats datatypes.JSON
//
// // This is purposefully not a foreign key. It can be empty/NULL for
// // most games.
// TournamentID string `gorm:"index"`
// TournamentData datatypes.JSON
// }

message GetGamesRequest {}

message GetGamesResponse {}

service QueryService {
rpc GetGames(GetGamesRequest) returns (GetGamesResponse);
}
2 changes: 1 addition & 1 deletion build-protobuf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
protoc --plugin="protoc-gen-ts=/opt/node_modules/ts-protoc-gen/bin/protoc-gen-ts" --ts_out=liwords-ui/src/gen --js_out=import_style=commonjs,binary:liwords-ui/src/gen --proto_path=$CODE_DIR macondo/api/proto/macondo/macondo.proto


for api in "user_service" "game_service" "config_service" "tournament_service" "mod_service" "word_service"
for api in "user_service" "game_service" "config_service" "tournament_service" "mod_service" "word_service" "query_service"
do
protoc --twirp_out=rpc --go_out=rpc --proto_path=$CODE_DIR/ --proto_path=$CODE_DIR/liwords --go_opt=paths=source_relative --twirp_opt=paths=source_relative api/proto/$api/$api.proto
done
Expand Down
11 changes: 11 additions & 0 deletions pkg/query/query.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package query

import (
"context"

"github.com/domino14/liwords/pkg/gameplay"
)

func GetGames(ctx context.Context, gs gameplay.GameStore) error {
return nil
}
20 changes: 20 additions & 0 deletions pkg/query/service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package query

import (
"context"

"github.com/domino14/liwords/pkg/gameplay"
pb "github.com/domino14/liwords/rpc/api/proto/query_service"
)

type QueryService struct {
GameStore gameplay.GameStore
}

func NewModService(gs gameplay.GameStore) *QueryService {
return &QueryService{gs}
}

func (ms *QueryService) GetGames(ctx context.Context, req *pb.GetGamesRequest) (*pb.GetGamesResponse, error) {
return &pb.GetGamesResponse{}, nil
}
197 changes: 197 additions & 0 deletions rpc/api/proto/query_service/query_service.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading