Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wgrape/matching
A general and configurable user matching library based on Go language / 一个基于Go语言实现的通用且可配置化的用户匹配库
https://github.com/wgrape/matching
golang golang-library matching strategy-game
Last synced: 2 months ago
JSON representation
A general and configurable user matching library based on Go language / 一个基于Go语言实现的通用且可配置化的用户匹配库
- Host: GitHub
- URL: https://github.com/wgrape/matching
- Owner: WGrape
- License: mit
- Created: 2022-04-17T16:42:40.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-03T14:34:58.000Z (10 months ago)
- Last Synced: 2024-10-09T17:40:59.195Z (2 months ago)
- Topics: golang, golang-library, matching, strategy-game
- Language: Go
- Homepage:
- Size: 14.6 KB
- Stars: 10
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# matching
[![MIT license](https://img.shields.io/badge/license-MIT-brightgreen.svg)](./LICENSE)
A general and configurable user matching library based on Go language
## Overview
How to find the target matching users by priority ?### 1、Core Matching Logic
Computing user and get the core data for matching.#### (1) User properties
- gender :male
- age :27#### (2) Property Combinations
- gender=male;age=27
- gender=male
- age=27#### (3) Matched Property Combinations
- gender=female;age=27
- gender=female
- age=27### 2、Store Users and Get Matched Users
#### (1) Store Users
#### (2) Get Matched Users
Get user ``` Matched Property Combinations``` and fetch users from ```userMap``` by key in turn.
## Usage
You can follow the steps below, or use the [example](./example/example.go).### 1、Configuration
- app
- ```version``` :the version number of application
- ```language``` :the different agents
- strategy
- ```rules``` :the different rules of matchingExpand config/config.yaml file
```yaml
app:
version: v1.0.0
language: go1.16.10strategy:
rules:
# If it is a woman, first match the male, then the female
- gender=0:
- gender=1
- gender=0# If male, match female first, then male
- gender=1:
- gender=0
- gender=1
# ... ...
```### 2、Create strategy object
Create a strategy object and call ```AutoCreateStrategy()```.```go
package main
import (
"matching/pkg/strategy"
)func main(){
st := strategy.UseStrategy{}
err := st.AutoCreateStrategy("config/config.yaml")
if err != nil {
fmt.Println(err.Error())
return
}
}
```### 3、Compute user
You can get ```implodePropertiesString```,```combinationList``` and ```matchedCombinationList``` after calling ```ComputeUser()```.- ```implodePropertiesString``` :implode the properties to string
- ```combinationList``` :get the combination list of properties
- ```matchedCombinationList``` :get the matched combination list of properties```go
package main
import (
"matching/pkg/strategy"
)func main() {
user := strategy.User{
UserId: "12345678",
Score: 0.0,
Gender: 0,
Age: "80",
City: "Yon",
Status: 1,
}
implodePropertiesString, combinationList, matchedCombinationList := st.ComputeUser(user)
}
```## Contributing
Welcome to use and contribute to this project !## License
[LICENSE](./LICENSE)