flok 0.0.70 → 0.0.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/kern/pagers/pg_spec.js +2 -0
- data/docs/services/vm.md +3 -2
- data/lib/flok/version.rb +1 -1
- data/spec/kern/assets/vm/controller8ws2.rb +46 -0
- data/spec/kern/vm_service_spec.rb +25 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a7905b48da7599f5f6f62357affb30856c22cf7
|
4
|
+
data.tar.gz: 340d2d3ddf2cf4d564959a0b9d553dd9fb6eb7f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48ac928647f77627085badb6eb35d7b419e4bd523b9772a146476a95f6cd4571f723cd986d105643b79d4c12d2b5c1fa62c09c186bc5a3288f5402c8d5d5b682
|
7
|
+
data.tar.gz: ba8832ae43f3fa6855036ce0a273041826d7eb30db5ebd843472190da32df5db0537072487d9fbe9f1489325de891254aff6c2faf119fc54664256b44081fdc6
|
data/app/kern/pagers/pg_spec.js
CHANGED
data/docs/services/vm.md
CHANGED
@@ -109,7 +109,8 @@ This is how you **read a page** and **request notifications for any updates to a
|
|
109
109
|
Likewise, a `sync` watch request is perfectly acceptible to be called many times for a new controller needing the information. There is little
|
110
110
|
performance benefit in locally caching the data and many drawbacks like not getting updates of changes.
|
111
111
|
* Event Responses
|
112
|
-
* `read_res` - Whenever a change occurs to a page or the first read.
|
112
|
+
* `read_res` - Whenever a change occurs to a page or the first read. If `sync` is true, the page may be `{}` which indicates that no page existed
|
113
|
+
when sync was called (really an illegal condition, you should never use sync unless it's cached)
|
113
114
|
* Returns an immutable page in params
|
114
115
|
|
115
116
|
###`unwatch`
|
@@ -137,7 +138,7 @@ requested. This is because a cached page will be returned by the call stack whil
|
|
137
138
|
* `id` - id of the page
|
138
139
|
* Event Responses
|
139
140
|
* `read_res`
|
140
|
-
* `entire params` - The page that was retrieved (or
|
141
|
+
* `entire params` - The page that was retrieved (or `{}` if it dosen't exist)
|
141
142
|
|
142
143
|
##Cache
|
143
144
|
See below with `vm_cache_write` for how to write to the cache. Each pager can choose whether or not to cache; some pagers may cache only reads while others will cache writes. Failure to write to the cache at all will cause `watch` to never trigger. Some pagers may use a trick where writes are allowed, and go directly to the cache but nowhere else. This is to allow things like *pending* transactions where you can locally fake data until a server response is received which will both wipe the fake write and insert the new one. Cache writes will trigger `watch`; if you write to cache with `vm_cache_write` with a page that has the same `_hash` as a page that already exists in cache, no `watch` events will be triggered. Additionally, calling `vm_cache_write` with a non-modified page will result in no performance penalty. `vm_cache_write` notifies controllers asynchronously and is not effected by the `watch` flag on controllers.
|
data/lib/flok/version.rb
CHANGED
@@ -0,0 +1,46 @@
|
|
1
|
+
controller :my_controller do
|
2
|
+
spots "content"
|
3
|
+
services :vm
|
4
|
+
|
5
|
+
on_entry %{
|
6
|
+
read_res_params = [];
|
7
|
+
}
|
8
|
+
|
9
|
+
action :my_action do
|
10
|
+
on_entry %{
|
11
|
+
page0 = {
|
12
|
+
ns: "spec",
|
13
|
+
id: "my_key",
|
14
|
+
sync: true
|
15
|
+
};
|
16
|
+
|
17
|
+
Request("vm", "watch", page0);
|
18
|
+
}
|
19
|
+
|
20
|
+
on "read_res", %{
|
21
|
+
read_res_params.push(params);
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
controller :my_other_controller do
|
27
|
+
services "vm"
|
28
|
+
|
29
|
+
action :index do
|
30
|
+
#Make changes to page, read_res should be called a second
|
31
|
+
#time (asynchronously)
|
32
|
+
on "modify_page", %{
|
33
|
+
var p = vm_create_page("my_key");
|
34
|
+
p.entries.push({
|
35
|
+
_id: "test",
|
36
|
+
_sig: "test",
|
37
|
+
value: "test"
|
38
|
+
});
|
39
|
+
var info = {
|
40
|
+
ns: "spec",
|
41
|
+
page: p
|
42
|
+
}
|
43
|
+
Request("vm", "write", info);
|
44
|
+
}
|
45
|
+
end
|
46
|
+
end
|
@@ -1037,14 +1037,20 @@ RSpec.describe "kern:vm_service" do
|
|
1037
1037
|
end
|
1038
1038
|
|
1039
1039
|
it "A watch request with the sync flag enabled does return the page to read_res followed by all future changes being sent asynchronously" do
|
1040
|
-
ctx = flok_new_user File.read('./spec/kern/assets/vm/
|
1040
|
+
ctx = flok_new_user File.read('./spec/kern/assets/vm/controller8ws2.rb'), File.read("./spec/kern/assets/vm/config4.rb")
|
1041
1041
|
|
1042
1042
|
ctx.eval %{
|
1043
1043
|
base = _embed("my_controller", 1, {}, null);
|
1044
1044
|
|
1045
|
+
//We need another controller, plans to synchronously dispatch
|
1046
|
+
//changes within the same controller
|
1047
|
+
other_base = _embed("my_other_controller", base+2, {}, null);
|
1048
|
+
|
1045
1049
|
//Drain queue
|
1046
1050
|
int_dispatch([]);
|
1047
1051
|
}
|
1052
|
+
base = ctx.eval("base")
|
1053
|
+
other_base = ctx.eval("other_base")
|
1048
1054
|
|
1049
1055
|
@driver.ignore_up_to "if_per_get", 0
|
1050
1056
|
@driver.mexpect("if_per_get", ["vm", "spec", "my_key"], 0)
|
@@ -1068,6 +1074,24 @@ RSpec.describe "kern:vm_service" do
|
|
1068
1074
|
read_res_params = ctx.dump "read_res_params"
|
1069
1075
|
expect(read_res_params[0]["_id"]).to eq("my_key")
|
1070
1076
|
expect(read_res_params.length).to eq(1)
|
1077
|
+
|
1078
|
+
#Signal controller to modify page
|
1079
|
+
@driver.int "int_event", [other_base, "modify_page", {}]
|
1080
|
+
|
1081
|
+
#Expect nothing to show up yet (should be dispatched asynchrosouly and will show up after int_dispatch
|
1082
|
+
read_res_params = ctx.dump "read_res_params"
|
1083
|
+
expect(read_res_params.length).to eq(1)
|
1084
|
+
|
1085
|
+
#Dispatch any pending async
|
1086
|
+
#(This should trigger an additional read_res)
|
1087
|
+
@ctx.eval %{
|
1088
|
+
for (var i = 0; i < 100; ++i) {
|
1089
|
+
int_dispatch([]);
|
1090
|
+
}
|
1091
|
+
}
|
1092
|
+
|
1093
|
+
read_res_params = ctx.dump "read_res_params"
|
1094
|
+
expect(read_res_params.length).to eq(2)
|
1071
1095
|
end
|
1072
1096
|
|
1073
1097
|
it "Clears the dirty page when pageout runs" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flok
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.71
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- seo
|
@@ -1226,6 +1226,7 @@ files:
|
|
1226
1226
|
- spec/kern/assets/vm/controller8.rb
|
1227
1227
|
- spec/kern/assets/vm/controller8b.rb
|
1228
1228
|
- spec/kern/assets/vm/controller8ws.rb
|
1229
|
+
- spec/kern/assets/vm/controller8ws2.rb
|
1229
1230
|
- spec/kern/assets/vm/controller9.rb
|
1230
1231
|
- spec/kern/assets/vm/controller_exc_2watch.rb
|
1231
1232
|
- spec/kern/assets/vm/controller_exc_ewatch.rb
|
@@ -2162,6 +2163,7 @@ test_files:
|
|
2162
2163
|
- spec/kern/assets/vm/controller8.rb
|
2163
2164
|
- spec/kern/assets/vm/controller8b.rb
|
2164
2165
|
- spec/kern/assets/vm/controller8ws.rb
|
2166
|
+
- spec/kern/assets/vm/controller8ws2.rb
|
2165
2167
|
- spec/kern/assets/vm/controller9.rb
|
2166
2168
|
- spec/kern/assets/vm/controller_exc_2watch.rb
|
2167
2169
|
- spec/kern/assets/vm/controller_exc_ewatch.rb
|