...

Package matching

import "github.com/Diarkis/diarkis/matching"
Overview
Index

Overview ▾

Package matching ▷

Match Maker - Distributed in-memory match making

Highly scalable and extremely fast match-making based on application defined match making conditions.

Configurations

Match Maker configurations are explained below.

{
  "distributionRate": 30
}

▶︎ Configuration Value

distributionRate - Default is 30

Ratio of sharded data saturation among the HTTP server nodes in per centage: e.i. 30 means 30%.

func Add

func Add(matchingID string, uniqueID string, props map[string]int, value map[string]interface{}, ttl int64, limit int)

Add Adds a searchable matching candidate data

matchingID - Pre-defined matching ID that is associated with the matching definition by Define()
uniqueID   -  A unique ID for the match making candidate data to prevent duplicates
props      - Match making conditions
value      - Candidate data to be returned when search finds this candidate
ttl        - Defines how long the candidate should be available for search: This is in seconds maximum TTL is 60 seconds
limit      - Defines how many mesh node it should distribute at a time

In order to have long lasting (TTL longer than 60 seconds) searable items, the application must "add" searchable items repeatedly with TTL=60.

func ClearDefinition

func ClearDefinition(matchingID string)

Clear Definition clears already defined match making definition

func Define

func Define(matchingID string, props map[string]int)

Define Defines a match making search schema: This must be defined on HTTP server b/c all match making data is stored on HTTP servers. You may define as many matching definition as you require as long as each matchingID is unique.

func DefineByJSON

func DefineByJSON(jsonBytes []byte)

DefineByJSON defines multiple match making definitions from JSON string.

{
   "<matching ID>": {
                       "<property name>": <property range value>
                       "<property name>": <property range value>
                       "<property name>": <property range value>
                    }
}

func Remove

func Remove(matchingID string, uniqueIDList []string, limit int)

Remove removes a list of searchable matching candidate items by their unique IDs NOTE: this function is very expensive as it will send a message to all related mesh nodes

matchingID   - Target matching ID to remove items from
uniqueIDList - A list of unique IDs of items to remove
limit        - Mesh network relay limit
func Search(searchIDList []string, props map[string]int, limit int, callback func(error, []interface{}))

Search Searchs for matched data based on the given props' values

searchIDList - a list of matchingID to search by. The order of the list is the order of search attempts
props        - a property map to act as match making conditions
limit        - a hard limit to the number of results
callback     - a callback with the search results or an error

func Setup

func Setup(confpath string)

func Test

func Test(method string, data map[string]interface{}) (map[string]interface{}, error)

Test this is used ONLY in tests