The Match Function is the core of the decision. It's this service that creates game proposals. It makes its decisions from profile's configuration. In this service, you can code any logic that will generate your match proposals
Every Open Match service should be in its own project. Create a new folder for the OpenMatch match-function component.
In this folder, run the following command.
And create a file named
main.go where the core logic of the component will be.
The first thing that we need for our Match Function is a gRPC server that will listen for a call from Open Match Core.
We will need two libraries for this step. You can install them with
Now, in your main.go file, you can add the following code. This will create the gPRC server.
You can try it by starting your app with
go run ./main.go. You should see
The strength of Open Match comes from the customization of Match Function and Director services. We will now create the Match Function. This one aims to fetch Open Match tickets based on profiles. Match Function can be very complicated, but we will keep it simple and implement a basic Match Function in this tutorial.
The Match Function will fetch all the tickets that match the profile received in the request. The tickets will be categorized by pool's name (Profiles contain pools). Then, we will go through each pool and create game proposals from the tickets in the pool. When the proposals are all created, we will send them back to Open Match Core via gRPC
Below is the code for the Match Function. It should be placed in the main.go file under the
You will have to change your dependencies. They should look like this
Also, you will have to update the main function to create the Open Match Query service connection and make the basicMatchFunction
It will be hard to test this service in a standalone context. We will see it in action when all the services (Front end, Director, and Match Function) will be ready.
Create a file named Dockerfile and write this inside.
You can now build your image using.
You can run it using this command, but without all the other services, it will not work.
You can now build your image using. (If you use Edgegap's harbor, <REPOSITORY_MAME> is harbor.edgegap.net/<YOUR_PROJECT>)
You can run it using
Now push your image on your Docker repository. (You may have to use Docker login)
You now have a basic Open Match Match Function service that can be called by Open Match Core using gRPC protocol. This is not production-ready, however you should be able to grasp the basics of Open Match Front End. You also created a Docker image and pushed it to your repository.