-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.yaml
271 lines (207 loc) · 7.82 KB
/
client.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
- name: request, response and Json
comment: |
This example will show you how to read user input and Json file and return them to the client
keywords: **input.Requ, input.Json**
The Json file is main.json, you can display it directly on the button above
When you execute:
- npm run serverJsBuildAndUpload
- npm run serverLuaBuildAndUpload
- npm run serverStarBuildAndUpload
- npm run serverGoBuildAndUpload
The above script will first upload main.json and then upload the server script
**Please note**: If you want the Json file to take effect, you must change the server script.
KeySubList: []
Call:
name: testRequResp
comment:
params:
param1: string
param2: number
param3: boolean
- name: read and write kv
comment: |
this is a read and write kv example, Count increments by 1
keywords: **GetSubVal, GetAndLock, PutSubVal, PutAndUnlock**
KeySubList:
- name: mBase
comment: Count is a counter
Call:
name: testBaseCount
comment:
- name: list queue mode
comment: |
In order, push data to the end of the list, and excess data will shift out from the front
keywords: **List(**
KeySubList:
- name: mList
comment: list mode
Call:
name: testListQueue
comment:
params:
first: string
second: string
- name: list stack mode
comment: |
First pop up the n pieces behind the old data, and then push data to the end of the list
keywords: **List(**
KeySubList:
- name: mList
comment: list mode
Call:
name: testListStack
comment:
params:
n: number
- name: clear data
comment: |
Clear data before doing anything
keywords: **Clear(**
KeySubList:
- name: mList
comment: list mode
Call:
name: testClearData
comment:
- name: get all data
comment: |
There are two ways to get all the data
- **GetSubVal(input.UID, "mList")**
- **GetSubValAll(input.UID, "mList")**
other api: **DiscardAndUnlock**
- like **PutAndUnlock**, but does not modify any data
KeySubList: []
Call:
name: testGetAll
comment:
- name: put link
comment: |
Associate other KeySub when putting data
keywords: **Link(**
KeySubList:
- name: mList
comment: list mode
- name: mListSlave
comment: list mode
Call:
name: testPutLink
comment:
params:
first: string
second: string
- name: throw a user error
comment: |
like read and write kv, but execution is interrupted.
keywords: **Throw(**
KeySubList:
- name: mBase
comment: Count is a counter
Call:
name: testThrow
comment:
- name: advanced query
comment: |
In addition to **GetSubVal** and **GetSubValAll**, we also provide other query methods.
keywords: **Group, Len, Max, Min, Random, Range, Search, Sum, Unique**
KeySubList: []
Call:
name: testOtherQuery
comment:
- name: Prepare a globalChat struct
comment: |
Sometimes, we need to develop some interactive services, such as chat system. At this time we need to watch a public UID and modify it when needed.
- In the client
1. we need to define which keys this structure contains. These codes are somewhat similar to player.ts.
- In the server script(Check out the code in "Server Basic Code" above):
1. Write the "watch" file. According to your own needs, judge whether this call can be allowed
2. Write the "public" file. Let lockval know which fields can be synchronized to the client
After the above preparations, you can execute player.Watch to watch a public UID. You can see the data change in the example below
StructName:
name: globalChat
comment:
IDs: [the001]
- name: send A message to globalChat and trigger cron
comment: |
Please click Watch in the example above before Call
Add data to globalChat:the001. This way users watching globalChat:the001 will see the changes
The cron functionality for triggers is also demonstrated here. For configuration, see the config.yaml of the server.
It demonstrates the action of two bots sending messages periodically.
about cron, you can see: https://lockval.com/docs/architecture/trigger/
KeySubList:
- name: mChatList
comment: chat history here
structName: globalChat
structID: the001
- name: mChatID
comment: who sent the message
structName: globalChat
structID: the001
Call:
name: testChat
comment:
params:
text: string
- name: Delayed execution of calling code
comment: |
Execute "sys/testItsTime" after setting 3 seconds
keywords: **Sleep**
Please pay attention to the data changes in the example below
KeySubList: []
Call:
name: testSleep
comment:
- name: Delayed execution entity code
comment: |
do something when it's time
Here's the Sleep call from the example above
KeySubList:
- name: mBase
comment: Count is a counter
sys:
name: testItsTime
comment:
- name: Use api.*.so for more functionality
comment: |
Generate api.\*.so files by writing plug-ins to support more functions for server-side script codes
When the api starts, it will search for api.\*.so and add all of them to become available functions of the script
This "lockval" plugin can click [here](https://github.com/lockval/api.so) to view the source code
keywords: **.G[**
KeySubList: []
Call:
name: testG
comment:
- name: get link
comment: |
Associate other KeySub when getting data
keywords: **Link(**
KeySubList: []
Call:
name: testGetLink
comment:
- name: Get user data before GetAndLock
comment: |
In lockval, the data in each user call is ACID.
This means that there can only be one GetAndLock call per call to guarantee ACID.
So how to solve the dynamic acquisition of user data through the current user data in GetAndLock?
The method is to notify the front-end engine to upload the specified fields of the current user according to a specific call name. When the backend engine calls GetAndLock, it will check whether these fields are consistent with the current user field data. If not, GetAndLock will return a UserError=-1 to indicate that the data is out of sync
1. The call name use the "-" symbol to express a group of primarykey_subkey requests
For example: when you want to get the subkey "Count" in the primary key "mBase" before GetAndLock
Then the call name is written as: testKeysCount-mBase_Count (of course testKeysCount can be written as other names)
2. In addition, lockval also supports reading the value of a parameter (must be of string type) in the request as the key of the subkey.
For example: you want to use the value of your parameter "param1" as a subkey, and "mList" as a primary key. Then the call name is written as: testKeysCount--mList_param1_ (of course testKeysCount can be written as other names, note that there is a "_" at the end, don't miss it)
If you have requirement 1 and requirement 2, then your calling name should be: testKeysCount-mBase_Count-mList_param1_
The current example will record the value of mBase.Count as the number of subkey in mDict, and if param1="a", then it will also record the value of mList.a as the number of subkey in mDict
***Note***: param1 fills in a subkey in mList, for example: ***0000000000000000000001***
***Note***: "func (e export) Export_***...***" in ***Go*** Script use ***__*** instead of ***-***
KeySubList:
- name: mBase
comment: Count is a counter
- name: mList
comment: list mode
- name: mDict
comment: dict(map) mode
Call:
name: testKeysCount-mBase_Count-mList_param1_
comment:
params:
param1: string