mirror of
https://github.com/googleforgames/open-match.git
synced 2025-03-25 13:24:18 +00:00
Add Evaluator Proto, Evaluator Harness and an example Evaluator using the harness. (#545)
* Add Evaluator Proto, Evaluator Harness and an example Evaluator using the harness. This change just adds a skeleton of the sample evaluator to set up building the harness. The actual evaluation logic for the example, tests and wiring up the example in the helm charts, demos and e2e tests etc., will follow in future PRs. * fix golint issues
This commit is contained in:
@ -111,6 +111,7 @@ cmd/swaggerui/swaggerui
|
||||
tools/certgen/certgen
|
||||
examples/demo/demo
|
||||
examples/functions/golang/soloduel/soloduel
|
||||
examples/evaluator/golang/simple/simple
|
||||
tools/reaper/reaper
|
||||
|
||||
# Open Match Build Directory
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -111,6 +111,7 @@ cmd/swaggerui/swaggerui
|
||||
tools/certgen/certgen
|
||||
examples/demo/demo
|
||||
examples/functions/golang/soloduel/soloduel
|
||||
examples/evaluator/golang/simple/simple
|
||||
tools/reaper/reaper
|
||||
|
||||
# Secrets Directories
|
||||
|
28
Makefile
28
Makefile
@ -211,9 +211,10 @@ push-images: push-service-images push-example-images push-tool-images
|
||||
|
||||
|
||||
push-service-images: push-backend-image push-frontend-image push-mmlogic-image push-minimatch-image push-synchronizer-image push-swaggerui-image
|
||||
push-example-images: push-demo-images push-mmf-example-images
|
||||
push-example-images: push-demo-images push-mmf-example-images push-evaluator-example-images
|
||||
push-demo-images: push-mmf-go-soloduel-image push-demo-image
|
||||
push-mmf-example-images: push-mmf-go-soloduel-image
|
||||
push-evaluator-example-images: push-evaluator-go-simple-image
|
||||
push-tool-images: push-reaper-image
|
||||
|
||||
push-backend-image: docker build-backend-image
|
||||
@ -248,6 +249,10 @@ push-mmf-go-soloduel-image: docker build-mmf-go-soloduel-image
|
||||
docker push $(REGISTRY)/openmatch-mmf-go-soloduel:$(TAG)
|
||||
docker push $(REGISTRY)/openmatch-mmf-go-soloduel:$(ALTERNATE_TAG)
|
||||
|
||||
push-evaluator-go-simple-image: docker build-evaluator-go-simple-image
|
||||
docker push $(REGISTRY)/openmatch-evaluator-go-simple:$(TAG)
|
||||
docker push $(REGISTRY)/openmatch-evaluator-go-simple:$(ALTERNATE_TAG)
|
||||
|
||||
push-reaper-image: docker build-reaper-image
|
||||
docker push $(REGISTRY)/openmatch-reaper:$(TAG)
|
||||
docker push $(REGISTRY)/openmatch-reaper:$(ALTERNATE_TAG)
|
||||
@ -255,9 +260,10 @@ push-reaper-image: docker build-reaper-image
|
||||
build-images: build-service-images build-example-images build-tool-images
|
||||
|
||||
build-service-images: build-backend-image build-frontend-image build-mmlogic-image build-minimatch-image build-synchronizer-image build-swaggerui-image
|
||||
build-example-images: build-demo-images build-mmf-example-images
|
||||
build-example-images: build-demo-images build-mmf-example-images build-evaluator-example-images
|
||||
build-demo-images: build-mmf-go-soloduel-image build-demo-image
|
||||
build-mmf-example-images: build-mmf-go-soloduel-image
|
||||
build-evaluator-example-images: build-evaluator-go-simple-image
|
||||
build-tool-images: build-reaper-image
|
||||
|
||||
# Include all-protos here so that all dependencies are guaranteed to be downloaded after the base image is created.
|
||||
@ -289,6 +295,9 @@ build-demo-image: docker build-base-build-image
|
||||
build-mmf-go-soloduel-image: docker build-base-build-image
|
||||
docker build -f examples/functions/golang/soloduel/Dockerfile -t $(REGISTRY)/openmatch-mmf-go-soloduel:$(TAG) -t $(REGISTRY)/openmatch-mmf-go-soloduel:$(ALTERNATE_TAG) .
|
||||
|
||||
build-evaluator-go-simple-image: docker build-base-build-image
|
||||
docker build -f examples/evaluator/golang/simple/Dockerfile -t $(REGISTRY)/openmatch-evaluator-go-simple:$(TAG) -t $(REGISTRY)/openmatch-evaluator-go-simple:$(ALTERNATE_TAG) .
|
||||
|
||||
build-reaper-image: docker build-base-build-image
|
||||
docker build -f tools/reaper/Dockerfile -t $(REGISTRY)/openmatch-reaper:$(TAG) -t $(REGISTRY)/openmatch-reaper:$(ALTERNATE_TAG) .
|
||||
|
||||
@ -302,6 +311,7 @@ clean-images: docker
|
||||
-docker rmi -f $(REGISTRY)/openmatch-swaggerui:$(TAG) $(REGISTRY)/openmatch-swaggerui:$(ALTERNATE_TAG)
|
||||
|
||||
-docker rmi -f $(REGISTRY)/openmatch-mmf-go-soloduel:$(TAG) $(REGISTRY)/openmatch-mmf-go-soloduel:$(ALTERNATE_TAG)
|
||||
-docker rmi -f $(REGISTRY)/openmatch-evaluator-go-simple:$(TAG) $(REGISTRY)/openmatch-evaluator-go-simple:$(ALTERNATE_TAG)
|
||||
-docker rmi -f $(REGISTRY)/openmatch-demo:$(TAG) $(REGISTRY)/openmatch-demo:$(ALTERNATE_TAG)
|
||||
-docker rmi -f $(REGISTRY)/openmatch-reaper:$(TAG) $(REGISTRY)/openmatch-reaper:$(ALTERNATE_TAG)
|
||||
|
||||
@ -630,11 +640,11 @@ gcp-apply-binauthz-policy: build/policies/binauthz.yaml
|
||||
$(GCLOUD) beta $(GCP_PROJECT_FLAG) container binauthz policy import build/policies/binauthz.yaml
|
||||
|
||||
all-protos: golang-protos http-proxy-golang-protos swagger-json-docs
|
||||
golang-protos: internal/pb/backend.pb.go internal/pb/frontend.pb.go internal/pb/matchfunction.pb.go internal/pb/messages.pb.go internal/pb/mmlogic.pb.go internal/pb/synchronizer.pb.go
|
||||
golang-protos: internal/pb/backend.pb.go internal/pb/frontend.pb.go internal/pb/matchfunction.pb.go internal/pb/messages.pb.go internal/pb/mmlogic.pb.go internal/pb/synchronizer.pb.go internal/pb/evaluator.pb.go
|
||||
|
||||
http-proxy-golang-protos: internal/pb/backend.pb.gw.go internal/pb/frontend.pb.gw.go internal/pb/matchfunction.pb.gw.go internal/pb/messages.pb.gw.go internal/pb/mmlogic.pb.gw.go internal/pb/synchronizer.pb.gw.go
|
||||
http-proxy-golang-protos: internal/pb/backend.pb.gw.go internal/pb/frontend.pb.gw.go internal/pb/matchfunction.pb.gw.go internal/pb/messages.pb.gw.go internal/pb/mmlogic.pb.gw.go internal/pb/synchronizer.pb.gw.go internal/pb/evaluator.pb.gw.go
|
||||
|
||||
swagger-json-docs: api/frontend.swagger.json api/backend.swagger.json api/mmlogic.swagger.json api/matchfunction.swagger.json api/synchronizer.swagger.json
|
||||
swagger-json-docs: api/frontend.swagger.json api/backend.swagger.json api/mmlogic.swagger.json api/matchfunction.swagger.json api/synchronizer.swagger.json api/evaluator.swagger.json
|
||||
|
||||
internal/pb/%.pb.go: api/%.proto build/toolchain/bin/protoc$(EXE_EXTENSION) build/toolchain/bin/protoc-gen-go$(EXE_EXTENSION) build/toolchain/bin/protoc-gen-grpc-gateway$(EXE_EXTENSION)
|
||||
$(PROTOC) $< \
|
||||
@ -656,6 +666,7 @@ internal/pb/frontend.pb.go: internal/pb/messages.pb.go
|
||||
internal/pb/mmlogic.pb.go: internal/pb/messages.pb.go
|
||||
internal/pb/synchronizer.pb.go: internal/pb/messages.pb.go
|
||||
internal/pb/matchfunction.pb.go: internal/pb/messages.pb.go
|
||||
internal/pb/evaluator.pb.go: internal/pb/messages.pb.go
|
||||
|
||||
build:
|
||||
$(GO) build ./...
|
||||
@ -688,12 +699,16 @@ service-binaries: cmd/minimatch/minimatch$(EXE_EXTENSION) cmd/swaggerui/swaggeru
|
||||
service-binaries: cmd/backend/backend$(EXE_EXTENSION) cmd/frontend/frontend$(EXE_EXTENSION)
|
||||
service-binaries: cmd/mmlogic/mmlogic$(EXE_EXTENSION) cmd/synchronizer/synchronizer$(EXE_EXTENSION)
|
||||
|
||||
example-binaries: example-mmf-binaries
|
||||
example-binaries: example-mmf-binaries example-evaluator-binaries
|
||||
example-mmf-binaries: examples/functions/golang/soloduel/soloduel$(EXE_EXTENSION)
|
||||
example-evaluator-binaries: examples/evaluator/golang/simple/simple$(EXE_EXTENSION)
|
||||
|
||||
examples/functions/golang/soloduel/soloduel$(EXE_EXTENSION): internal/pb/mmlogic.pb.go internal/pb/mmlogic.pb.gw.go api/mmlogic.swagger.json internal/pb/matchfunction.pb.go internal/pb/matchfunction.pb.gw.go api/matchfunction.swagger.json
|
||||
cd $(REPOSITORY_ROOT)/examples/functions/golang/soloduel; $(GO_BUILD_COMMAND)
|
||||
|
||||
examples/evaluator/golang/simple/simple$(EXE_EXTENSION): internal/pb/evaluator.pb.go internal/pb/evaluator.pb.gw.go api/evaluator.swagger.json
|
||||
cd $(REPOSITORY_ROOT)/examples/evaluator/golang/simple; $(GO_BUILD_COMMAND)
|
||||
|
||||
tools-binaries: tools/certgen/certgen$(EXE_EXTENSION) tools/reaper/reaper$(EXE_EXTENSION)
|
||||
|
||||
cmd/backend/backend$(EXE_EXTENSION): internal/pb/backend.pb.go internal/pb/backend.pb.gw.go api/backend.swagger.json
|
||||
@ -786,6 +801,7 @@ clean-binaries:
|
||||
rm -rf $(REPOSITORY_ROOT)/cmd/mmlogic/mmlogic$(EXE_EXTENSION)
|
||||
rm -rf $(REPOSITORY_ROOT)/cmd/minimatch/minimatch$(EXE_EXTENSION)
|
||||
rm -rf $(REPOSITORY_ROOT)/examples/functions/golang/soloduel/soloduel$(EXE_EXTENSION)
|
||||
rm -rf $(REPOSITORY_ROOT)/examples/functions/golang/simple/evaluator$(EXE_EXTENSION)
|
||||
rm -rf $(REPOSITORY_ROOT)/cmd/swaggerui/swaggerui$(EXE_EXTENSION)
|
||||
rm -rf $(REPOSITORY_ROOT)/tools/certgen/certgen$(EXE_EXTENSION)
|
||||
rm -rf $(REPOSITORY_ROOT)/tools/reaper/reaper$(EXE_EXTENSION)
|
||||
|
78
api/evaluator.proto
Normal file
78
api/evaluator.proto
Normal file
@ -0,0 +1,78 @@
|
||||
// Copyright 2019 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
syntax = "proto3";
|
||||
package api;
|
||||
option go_package = "internal/pb";
|
||||
|
||||
import "api/messages.proto";
|
||||
import "google/api/annotations.proto";
|
||||
import "protoc-gen-swagger/options/annotations.proto";
|
||||
|
||||
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_swagger) = {
|
||||
info: {
|
||||
title: "Evaluator"
|
||||
version: "1.0"
|
||||
contact: {
|
||||
name: "Open Match"
|
||||
url: "https://open-match.dev"
|
||||
email: "open-match-discuss@googlegroups.com"
|
||||
}
|
||||
license: {
|
||||
name: "Apache 2.0 License"
|
||||
url: "https://github.com/googleforgames/open-match/blob/master/LICENSE"
|
||||
}
|
||||
}
|
||||
external_docs: {
|
||||
url: "https://open-match.dev/site/docs/"
|
||||
description: "Open Match Documentation"
|
||||
}
|
||||
schemes: HTTP
|
||||
schemes: HTTPS
|
||||
consumes: "application/json"
|
||||
produces: "application/json"
|
||||
responses: {
|
||||
key: "404"
|
||||
value: {
|
||||
description: "Returned when the resource does not exist."
|
||||
schema: { json_schema: { type: STRING } }
|
||||
}
|
||||
}
|
||||
// TODO Add annotations for security_defintiions.
|
||||
// See
|
||||
// https://github.com/grpc-ecosystem/grpc-gateway/blob/master/examples/proto/examplepb/a_bit_of_everything.proto
|
||||
};
|
||||
|
||||
message EvaluateRequest {
|
||||
// List of Matches to evaluate.
|
||||
repeated Match match = 1;
|
||||
}
|
||||
|
||||
message EvaluateResponse {
|
||||
// Accepted list of Matches.
|
||||
repeated Match match = 1;
|
||||
}
|
||||
|
||||
// The service implementing the Evaluator API that is called to evaluate
|
||||
// matches generated by MMFs and shortlist them to accepted results.
|
||||
service Evaluator {
|
||||
// Evaluate accepts a list of proposed matches, evaluates them for quality,
|
||||
// collisions etc. and returns matches that should be accepted as results.
|
||||
rpc Evaluate(EvaluateRequest) returns (EvaluateResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/v1/evaluator/matches:evaluate"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
}
|
246
api/evaluator.swagger.json
Normal file
246
api/evaluator.swagger.json
Normal file
@ -0,0 +1,246 @@
|
||||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"title": "Evaluator",
|
||||
"version": "1.0",
|
||||
"contact": {
|
||||
"name": "Open Match",
|
||||
"url": "https://open-match.dev",
|
||||
"email": "open-match-discuss@googlegroups.com"
|
||||
},
|
||||
"license": {
|
||||
"name": "Apache 2.0 License",
|
||||
"url": "https://github.com/googleforgames/open-match/blob/master/LICENSE"
|
||||
}
|
||||
},
|
||||
"schemes": [
|
||||
"http",
|
||||
"https"
|
||||
],
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"paths": {
|
||||
"/v1/evaluator/matches:evaluate": {
|
||||
"post": {
|
||||
"summary": "Evaluate accepts a list of proposed matches, evaluates them for quality,\ncollisions etc. and returns matches that should be accepted as results.",
|
||||
"operationId": "Evaluate",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/apiEvaluateResponse"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Returned when the resource does not exist.",
|
||||
"schema": {
|
||||
"format": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/apiEvaluateRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"Evaluator"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"apiAssignment": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"connection": {
|
||||
"type": "string",
|
||||
"description": "Connection information for this Assignment."
|
||||
},
|
||||
"properties": {
|
||||
"type": "string",
|
||||
"description": "Other details to be sent to the players. (Optional)\nOpen Match does not interpret these properties."
|
||||
},
|
||||
"error": {
|
||||
"type": "string",
|
||||
"description": "Error when finding an Assignment for this Ticket."
|
||||
}
|
||||
},
|
||||
"description": "An Assignment object represents the assignment associated with a Ticket."
|
||||
},
|
||||
"apiEvaluateRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"match": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/apiMatch"
|
||||
},
|
||||
"description": "List of Matches to evaluate."
|
||||
}
|
||||
}
|
||||
},
|
||||
"apiEvaluateResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"match": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/apiMatch"
|
||||
},
|
||||
"description": "Accepted list of Matches."
|
||||
}
|
||||
}
|
||||
},
|
||||
"apiMatch": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"match_id": {
|
||||
"type": "string",
|
||||
"description": "A Match ID that should be passed through the stack for tracing."
|
||||
},
|
||||
"match_profile": {
|
||||
"type": "string",
|
||||
"description": "Name of the match profile that generated this Match."
|
||||
},
|
||||
"match_function": {
|
||||
"type": "string",
|
||||
"description": "Name of the match function that generated this Match."
|
||||
},
|
||||
"ticket": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/apiTicket"
|
||||
},
|
||||
"description": "Tickets belonging to this match."
|
||||
},
|
||||
"roster": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/apiRoster"
|
||||
},
|
||||
"title": "Set of Rosters that comprise this Match"
|
||||
},
|
||||
"properties": {
|
||||
"$ref": "#/definitions/protobufStruct",
|
||||
"description": "Match properties for this Match. Open Match does not interpret this field."
|
||||
}
|
||||
},
|
||||
"description": "A Match is used to represent a completed match object. It can be generated by\na MatchFunction as a proposal or can be returned by OpenMatch as a result in\nresponse to the FetchMatches call."
|
||||
},
|
||||
"apiRoster": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "A developer-chosen human-readable name for this Roster."
|
||||
},
|
||||
"ticket_id": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "Tickets belonging to this Roster."
|
||||
}
|
||||
},
|
||||
"description": "A Roster is a named collection of Ticket IDs. It exists so that a Tickets\nassociated with a Match can be labelled to belong to a team, sub-team etc. It\ncan also be used to represent the current state of a Match in scenarios such\nas backfill, join-in-progress etc."
|
||||
},
|
||||
"apiTicket": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"description": "The Ticket ID generated by Open Match."
|
||||
},
|
||||
"properties": {
|
||||
"$ref": "#/definitions/protobufStruct",
|
||||
"description": "Properties contains custom info about the ticket. Top level values can be\nused in indexing and filtering to find tickets."
|
||||
},
|
||||
"assignment": {
|
||||
"$ref": "#/definitions/apiAssignment",
|
||||
"description": "Assignment associated with the Ticket."
|
||||
}
|
||||
},
|
||||
"description": "A Ticket is a basic matchmaking entity in Open Match. In order to enter\nmatchmaking using Open Match, the client should generate a Ticket, passing in\nthe properties to be associated with this Ticket. Open Match will generate an\nID for a Ticket during creation. A Ticket could be used to represent an\nindividual 'Player' or a 'Group' of players. Open Match will not interpret\nwhat the Ticket represents but just treat it as a matchmaking unit with a set\nof properties. Open Match stores the Ticket in state storage and enables an\nAssignment to be associated with this Ticket."
|
||||
},
|
||||
"protobufListValue": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"values": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/protobufValue"
|
||||
},
|
||||
"description": "Repeated field of dynamically typed values."
|
||||
}
|
||||
},
|
||||
"description": "`ListValue` is a wrapper around a repeated field of values.\n\nThe JSON representation for `ListValue` is JSON array."
|
||||
},
|
||||
"protobufNullValue": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"NULL_VALUE"
|
||||
],
|
||||
"default": "NULL_VALUE",
|
||||
"description": "`NullValue` is a singleton enumeration to represent the null value for the\n`Value` type union.\n\n The JSON representation for `NullValue` is JSON `null`.\n\n - NULL_VALUE: Null value."
|
||||
},
|
||||
"protobufStruct": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"fields": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"$ref": "#/definitions/protobufValue"
|
||||
},
|
||||
"description": "Unordered map of dynamically typed values."
|
||||
}
|
||||
},
|
||||
"description": "`Struct` represents a structured data value, consisting of fields\nwhich map to dynamically typed values. In some languages, `Struct`\nmight be supported by a native representation. For example, in\nscripting languages like JS a struct is represented as an\nobject. The details of that representation are described together\nwith the proto support for the language.\n\nThe JSON representation for `Struct` is JSON object."
|
||||
},
|
||||
"protobufValue": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"null_value": {
|
||||
"$ref": "#/definitions/protobufNullValue",
|
||||
"description": "Represents a null value."
|
||||
},
|
||||
"number_value": {
|
||||
"type": "number",
|
||||
"format": "double",
|
||||
"description": "Represents a double value."
|
||||
},
|
||||
"string_value": {
|
||||
"type": "string",
|
||||
"description": "Represents a string value."
|
||||
},
|
||||
"bool_value": {
|
||||
"type": "boolean",
|
||||
"format": "boolean",
|
||||
"description": "Represents a boolean value."
|
||||
},
|
||||
"struct_value": {
|
||||
"$ref": "#/definitions/protobufStruct",
|
||||
"description": "Represents a structured value."
|
||||
},
|
||||
"list_value": {
|
||||
"$ref": "#/definitions/protobufListValue",
|
||||
"description": "Represents a repeated `Value`."
|
||||
}
|
||||
},
|
||||
"description": "`Value` represents a dynamically typed value which can be either\nnull, a number, a string, a boolean, a recursive struct value, or a\nlist of values. A producer of value is expected to set one of that\nvariants, absence of any variant indicates an error.\n\nThe JSON representation for `Value` is JSON value."
|
||||
}
|
||||
},
|
||||
"externalDocs": {
|
||||
"description": "Open Match Documentation",
|
||||
"url": "https://open-match.dev/site/docs/"
|
||||
}
|
||||
}
|
@ -62,12 +62,15 @@ message GetContextResponse {
|
||||
string context_id = 1;
|
||||
}
|
||||
|
||||
message EvaluateRequest {
|
||||
// List of Matches to evaluate.
|
||||
message EvaluateInContextRequest {
|
||||
// List of Matches to evaluate in the given context.
|
||||
repeated Match match = 1;
|
||||
|
||||
// Context in which these matches should be evaluated.
|
||||
string context_id = 2;
|
||||
}
|
||||
|
||||
message EvaluateResponse {
|
||||
message EvaluateInContextResponse {
|
||||
// Accepted list of Matches.
|
||||
repeated Match match = 1;
|
||||
}
|
||||
@ -85,10 +88,13 @@ service Synchronizer {
|
||||
};
|
||||
}
|
||||
|
||||
// Evaluate accepts a list of matches, triggers the user configured evaluation
|
||||
// function with these and other matches in the evaluation window and returns
|
||||
// matches that are accepted by the Evaluator as valid results.
|
||||
rpc Evaluate(EvaluateRequest) returns (EvaluateResponse) {
|
||||
// EvaluateInContext accepts a list of matches and a context in which these
|
||||
// matches should be evaluated. If the context has expired (not present in
|
||||
// the current evaluation window) this method fails otherwise the matches are
|
||||
// added to the list of matches to be evaluated in the current evaluation
|
||||
// window. At the end of the window, the user defined evaluation method is
|
||||
// triggered and the matches accepted by it are returned as results.
|
||||
rpc EvaluateInContext(EvaluateInContextRequest) returns (EvaluateInContextResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/v1/synchronizer/matches:evaluate"
|
||||
body: "*"
|
||||
|
@ -49,13 +49,13 @@
|
||||
},
|
||||
"/v1/synchronizer/matches:evaluate": {
|
||||
"post": {
|
||||
"summary": "Evaluate accepts a list of matches, triggers the user configured evaluation\nfunction with these and other matches in the evaluation window and returns\nmatches that are accepted by the Evaluator as valid results.",
|
||||
"operationId": "Evaluate",
|
||||
"summary": "EvaluateInContext accepts a list of matches and a context in which these\nmatches should be evaluated. If the context has expired (not present in\nthe current evaluation window) this method fails otherwise the matches are\nadded to the list of matches to be evaluated in the current evaluation\nwindow. At the end of the window, the user defined evaluation method is\ntriggered and the matches accepted by it are returned as results.",
|
||||
"operationId": "EvaluateInContext",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/apiEvaluateResponse"
|
||||
"$ref": "#/definitions/apiEvaluateInContextResponse"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
@ -71,7 +71,7 @@
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/apiEvaluateRequest"
|
||||
"$ref": "#/definitions/apiEvaluateInContextRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
@ -100,7 +100,7 @@
|
||||
},
|
||||
"description": "An Assignment object represents the assignment associated with a Ticket."
|
||||
},
|
||||
"apiEvaluateRequest": {
|
||||
"apiEvaluateInContextRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"match": {
|
||||
@ -108,11 +108,15 @@
|
||||
"items": {
|
||||
"$ref": "#/definitions/apiMatch"
|
||||
},
|
||||
"description": "List of Matches to evaluate."
|
||||
"description": "List of Matches to evaluate in the given context."
|
||||
},
|
||||
"context_id": {
|
||||
"type": "string",
|
||||
"description": "Context in which these matches should be evaluated."
|
||||
}
|
||||
}
|
||||
},
|
||||
"apiEvaluateResponse": {
|
||||
"apiEvaluateInContextResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"match": {
|
||||
|
@ -157,6 +157,7 @@ artifacts:
|
||||
- cmd/minimatch/minimatch
|
||||
- cmd/swaggerui/swaggerui
|
||||
- examples/functions/golang/soloduel/soloduel
|
||||
- examples/evaluator/golang/simple/simple
|
||||
- tools/certgen/certgen
|
||||
- tools/reaper/reaper
|
||||
- install/yaml/install.yaml
|
||||
@ -174,6 +175,7 @@ images:
|
||||
- 'gcr.io/$PROJECT_ID/openmatch-minimatch:${_OM_VERSION}-${SHORT_SHA}'
|
||||
- 'gcr.io/$PROJECT_ID/openmatch-demo:${_OM_VERSION}-${SHORT_SHA}'
|
||||
- 'gcr.io/$PROJECT_ID/openmatch-mmf-go-soloduel:${_OM_VERSION}-${SHORT_SHA}'
|
||||
- 'gcr.io/$PROJECT_ID/openmatch-evaluator-go-simple:${_OM_VERSION}-${SHORT_SHA}'
|
||||
- 'gcr.io/$PROJECT_ID/openmatch-swaggerui:${_OM_VERSION}-${SHORT_SHA}'
|
||||
- 'gcr.io/$PROJECT_ID/openmatch-reaper:${_OM_VERSION}-${SHORT_SHA}'
|
||||
substitutions:
|
||||
|
23
examples/evaluator/golang/simple/Dockerfile
Normal file
23
examples/evaluator/golang/simple/Dockerfile
Normal file
@ -0,0 +1,23 @@
|
||||
# Copyright 2019 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FROM open-match-base-build as builder
|
||||
|
||||
WORKDIR /go/src/open-match.dev/open-match/examples/evaluator/golang/simple
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o simple .
|
||||
|
||||
FROM gcr.io/distroless/static
|
||||
COPY --from=builder /go/src/open-match.dev/open-match/examples/evaluator/golang/simple/simple .
|
||||
|
||||
ENTRYPOINT ["/simple"]
|
26
examples/evaluator/golang/simple/evaluator.go
Normal file
26
examples/evaluator/golang/simple/evaluator.go
Normal file
@ -0,0 +1,26 @@
|
||||
// Copyright 2019 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
package main
|
||||
|
||||
import (
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
"open-match.dev/open-match/internal/pb"
|
||||
harness "open-match.dev/open-match/pkg/harness/evaluator/golang"
|
||||
)
|
||||
|
||||
// Evaluate is where your custom evaluation logic lives.
|
||||
func Evaluate(p *harness.EvaluatorParams) ([]*pb.Match, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "not implemented")
|
||||
}
|
23
examples/evaluator/golang/simple/main.go
Normal file
23
examples/evaluator/golang/simple/main.go
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright 2019 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
package main
|
||||
|
||||
import (
|
||||
harness "open-match.dev/open-match/pkg/harness/evaluator/golang"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Invoke the harness to setup a GRPC service that handles requests to run the evaluator.
|
||||
harness.RunEvaluator(Evaluate)
|
||||
}
|
@ -22,7 +22,7 @@ package pool
|
||||
import (
|
||||
"github.com/rs/xid"
|
||||
"open-match.dev/open-match/internal/pb"
|
||||
mmfHarness "open-match.dev/open-match/pkg/harness/golang"
|
||||
mmfHarness "open-match.dev/open-match/pkg/harness/function/golang"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/stretchr/testify/assert"
|
||||
mmfHarness "open-match.dev/open-match/pkg/harness/golang"
|
||||
mmfHarness "open-match.dev/open-match/pkg/harness/function/golang"
|
||||
)
|
||||
|
||||
func TestMakeMatches(t *testing.T) {
|
||||
|
@ -20,7 +20,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
mmfHarness "open-match.dev/open-match/pkg/harness/golang"
|
||||
mmfHarness "open-match.dev/open-match/pkg/harness/function/golang"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -23,7 +23,7 @@ import (
|
||||
"time"
|
||||
|
||||
"open-match.dev/open-match/internal/pb"
|
||||
mmfHarness "open-match.dev/open-match/pkg/harness/golang"
|
||||
mmfHarness "open-match.dev/open-match/pkg/harness/function/golang"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/stretchr/testify/assert"
|
||||
mmfHarness "open-match.dev/open-match/pkg/harness/golang"
|
||||
mmfHarness "open-match.dev/open-match/pkg/harness/function/golang"
|
||||
)
|
||||
|
||||
func TestMakeMatchesDeduplicate(t *testing.T) {
|
||||
|
@ -126,7 +126,7 @@ func TestDoGetAssignments(t *testing.T) {
|
||||
}
|
||||
},
|
||||
wantCode: codes.Aborted,
|
||||
wantAssignments: []*pb.Assignment{&pb.Assignment{Connection: "1"}, &pb.Assignment{Connection: "2"}},
|
||||
wantAssignments: []*pb.Assignment{{Connection: "1"}, {Connection: "2"}},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -39,9 +39,12 @@ func (s *synchronizerService) GetContext(ctx context.Context, req *pb.GetContext
|
||||
return nil, status.Error(codes.Unimplemented, "not implemented")
|
||||
}
|
||||
|
||||
// Evaluate accepts a list of matches, triggers the user configured evaluation
|
||||
// function with these and other matches in the evaluation window and returns
|
||||
// matches that are accepted by the Evaluator as valid results.
|
||||
func (s *synchronizerService) Evaluate(ctx context.Context, req *pb.EvaluateRequest) (*pb.EvaluateResponse, error) {
|
||||
// EvaluateInContext accepts a list of matches and a context in which these
|
||||
// matches should be evaluated. If the context has expired (not present in
|
||||
// the current evaluation window) this method fails otherwise the matches are
|
||||
// added to the list of matches to be evaluated in the current evaluation
|
||||
// window. At the end of the window, the user defined evaluation method is
|
||||
// triggered and the matches accepted by it are returned as results.
|
||||
func (s *synchronizerService) EvaluateInContext(ctx context.Context, req *pb.EvaluateInContextRequest) (*pb.EvaluateInContextResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "not implemented")
|
||||
}
|
||||
|
221
internal/pb/evaluator.pb.go
Normal file
221
internal/pb/evaluator.pb.go
Normal file
@ -0,0 +1,221 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: api/evaluator.proto
|
||||
|
||||
package pb
|
||||
|
||||
import (
|
||||
context "context"
|
||||
fmt "fmt"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
_ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options"
|
||||
_ "google.golang.org/genproto/googleapis/api/annotations"
|
||||
grpc "google.golang.org/grpc"
|
||||
math "math"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
type EvaluateRequest struct {
|
||||
// List of Matches to evaluate.
|
||||
Match []*Match `protobuf:"bytes,1,rep,name=match,proto3" json:"match,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *EvaluateRequest) Reset() { *m = EvaluateRequest{} }
|
||||
func (m *EvaluateRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*EvaluateRequest) ProtoMessage() {}
|
||||
func (*EvaluateRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_8c58cb7dff9acb0f, []int{0}
|
||||
}
|
||||
|
||||
func (m *EvaluateRequest) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_EvaluateRequest.Unmarshal(m, b)
|
||||
}
|
||||
func (m *EvaluateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_EvaluateRequest.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *EvaluateRequest) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_EvaluateRequest.Merge(m, src)
|
||||
}
|
||||
func (m *EvaluateRequest) XXX_Size() int {
|
||||
return xxx_messageInfo_EvaluateRequest.Size(m)
|
||||
}
|
||||
func (m *EvaluateRequest) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_EvaluateRequest.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_EvaluateRequest proto.InternalMessageInfo
|
||||
|
||||
func (m *EvaluateRequest) GetMatch() []*Match {
|
||||
if m != nil {
|
||||
return m.Match
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type EvaluateResponse struct {
|
||||
// Accepted list of Matches.
|
||||
Match []*Match `protobuf:"bytes,1,rep,name=match,proto3" json:"match,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *EvaluateResponse) Reset() { *m = EvaluateResponse{} }
|
||||
func (m *EvaluateResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*EvaluateResponse) ProtoMessage() {}
|
||||
func (*EvaluateResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_8c58cb7dff9acb0f, []int{1}
|
||||
}
|
||||
|
||||
func (m *EvaluateResponse) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_EvaluateResponse.Unmarshal(m, b)
|
||||
}
|
||||
func (m *EvaluateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_EvaluateResponse.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *EvaluateResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_EvaluateResponse.Merge(m, src)
|
||||
}
|
||||
func (m *EvaluateResponse) XXX_Size() int {
|
||||
return xxx_messageInfo_EvaluateResponse.Size(m)
|
||||
}
|
||||
func (m *EvaluateResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_EvaluateResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_EvaluateResponse proto.InternalMessageInfo
|
||||
|
||||
func (m *EvaluateResponse) GetMatch() []*Match {
|
||||
if m != nil {
|
||||
return m.Match
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*EvaluateRequest)(nil), "api.EvaluateRequest")
|
||||
proto.RegisterType((*EvaluateResponse)(nil), "api.EvaluateResponse")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("api/evaluator.proto", fileDescriptor_8c58cb7dff9acb0f) }
|
||||
|
||||
var fileDescriptor_8c58cb7dff9acb0f = []byte{
|
||||
// 453 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x52, 0x4d, 0x6f, 0xd4, 0x30,
|
||||
0x10, 0x55, 0xb2, 0x50, 0xc0, 0x3d, 0x50, 0x99, 0x0f, 0x55, 0x2b, 0x84, 0x4c, 0x7a, 0x81, 0x15,
|
||||
0x1b, 0xb7, 0xe9, 0x9e, 0x16, 0x21, 0xb5, 0xc0, 0x1e, 0x2a, 0x15, 0x90, 0x16, 0x89, 0x03, 0x37,
|
||||
0xc7, 0x19, 0x12, 0xa3, 0xc4, 0x63, 0x3c, 0xce, 0x96, 0x33, 0x3f, 0x01, 0x6e, 0xfc, 0x0d, 0x7e,
|
||||
0x0a, 0x37, 0xce, 0xdc, 0xf8, 0x13, 0x28, 0x09, 0xab, 0xad, 0x5a, 0x24, 0x4e, 0x96, 0xdf, 0x7b,
|
||||
0x33, 0x6f, 0xfc, 0x3c, 0xec, 0x96, 0x72, 0x46, 0xc2, 0x4a, 0xd5, 0xad, 0x0a, 0xe8, 0x53, 0xe7,
|
||||
0x31, 0x20, 0x1f, 0x29, 0x67, 0xc6, 0xbc, 0x63, 0x1a, 0x20, 0x52, 0x25, 0xd0, 0x40, 0x8c, 0xef,
|
||||
0x95, 0x88, 0x65, 0x0d, 0xb2, 0xa3, 0x94, 0xb5, 0x18, 0x54, 0x30, 0x68, 0xd7, 0xec, 0xe3, 0xfe,
|
||||
0xd0, 0xd3, 0x12, 0xec, 0x94, 0xce, 0x54, 0x59, 0x82, 0x97, 0xe8, 0x7a, 0xc5, 0x65, 0x75, 0x72,
|
||||
0xc8, 0x6e, 0x2e, 0x06, 0x5f, 0x58, 0xc2, 0xc7, 0x16, 0x28, 0x70, 0xc1, 0xae, 0x36, 0x2a, 0xe8,
|
||||
0x6a, 0x37, 0x12, 0xa3, 0x87, 0xdb, 0x19, 0x4b, 0x95, 0x33, 0xe9, 0xcb, 0x0e, 0x59, 0x0e, 0x44,
|
||||
0x32, 0x63, 0x3b, 0x9b, 0x22, 0x72, 0x68, 0x09, 0xfe, 0x5f, 0x95, 0x21, 0xbb, 0xb1, 0x58, 0x3f,
|
||||
0x91, 0xe7, 0xec, 0xfa, 0xba, 0x05, 0xbf, 0xdd, 0x6b, 0x2f, 0x8c, 0x31, 0xbe, 0x73, 0x01, 0x1d,
|
||||
0x7c, 0x92, 0x47, 0x9f, 0x7f, 0xfc, 0xfa, 0x1a, 0xef, 0x25, 0xf7, 0xe5, 0xea, 0x60, 0x13, 0x99,
|
||||
0xec, 0x2d, 0x80, 0xe6, 0x7f, 0x11, 0x98, 0x47, 0x93, 0x67, 0xbf, 0xe3, 0x2f, 0xc7, 0x3f, 0x63,
|
||||
0xfe, 0x3d, 0x3a, 0x67, 0x9c, 0x9c, 0x30, 0xf6, 0xda, 0x81, 0x15, 0xfd, 0x68, 0xfc, 0x6e, 0x15,
|
||||
0x82, 0xa3, 0xb9, 0x94, 0xe8, 0xc0, 0x4e, 0xfb, 0x26, 0x69, 0x01, 0xab, 0xf1, 0xde, 0xe6, 0x3e,
|
||||
0x2d, 0x0c, 0xe9, 0x96, 0xe8, 0x68, 0x48, 0xbd, 0xf4, 0xd8, 0x3a, 0x4a, 0x35, 0x36, 0x93, 0xb7,
|
||||
0x8c, 0x1f, 0x3b, 0xa5, 0x2b, 0x10, 0x59, 0xba, 0x2f, 0x4e, 0x8d, 0x86, 0x2e, 0x88, 0xa3, 0x75,
|
||||
0xcb, 0xd2, 0x84, 0xaa, 0xcd, 0x3b, 0xa5, 0x1c, 0x4a, 0xdf, 0xa3, 0x2f, 0x55, 0x03, 0x74, 0xce,
|
||||
0x4c, 0xe6, 0x35, 0xe6, 0xb2, 0x51, 0x14, 0xc0, 0xcb, 0xd3, 0x93, 0xe7, 0x8b, 0x57, 0x6f, 0x16,
|
||||
0xd9, 0xe8, 0x20, 0xdd, 0x9f, 0xc4, 0x51, 0x9c, 0xed, 0x28, 0xe7, 0x6a, 0xa3, 0xfb, 0x0f, 0x93,
|
||||
0x1f, 0x08, 0xed, 0xfc, 0x12, 0xb2, 0x7c, 0xc2, 0x46, 0xb3, 0xfd, 0x19, 0x9f, 0xb1, 0xc9, 0x12,
|
||||
0x42, 0xeb, 0x2d, 0x14, 0xe2, 0xac, 0x02, 0x2b, 0x42, 0x05, 0xc2, 0x03, 0x61, 0xeb, 0x35, 0x88,
|
||||
0x02, 0x81, 0x84, 0xc5, 0x20, 0xe0, 0x93, 0xa1, 0x90, 0xf2, 0x2d, 0x76, 0xe5, 0x5b, 0x1c, 0x5d,
|
||||
0xf3, 0x4f, 0xd9, 0xee, 0x26, 0x0c, 0xf1, 0x02, 0x75, 0xdb, 0x80, 0x1d, 0x16, 0x84, 0x3f, 0xf8,
|
||||
0x77, 0x34, 0x92, 0x4c, 0x00, 0x59, 0xa0, 0x26, 0xf9, 0x6e, 0xdb, 0xd8, 0x00, 0xde, 0xaa, 0x5a,
|
||||
0xba, 0x3c, 0xdf, 0xea, 0x17, 0xea, 0xf0, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x5d, 0xff, 0xc7,
|
||||
0x1f, 0xcc, 0x02, 0x00, 0x00,
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ context.Context
|
||||
var _ grpc.ClientConn
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
const _ = grpc.SupportPackageIsVersion4
|
||||
|
||||
// EvaluatorClient is the client API for Evaluator service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
|
||||
type EvaluatorClient interface {
|
||||
// Evaluate accepts a list of proposed matches, evaluates them for quality,
|
||||
// collisions etc. and returns matches that should be accepted as results.
|
||||
Evaluate(ctx context.Context, in *EvaluateRequest, opts ...grpc.CallOption) (*EvaluateResponse, error)
|
||||
}
|
||||
|
||||
type evaluatorClient struct {
|
||||
cc *grpc.ClientConn
|
||||
}
|
||||
|
||||
func NewEvaluatorClient(cc *grpc.ClientConn) EvaluatorClient {
|
||||
return &evaluatorClient{cc}
|
||||
}
|
||||
|
||||
func (c *evaluatorClient) Evaluate(ctx context.Context, in *EvaluateRequest, opts ...grpc.CallOption) (*EvaluateResponse, error) {
|
||||
out := new(EvaluateResponse)
|
||||
err := c.cc.Invoke(ctx, "/api.Evaluator/Evaluate", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// EvaluatorServer is the server API for Evaluator service.
|
||||
type EvaluatorServer interface {
|
||||
// Evaluate accepts a list of proposed matches, evaluates them for quality,
|
||||
// collisions etc. and returns matches that should be accepted as results.
|
||||
Evaluate(context.Context, *EvaluateRequest) (*EvaluateResponse, error)
|
||||
}
|
||||
|
||||
func RegisterEvaluatorServer(s *grpc.Server, srv EvaluatorServer) {
|
||||
s.RegisterService(&_Evaluator_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _Evaluator_Evaluate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(EvaluateRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(EvaluatorServer).Evaluate(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/api.Evaluator/Evaluate",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(EvaluatorServer).Evaluate(ctx, req.(*EvaluateRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _Evaluator_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "api.Evaluator",
|
||||
HandlerType: (*EvaluatorServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Evaluate",
|
||||
Handler: _Evaluator_Evaluate_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "api/evaluator.proto",
|
||||
}
|
115
internal/pb/evaluator.pb.gw.go
Normal file
115
internal/pb/evaluator.pb.gw.go
Normal file
@ -0,0 +1,115 @@
|
||||
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
|
||||
// source: api/evaluator.proto
|
||||
|
||||
/*
|
||||
Package pb is a reverse proxy.
|
||||
|
||||
It translates gRPC into RESTful JSON APIs.
|
||||
*/
|
||||
package pb
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/utilities"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
var _ codes.Code
|
||||
var _ io.Reader
|
||||
var _ status.Status
|
||||
var _ = runtime.String
|
||||
var _ = utilities.NewDoubleArray
|
||||
|
||||
func request_Evaluator_Evaluate_0(ctx context.Context, marshaler runtime.Marshaler, client EvaluatorClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq EvaluateRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||
if berr != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
|
||||
}
|
||||
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.Evaluate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
// RegisterEvaluatorHandlerFromEndpoint is same as RegisterEvaluatorHandler but
|
||||
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
|
||||
func RegisterEvaluatorHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
|
||||
conn, err := grpc.Dial(endpoint, opts...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
if err != nil {
|
||||
if cerr := conn.Close(); cerr != nil {
|
||||
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
|
||||
}
|
||||
return
|
||||
}
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
if cerr := conn.Close(); cerr != nil {
|
||||
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
|
||||
}
|
||||
}()
|
||||
}()
|
||||
|
||||
return RegisterEvaluatorHandler(ctx, mux, conn)
|
||||
}
|
||||
|
||||
// RegisterEvaluatorHandler registers the http handlers for service Evaluator to "mux".
|
||||
// The handlers forward requests to the grpc endpoint over "conn".
|
||||
func RegisterEvaluatorHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
|
||||
return RegisterEvaluatorHandlerClient(ctx, mux, NewEvaluatorClient(conn))
|
||||
}
|
||||
|
||||
// RegisterEvaluatorHandlerClient registers the http handlers for service Evaluator
|
||||
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "EvaluatorClient".
|
||||
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "EvaluatorClient"
|
||||
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
|
||||
// "EvaluatorClient" to call the correct interceptors.
|
||||
func RegisterEvaluatorHandlerClient(ctx context.Context, mux *runtime.ServeMux, client EvaluatorClient) error {
|
||||
|
||||
mux.Handle("POST", pattern_Evaluator_Evaluate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Evaluator_Evaluate_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Evaluator_Evaluate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_Evaluator_Evaluate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "evaluator", "matches"}, "evaluate"))
|
||||
)
|
||||
|
||||
var (
|
||||
forward_Evaluator_Evaluate_0 = runtime.ForwardResponseMessage
|
||||
)
|
@ -95,47 +95,56 @@ func (m *GetContextResponse) GetContextId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
type EvaluateRequest struct {
|
||||
// List of Matches to evaluate.
|
||||
Match []*Match `protobuf:"bytes,1,rep,name=match,proto3" json:"match,omitempty"`
|
||||
type EvaluateInContextRequest struct {
|
||||
// List of Matches to evaluate in the given context.
|
||||
Match []*Match `protobuf:"bytes,1,rep,name=match,proto3" json:"match,omitempty"`
|
||||
// Context in which these matches should be evaluated.
|
||||
ContextId string `protobuf:"bytes,2,opt,name=context_id,json=contextId,proto3" json:"context_id,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *EvaluateRequest) Reset() { *m = EvaluateRequest{} }
|
||||
func (m *EvaluateRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*EvaluateRequest) ProtoMessage() {}
|
||||
func (*EvaluateRequest) Descriptor() ([]byte, []int) {
|
||||
func (m *EvaluateInContextRequest) Reset() { *m = EvaluateInContextRequest{} }
|
||||
func (m *EvaluateInContextRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*EvaluateInContextRequest) ProtoMessage() {}
|
||||
func (*EvaluateInContextRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_9dbd55595bca25da, []int{2}
|
||||
}
|
||||
|
||||
func (m *EvaluateRequest) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_EvaluateRequest.Unmarshal(m, b)
|
||||
func (m *EvaluateInContextRequest) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_EvaluateInContextRequest.Unmarshal(m, b)
|
||||
}
|
||||
func (m *EvaluateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_EvaluateRequest.Marshal(b, m, deterministic)
|
||||
func (m *EvaluateInContextRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_EvaluateInContextRequest.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *EvaluateRequest) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_EvaluateRequest.Merge(m, src)
|
||||
func (m *EvaluateInContextRequest) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_EvaluateInContextRequest.Merge(m, src)
|
||||
}
|
||||
func (m *EvaluateRequest) XXX_Size() int {
|
||||
return xxx_messageInfo_EvaluateRequest.Size(m)
|
||||
func (m *EvaluateInContextRequest) XXX_Size() int {
|
||||
return xxx_messageInfo_EvaluateInContextRequest.Size(m)
|
||||
}
|
||||
func (m *EvaluateRequest) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_EvaluateRequest.DiscardUnknown(m)
|
||||
func (m *EvaluateInContextRequest) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_EvaluateInContextRequest.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_EvaluateRequest proto.InternalMessageInfo
|
||||
var xxx_messageInfo_EvaluateInContextRequest proto.InternalMessageInfo
|
||||
|
||||
func (m *EvaluateRequest) GetMatch() []*Match {
|
||||
func (m *EvaluateInContextRequest) GetMatch() []*Match {
|
||||
if m != nil {
|
||||
return m.Match
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type EvaluateResponse struct {
|
||||
func (m *EvaluateInContextRequest) GetContextId() string {
|
||||
if m != nil {
|
||||
return m.ContextId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type EvaluateInContextResponse struct {
|
||||
// Accepted list of Matches.
|
||||
Match []*Match `protobuf:"bytes,1,rep,name=match,proto3" json:"match,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
@ -143,32 +152,32 @@ type EvaluateResponse struct {
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *EvaluateResponse) Reset() { *m = EvaluateResponse{} }
|
||||
func (m *EvaluateResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*EvaluateResponse) ProtoMessage() {}
|
||||
func (*EvaluateResponse) Descriptor() ([]byte, []int) {
|
||||
func (m *EvaluateInContextResponse) Reset() { *m = EvaluateInContextResponse{} }
|
||||
func (m *EvaluateInContextResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*EvaluateInContextResponse) ProtoMessage() {}
|
||||
func (*EvaluateInContextResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_9dbd55595bca25da, []int{3}
|
||||
}
|
||||
|
||||
func (m *EvaluateResponse) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_EvaluateResponse.Unmarshal(m, b)
|
||||
func (m *EvaluateInContextResponse) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_EvaluateInContextResponse.Unmarshal(m, b)
|
||||
}
|
||||
func (m *EvaluateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_EvaluateResponse.Marshal(b, m, deterministic)
|
||||
func (m *EvaluateInContextResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_EvaluateInContextResponse.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *EvaluateResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_EvaluateResponse.Merge(m, src)
|
||||
func (m *EvaluateInContextResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_EvaluateInContextResponse.Merge(m, src)
|
||||
}
|
||||
func (m *EvaluateResponse) XXX_Size() int {
|
||||
return xxx_messageInfo_EvaluateResponse.Size(m)
|
||||
func (m *EvaluateInContextResponse) XXX_Size() int {
|
||||
return xxx_messageInfo_EvaluateInContextResponse.Size(m)
|
||||
}
|
||||
func (m *EvaluateResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_EvaluateResponse.DiscardUnknown(m)
|
||||
func (m *EvaluateInContextResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_EvaluateInContextResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_EvaluateResponse proto.InternalMessageInfo
|
||||
var xxx_messageInfo_EvaluateInContextResponse proto.InternalMessageInfo
|
||||
|
||||
func (m *EvaluateResponse) GetMatch() []*Match {
|
||||
func (m *EvaluateInContextResponse) GetMatch() []*Match {
|
||||
if m != nil {
|
||||
return m.Match
|
||||
}
|
||||
@ -178,47 +187,48 @@ func (m *EvaluateResponse) GetMatch() []*Match {
|
||||
func init() {
|
||||
proto.RegisterType((*GetContextRequest)(nil), "api.GetContextRequest")
|
||||
proto.RegisterType((*GetContextResponse)(nil), "api.GetContextResponse")
|
||||
proto.RegisterType((*EvaluateRequest)(nil), "api.EvaluateRequest")
|
||||
proto.RegisterType((*EvaluateResponse)(nil), "api.EvaluateResponse")
|
||||
proto.RegisterType((*EvaluateInContextRequest)(nil), "api.EvaluateInContextRequest")
|
||||
proto.RegisterType((*EvaluateInContextResponse)(nil), "api.EvaluateInContextResponse")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("api/synchronizer.proto", fileDescriptor_9dbd55595bca25da) }
|
||||
|
||||
var fileDescriptor_9dbd55595bca25da = []byte{
|
||||
// 527 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0x41, 0x8b, 0xd3, 0x40,
|
||||
0x18, 0x25, 0xa9, 0xae, 0xee, 0xac, 0xe0, 0x3a, 0x6a, 0x2d, 0x41, 0x61, 0x36, 0x82, 0x2c, 0x65,
|
||||
0x9b, 0xe9, 0xb6, 0x3d, 0x55, 0x84, 0x5d, 0xd7, 0x22, 0x85, 0x55, 0xa1, 0x0b, 0x1e, 0xbc, 0x2c,
|
||||
0xd3, 0xc9, 0x67, 0x32, 0xd2, 0xcc, 0x8c, 0x33, 0x93, 0xee, 0xea, 0xd1, 0x9f, 0xa0, 0x37, 0x7f,
|
||||
0x88, 0x7f, 0x44, 0xf0, 0xe6, 0xcd, 0xb3, 0xbf, 0x41, 0x9a, 0xa4, 0xb4, 0x36, 0x82, 0xa7, 0x90,
|
||||
0xf7, 0xe6, 0xbd, 0x6f, 0xde, 0xcb, 0x17, 0xd4, 0x64, 0x5a, 0x50, 0xfb, 0x41, 0xf2, 0xd4, 0x28,
|
||||
0x29, 0x3e, 0x82, 0x89, 0xb4, 0x51, 0x4e, 0xe1, 0x06, 0xd3, 0x22, 0xc0, 0x0b, 0x32, 0x03, 0x6b,
|
||||
0x59, 0x02, 0xb6, 0x24, 0x82, 0xfb, 0x89, 0x52, 0xc9, 0x0c, 0xe8, 0x82, 0x62, 0x52, 0x2a, 0xc7,
|
||||
0x9c, 0x50, 0x72, 0xc9, 0x1e, 0x14, 0x0f, 0xde, 0x49, 0x40, 0x76, 0xec, 0x05, 0x4b, 0x12, 0x30,
|
||||
0x54, 0xe9, 0xe2, 0x44, 0xfd, 0x74, 0x78, 0x1b, 0xdd, 0x7a, 0x0e, 0xee, 0x44, 0x49, 0x07, 0x97,
|
||||
0x6e, 0x02, 0xef, 0x73, 0xb0, 0x2e, 0xec, 0x23, 0xbc, 0x0e, 0x5a, 0xad, 0xa4, 0x05, 0xfc, 0x00,
|
||||
0x21, 0x5e, 0x42, 0xe7, 0x22, 0x6e, 0x79, 0xc4, 0xdb, 0xdf, 0x9e, 0x6c, 0x57, 0xc8, 0x38, 0x0e,
|
||||
0xfb, 0xe8, 0xe6, 0x68, 0xce, 0x66, 0x39, 0x73, 0x50, 0xf9, 0x60, 0x82, 0xae, 0x66, 0xcc, 0xf1,
|
||||
0xb4, 0xe5, 0x91, 0xc6, 0xfe, 0x4e, 0x0f, 0x45, 0x4c, 0x8b, 0xe8, 0xc5, 0x02, 0x99, 0x94, 0x44,
|
||||
0x38, 0x40, 0xbb, 0x2b, 0x51, 0x35, 0xe7, 0xbf, 0xaa, 0xde, 0x0f, 0x0f, 0xdd, 0x38, 0x5b, 0x2b,
|
||||
0x0c, 0x9f, 0x23, 0xb4, 0xba, 0x30, 0x6e, 0x16, 0x8a, 0x5a, 0xac, 0xe0, 0x5e, 0x0d, 0x2f, 0x27,
|
||||
0x86, 0xe4, 0xd3, 0xf7, 0x5f, 0x5f, 0xfc, 0x00, 0xb7, 0xe8, 0xfc, 0xf0, 0xaf, 0x2f, 0x41, 0xab,
|
||||
0x78, 0x18, 0xd0, 0xf5, 0xe5, 0x3d, 0xf1, 0x9d, 0xc2, 0x66, 0x23, 0x6b, 0x70, 0x77, 0x03, 0xad,
|
||||
0xac, 0x0f, 0x0a, 0xeb, 0x47, 0xe1, 0x5e, 0xcd, 0xba, 0x88, 0x02, 0x76, 0x08, 0x95, 0x64, 0xe8,
|
||||
0xb5, 0x9f, 0xfe, 0xf6, 0x3f, 0x1f, 0xff, 0xf4, 0xf1, 0xb7, 0x8d, 0x7c, 0xe1, 0x18, 0xa1, 0x57,
|
||||
0x1a, 0x24, 0x29, 0x5a, 0xc0, 0xcd, 0xd4, 0x39, 0x6d, 0x87, 0x94, 0x2a, 0x0d, 0xb2, 0x53, 0xf8,
|
||||
0x44, 0x31, 0xcc, 0x83, 0x87, 0xab, 0xf7, 0x4e, 0x2c, 0x2c, 0xcf, 0xad, 0x3d, 0x2a, 0x57, 0x25,
|
||||
0x31, 0x2a, 0xd7, 0x36, 0xe2, 0x2a, 0x6b, 0xbf, 0x46, 0xf8, 0x58, 0x33, 0x9e, 0x02, 0xe9, 0x45,
|
||||
0x5d, 0x72, 0x2a, 0x38, 0x2c, 0x3a, 0x3f, 0x5a, 0x5a, 0x26, 0xc2, 0xa5, 0xf9, 0x74, 0x71, 0x92,
|
||||
0x96, 0xd2, 0xb7, 0xca, 0x24, 0x2c, 0x03, 0xbb, 0x36, 0x8c, 0x4e, 0x67, 0x6a, 0x4a, 0x33, 0x66,
|
||||
0x1d, 0x18, 0x7a, 0x3a, 0x3e, 0x19, 0xbd, 0x3c, 0x1b, 0xf5, 0x1a, 0x87, 0x51, 0xb7, 0xed, 0x7b,
|
||||
0x7e, 0x6f, 0x97, 0x69, 0x3d, 0x13, 0xbc, 0xd8, 0x32, 0xfa, 0xce, 0x2a, 0x39, 0xac, 0x21, 0x93,
|
||||
0xc7, 0xa8, 0x31, 0xe8, 0x0e, 0xf0, 0x00, 0xb5, 0x27, 0xe0, 0x72, 0x23, 0x21, 0x26, 0x17, 0x29,
|
||||
0x48, 0xe2, 0x52, 0x20, 0x06, 0xac, 0xca, 0x0d, 0x07, 0x12, 0x2b, 0xb0, 0x44, 0x2a, 0x47, 0xe0,
|
||||
0x52, 0x58, 0x17, 0xe1, 0x2d, 0x74, 0xe5, 0xab, 0xef, 0x5d, 0x33, 0x4f, 0x50, 0x6b, 0x55, 0x06,
|
||||
0x79, 0xa6, 0x78, 0x9e, 0x81, 0x2c, 0xb7, 0x1a, 0xef, 0xfd, 0xbb, 0x1a, 0x6a, 0x85, 0x03, 0x1a,
|
||||
0x2b, 0x6e, 0xe9, 0x9b, 0x1d, 0x21, 0x1d, 0x18, 0xc9, 0x66, 0x54, 0x4f, 0xa7, 0x5b, 0xc5, 0x5f,
|
||||
0xd0, 0xff, 0x13, 0x00, 0x00, 0xff, 0xff, 0x38, 0x5f, 0x08, 0x01, 0x84, 0x03, 0x00, 0x00,
|
||||
// 539 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0x41, 0x6f, 0xd3, 0x30,
|
||||
0x14, 0x56, 0x52, 0x18, 0x9a, 0xc7, 0x81, 0x19, 0x69, 0x94, 0x88, 0x21, 0x2f, 0x48, 0x68, 0xaa,
|
||||
0xd6, 0xb8, 0xeb, 0x7a, 0x2a, 0x9a, 0xb4, 0x31, 0x2a, 0x54, 0x69, 0x80, 0xd4, 0x49, 0x1c, 0xe0,
|
||||
0x30, 0xb9, 0xce, 0x23, 0x31, 0x6a, 0x6c, 0x63, 0x3b, 0xdd, 0xe0, 0x84, 0xf8, 0x09, 0x70, 0xe3,
|
||||
0x87, 0xf0, 0x47, 0x38, 0x73, 0xe3, 0xcc, 0x81, 0x5f, 0x80, 0x9a, 0x64, 0x6a, 0xd7, 0x6c, 0xe2,
|
||||
0x14, 0xe5, 0xfb, 0xde, 0xfb, 0xbe, 0xf7, 0x3e, 0xdb, 0x68, 0x83, 0x69, 0x41, 0xed, 0x47, 0xc9,
|
||||
0x53, 0xa3, 0xa4, 0xf8, 0x04, 0x26, 0xd2, 0x46, 0x39, 0x85, 0x1b, 0x4c, 0x8b, 0x00, 0xcf, 0xc8,
|
||||
0x0c, 0xac, 0x65, 0x09, 0xd8, 0x92, 0x08, 0x1e, 0x24, 0x4a, 0x25, 0x13, 0xa0, 0x33, 0x8a, 0x49,
|
||||
0xa9, 0x1c, 0x73, 0x42, 0xc9, 0x0b, 0x76, 0xa7, 0xf8, 0xf0, 0x76, 0x02, 0xb2, 0x6d, 0xcf, 0x58,
|
||||
0x92, 0x80, 0xa1, 0x4a, 0x17, 0x15, 0xf5, 0xea, 0xf0, 0x2e, 0x5a, 0x7f, 0x0e, 0xee, 0x48, 0x49,
|
||||
0x07, 0xe7, 0x6e, 0x04, 0x1f, 0x72, 0xb0, 0x2e, 0xdc, 0x43, 0x78, 0x11, 0xb4, 0x5a, 0x49, 0x0b,
|
||||
0x78, 0x13, 0x21, 0x5e, 0x42, 0xa7, 0x22, 0x6e, 0x7a, 0xc4, 0xdb, 0x5e, 0x1d, 0xad, 0x56, 0xc8,
|
||||
0x30, 0x0e, 0xdf, 0xa2, 0xe6, 0x60, 0xca, 0x26, 0x39, 0x73, 0x30, 0x94, 0x97, 0x05, 0x31, 0x41,
|
||||
0x37, 0x33, 0xe6, 0x78, 0xda, 0xf4, 0x48, 0x63, 0x7b, 0xad, 0x8b, 0x22, 0xa6, 0x45, 0xf4, 0x62,
|
||||
0x86, 0x8c, 0x4a, 0x62, 0x49, 0xdc, 0x5f, 0x16, 0xdf, 0x47, 0xf7, 0xaf, 0x10, 0xaf, 0x06, 0xfb,
|
||||
0xaf, 0x7a, 0xf7, 0xaf, 0x87, 0x6e, 0x9f, 0x2c, 0x24, 0x8c, 0x4f, 0x11, 0x9a, 0x6f, 0x88, 0x37,
|
||||
0x8a, 0x8e, 0x5a, 0x0e, 0xc1, 0xbd, 0x1a, 0x5e, 0x3a, 0x86, 0xe4, 0xcb, 0xcf, 0xdf, 0xdf, 0xfc,
|
||||
0x00, 0x37, 0xe9, 0x74, 0xf7, 0xd2, 0xd1, 0xd1, 0x6a, 0x64, 0xfc, 0xd9, 0x43, 0xeb, 0xb5, 0x89,
|
||||
0xf1, 0x66, 0x21, 0x78, 0x5d, 0x4c, 0xc1, 0xc3, 0xeb, 0xe8, 0xca, 0x76, 0xa7, 0xb0, 0x7d, 0x1c,
|
||||
0x6e, 0xd5, 0x6c, 0x8b, 0x35, 0xc1, 0xf6, 0xa1, 0xea, 0xed, 0x7b, 0xad, 0xa7, 0x7f, 0xfc, 0xaf,
|
||||
0x87, 0xbf, 0x7c, 0xfc, 0x63, 0x69, 0xf7, 0x70, 0x88, 0xd0, 0x2b, 0x0d, 0x92, 0x14, 0x09, 0xe1,
|
||||
0x8d, 0xd4, 0x39, 0x6d, 0xfb, 0x94, 0x2a, 0x0d, 0xb2, 0x5d, 0xe8, 0x44, 0x31, 0x4c, 0x83, 0x47,
|
||||
0xf3, 0xff, 0x76, 0x2c, 0x2c, 0xcf, 0xad, 0x3d, 0x28, 0xef, 0x5d, 0x62, 0x54, 0xae, 0x6d, 0xc4,
|
||||
0x55, 0xd6, 0x7a, 0x8d, 0xf0, 0xa1, 0x66, 0x3c, 0x05, 0xd2, 0x8d, 0x3a, 0xe4, 0x58, 0x70, 0x98,
|
||||
0x9d, 0xc7, 0xc1, 0x85, 0x64, 0x22, 0x5c, 0x9a, 0x8f, 0x67, 0x95, 0xb4, 0x6c, 0x7d, 0xa7, 0x4c,
|
||||
0xc2, 0x32, 0xb0, 0x0b, 0x66, 0x74, 0x3c, 0x51, 0x63, 0x9a, 0x31, 0xeb, 0xc0, 0xd0, 0xe3, 0xe1,
|
||||
0xd1, 0xe0, 0xe5, 0xc9, 0xa0, 0xdb, 0xd8, 0x8d, 0x3a, 0x2d, 0xdf, 0xf3, 0xbb, 0x77, 0x98, 0xd6,
|
||||
0x13, 0xc1, 0x8b, 0x2b, 0x4b, 0xdf, 0x5b, 0x25, 0xfb, 0x35, 0x64, 0xf4, 0x04, 0x35, 0x7a, 0x9d,
|
||||
0x1e, 0xee, 0xa1, 0xd6, 0x08, 0x5c, 0x6e, 0x24, 0xc4, 0xe4, 0x2c, 0x05, 0x49, 0x5c, 0x0a, 0xc4,
|
||||
0x80, 0x55, 0xb9, 0xe1, 0x40, 0x62, 0x05, 0x96, 0x48, 0xe5, 0x08, 0x9c, 0x0b, 0xeb, 0x22, 0xbc,
|
||||
0x82, 0x6e, 0x7c, 0xf7, 0xbd, 0x5b, 0x66, 0x1f, 0x35, 0xe7, 0x61, 0x90, 0x67, 0x8a, 0xe7, 0x19,
|
||||
0xc8, 0xf2, 0x89, 0xe0, 0xad, 0xab, 0xa3, 0xa1, 0x56, 0x38, 0xa0, 0xb1, 0xe2, 0x96, 0xbe, 0x59,
|
||||
0x13, 0xd2, 0x81, 0x91, 0x6c, 0x42, 0xf5, 0x78, 0xbc, 0x52, 0x3c, 0xa9, 0xbd, 0x7f, 0x01, 0x00,
|
||||
0x00, 0xff, 0xff, 0x8e, 0x97, 0xf9, 0x54, 0xd1, 0x03, 0x00, 0x00,
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
@ -238,10 +248,13 @@ type SynchronizerClient interface {
|
||||
// request. This enables identify stale evaluation requests belonging to a
|
||||
// prior window when synchronizing evaluation requests for a window.
|
||||
GetContext(ctx context.Context, in *GetContextRequest, opts ...grpc.CallOption) (*GetContextResponse, error)
|
||||
// Evaluate accepts a list of matches, triggers the user configured evaluation
|
||||
// function with these and other matches in the evaluation window and returns
|
||||
// matches that are accepted by the Evaluator as valid results.
|
||||
Evaluate(ctx context.Context, in *EvaluateRequest, opts ...grpc.CallOption) (*EvaluateResponse, error)
|
||||
// EvaluateInContext accepts a list of matches and a context in which these
|
||||
// matches should be evaluated. If the context has expired (not present in
|
||||
// the current evaluation window) this method fails otherwise the matches are
|
||||
// added to the list of matches to be evaluated in the current evaluation
|
||||
// window. At the end of the window, the user defined evaluation method is
|
||||
// triggered and the matches accepted by it are returned as results.
|
||||
EvaluateInContext(ctx context.Context, in *EvaluateInContextRequest, opts ...grpc.CallOption) (*EvaluateInContextResponse, error)
|
||||
}
|
||||
|
||||
type synchronizerClient struct {
|
||||
@ -261,9 +274,9 @@ func (c *synchronizerClient) GetContext(ctx context.Context, in *GetContextReque
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *synchronizerClient) Evaluate(ctx context.Context, in *EvaluateRequest, opts ...grpc.CallOption) (*EvaluateResponse, error) {
|
||||
out := new(EvaluateResponse)
|
||||
err := c.cc.Invoke(ctx, "/api.Synchronizer/Evaluate", in, out, opts...)
|
||||
func (c *synchronizerClient) EvaluateInContext(ctx context.Context, in *EvaluateInContextRequest, opts ...grpc.CallOption) (*EvaluateInContextResponse, error) {
|
||||
out := new(EvaluateInContextResponse)
|
||||
err := c.cc.Invoke(ctx, "/api.Synchronizer/EvaluateInContext", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -277,10 +290,13 @@ type SynchronizerServer interface {
|
||||
// request. This enables identify stale evaluation requests belonging to a
|
||||
// prior window when synchronizing evaluation requests for a window.
|
||||
GetContext(context.Context, *GetContextRequest) (*GetContextResponse, error)
|
||||
// Evaluate accepts a list of matches, triggers the user configured evaluation
|
||||
// function with these and other matches in the evaluation window and returns
|
||||
// matches that are accepted by the Evaluator as valid results.
|
||||
Evaluate(context.Context, *EvaluateRequest) (*EvaluateResponse, error)
|
||||
// EvaluateInContext accepts a list of matches and a context in which these
|
||||
// matches should be evaluated. If the context has expired (not present in
|
||||
// the current evaluation window) this method fails otherwise the matches are
|
||||
// added to the list of matches to be evaluated in the current evaluation
|
||||
// window. At the end of the window, the user defined evaluation method is
|
||||
// triggered and the matches accepted by it are returned as results.
|
||||
EvaluateInContext(context.Context, *EvaluateInContextRequest) (*EvaluateInContextResponse, error)
|
||||
}
|
||||
|
||||
func RegisterSynchronizerServer(s *grpc.Server, srv SynchronizerServer) {
|
||||
@ -305,20 +321,20 @@ func _Synchronizer_GetContext_Handler(srv interface{}, ctx context.Context, dec
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Synchronizer_Evaluate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(EvaluateRequest)
|
||||
func _Synchronizer_EvaluateInContext_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(EvaluateInContextRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SynchronizerServer).Evaluate(ctx, in)
|
||||
return srv.(SynchronizerServer).EvaluateInContext(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/api.Synchronizer/Evaluate",
|
||||
FullMethod: "/api.Synchronizer/EvaluateInContext",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SynchronizerServer).Evaluate(ctx, req.(*EvaluateRequest))
|
||||
return srv.(SynchronizerServer).EvaluateInContext(ctx, req.(*EvaluateInContextRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
@ -332,8 +348,8 @@ var _Synchronizer_serviceDesc = grpc.ServiceDesc{
|
||||
Handler: _Synchronizer_GetContext_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Evaluate",
|
||||
Handler: _Synchronizer_Evaluate_Handler,
|
||||
MethodName: "EvaluateInContext",
|
||||
Handler: _Synchronizer_EvaluateInContext_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
|
@ -37,8 +37,8 @@ func request_Synchronizer_GetContext_0(ctx context.Context, marshaler runtime.Ma
|
||||
|
||||
}
|
||||
|
||||
func request_Synchronizer_Evaluate_0(ctx context.Context, marshaler runtime.Marshaler, client SynchronizerClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq EvaluateRequest
|
||||
func request_Synchronizer_EvaluateInContext_0(ctx context.Context, marshaler runtime.Marshaler, client SynchronizerClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq EvaluateInContextRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||
@ -49,7 +49,7 @@ func request_Synchronizer_Evaluate_0(ctx context.Context, marshaler runtime.Mars
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.Evaluate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
msg, err := client.EvaluateInContext(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
@ -112,7 +112,7 @@ func RegisterSynchronizerHandlerClient(ctx context.Context, mux *runtime.ServeMu
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_Synchronizer_Evaluate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
mux.Handle("POST", pattern_Synchronizer_EvaluateInContext_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
@ -121,14 +121,14 @@ func RegisterSynchronizerHandlerClient(ctx context.Context, mux *runtime.ServeMu
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Synchronizer_Evaluate_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
resp, md, err := request_Synchronizer_EvaluateInContext_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Synchronizer_Evaluate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
forward_Synchronizer_EvaluateInContext_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
@ -138,11 +138,11 @@ func RegisterSynchronizerHandlerClient(ctx context.Context, mux *runtime.ServeMu
|
||||
var (
|
||||
pattern_Synchronizer_GetContext_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "synchronizer", "context"}, ""))
|
||||
|
||||
pattern_Synchronizer_Evaluate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "synchronizer", "matches"}, "evaluate"))
|
||||
pattern_Synchronizer_EvaluateInContext_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "synchronizer", "matches"}, "evaluate"))
|
||||
)
|
||||
|
||||
var (
|
||||
forward_Synchronizer_GetContext_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Synchronizer_Evaluate_0 = runtime.ForwardResponseMessage
|
||||
forward_Synchronizer_EvaluateInContext_0 = runtime.ForwardResponseMessage
|
||||
)
|
||||
|
19
pkg/harness/evaluator/golang/doc.go
Normal file
19
pkg/harness/evaluator/golang/doc.go
Normal file
@ -0,0 +1,19 @@
|
||||
// Copyright 2019 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Package golang contains the go files required to run the evaluator harness
|
||||
// as a GRPC service. To use this harness, you should author the evaluation
|
||||
// function and pass that in as the callback when setting up the evaluator
|
||||
// harness service.
|
||||
package golang
|
78
pkg/harness/evaluator/golang/evaluator_service.go
Normal file
78
pkg/harness/evaluator/golang/evaluator_service.go
Normal file
@ -0,0 +1,78 @@
|
||||
// Copyright 2019 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Package golang provides the Evaluator service for Open Match golang harness.
|
||||
package golang
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
"open-match.dev/open-match/internal/config"
|
||||
"open-match.dev/open-match/internal/pb"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var (
|
||||
evaluatorLogger = logrus.WithFields(logrus.Fields{
|
||||
"app": "openmatch",
|
||||
"component": "harness.golang.evaluator_service",
|
||||
})
|
||||
)
|
||||
|
||||
// Evaluator is the function signature for the Evaluator to be implemented by
|
||||
// the user. The harness will pass the Matches to evaluate to the Evaluator
|
||||
// and the Evaluator will return an accepted list of Matches.
|
||||
type Evaluator func(*EvaluatorParams) ([]*pb.Match, error)
|
||||
|
||||
// evaluatorService implements pb.EvaluatorServer, the server generated by
|
||||
// compiling the protobuf, by fulfilling the pb.EvaluatorServer interface.
|
||||
type evaluatorService struct {
|
||||
cfg config.View
|
||||
evaluate Evaluator
|
||||
}
|
||||
|
||||
// EvaluatorParams is the parameters to be passed by the harness to the evaluator.
|
||||
// - logger:
|
||||
// A logger used to generate error/debug logs
|
||||
// - Matches
|
||||
// Matches to be evaluated
|
||||
type EvaluatorParams struct {
|
||||
Logger *logrus.Entry
|
||||
Matches []*pb.Match
|
||||
}
|
||||
|
||||
// Evaluate is this harness's implementation of the gRPC call defined in
|
||||
// api/evaluator.proto.
|
||||
func (s *evaluatorService) Evaluate(ctx context.Context, req *pb.EvaluateRequest) (*pb.EvaluateResponse, error) {
|
||||
evaluatorLogger.WithFields(logrus.Fields{
|
||||
"proposals": req.Match,
|
||||
}).Debug("matches sent to the evaluator")
|
||||
|
||||
// Run the customized evaluator!
|
||||
results, err := s.evaluate(&EvaluatorParams{
|
||||
Logger: evaluatorLogger,
|
||||
Matches: req.Match,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.Aborted, err.Error())
|
||||
}
|
||||
|
||||
evaluatorLogger.WithFields(logrus.Fields{
|
||||
"results": results,
|
||||
}).Debug("matches accepted by the evaluator")
|
||||
return &pb.EvaluateResponse{Match: results}, nil
|
||||
}
|
66
pkg/harness/evaluator/golang/harness.go
Normal file
66
pkg/harness/evaluator/golang/harness.go
Normal file
@ -0,0 +1,66 @@
|
||||
// Copyright 2019 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Package golang provides the Evaluator service for Open Match golang harness.
|
||||
package golang
|
||||
|
||||
import (
|
||||
"google.golang.org/grpc"
|
||||
"open-match.dev/open-match/internal/config"
|
||||
"open-match.dev/open-match/internal/pb"
|
||||
"open-match.dev/open-match/internal/rpc"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var (
|
||||
harnessLogger = logrus.WithFields(logrus.Fields{
|
||||
"app": "openmatch",
|
||||
"component": "evaluator.golang.harness",
|
||||
})
|
||||
)
|
||||
|
||||
// RunEvaluator is a hook for the main() method in the main executable.
|
||||
func RunEvaluator(eval Evaluator) {
|
||||
cfg, err := config.Read()
|
||||
if err != nil {
|
||||
harnessLogger.WithFields(logrus.Fields{
|
||||
"error": err.Error(),
|
||||
}).Fatalf("cannot read configuration.")
|
||||
}
|
||||
|
||||
p, err := rpc.NewServerParamsFromConfig(cfg, "api.evaluator")
|
||||
if err != nil {
|
||||
harnessLogger.WithFields(logrus.Fields{
|
||||
"error": err.Error(),
|
||||
}).Fatalf("cannot construct server.")
|
||||
}
|
||||
|
||||
if err := BindService(p, cfg, eval); err != nil {
|
||||
harnessLogger.WithFields(logrus.Fields{
|
||||
"error": err.Error(),
|
||||
}).Fatalf("failed to bind evaluator service.")
|
||||
}
|
||||
|
||||
rpc.MustServeForever(p)
|
||||
}
|
||||
|
||||
// BindService creates the evaluator service to the server Params.
|
||||
func BindService(p *rpc.ServerParams, cfg config.View, eval Evaluator) error {
|
||||
p.AddHandleFunc(func(s *grpc.Server) {
|
||||
pb.RegisterEvaluatorServer(s, &evaluatorService{cfg: cfg, evaluate: eval})
|
||||
}, pb.RegisterEvaluatorHandlerFromEndpoint)
|
||||
|
||||
return nil
|
||||
}
|
@ -21,7 +21,7 @@ import (
|
||||
"open-match.dev/open-match/examples/functions/golang/pool"
|
||||
"open-match.dev/open-match/internal/rpc"
|
||||
rpcTesting "open-match.dev/open-match/internal/rpc/testing"
|
||||
mmfHarness "open-match.dev/open-match/pkg/harness/golang"
|
||||
mmfHarness "open-match.dev/open-match/pkg/harness/function/golang"
|
||||
)
|
||||
|
||||
// Create a mmf service using a started test server.
|
||||
|
Reference in New Issue
Block a user