flok 0.0.47 → 0.0.48

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 322e33d75061a0053edd6c19efbb252639c1537d
4
- data.tar.gz: e5f0ea65132822c49497510001cc4a9c2a882448
3
+ metadata.gz: 34017063eb6a9e0ec5c835b31f20820df152548a
4
+ data.tar.gz: d7752b56cb6586b4a4baf5888fcfa2d6a860057b
5
5
  SHA512:
6
- metadata.gz: 6126951cecdb3acc59d10eac9578bd77d89e11ed92042f8424c97bd850aeebadc545e3b7fc30844e8c80588dfeed6700db9e40b0fb743536b305b59bd26a8f5f
7
- data.tar.gz: 5508fb77fbd94365ee2e952aa5dc84191a98e44378ba8d2c5e158b7cd581f54c5ddb9251f322d4e15fc17b905abb9656613f2aa59ff11227c90f1b1d36bac51a
6
+ metadata.gz: b9863c2d44654803d8bca864379b186592672e58c26b686425420a02e4fa0391779ee6358d58fe19ac271ffa0aa84b0c741c41d57da1f721f538acd838de2cc2
7
+ data.tar.gz: 5a9d6c902aa19887b2b70ce2f7df69e26a6364a85e6a60c55b073c2270d420c5d8fcd5a454af1567b0d14d1d522d55be6fb2e31a3d3697b9198caa081af3f3a7
@@ -81,6 +81,13 @@ service :vm do
81
81
  //Part of the persist module
82
82
  //res is page
83
83
  function int_per_get_res(s, ns, res) {
84
+ //Controller made a read_sync request, fulfull it
85
+ if (read_sync_in_progress !== undefined) {
86
+
87
+ int_event(read_sync_in_progress, "read_sync_res", {page: res, ns: ns});
88
+ read_sync_in_progress = undefined;
89
+ }
90
+
84
91
  //If the key didn't exist, ignore it
85
92
  if (res === null) { return; }
86
93
 
@@ -579,6 +586,25 @@ service :vm do
579
586
  <% end %>
580
587
  }
581
588
 
589
+ on "read_sync", %{
590
+ <% if @debug %>
591
+ if (params.id === undefined) {
592
+ throw "You need to pass an id for the page in read_sync request";
593
+ }
594
+
595
+ if (params.ns === undefined) {
596
+ throw "You need to pass an ns for the page in read_sync request";
597
+ }
598
+ <% end %>
599
+
600
+ read_sync_in_progress = bp;
601
+ var cache_entry = vm_cache[params.ns][params.id];
602
+ if (cache_entry !== undefined) {
603
+ int_event(bp, "read_sync_res", {ns: params.ns, page: cache_entry});
604
+ } else {
605
+ SEND("main", "if_per_get", "vm", params.ns, params.id);
606
+ }
607
+ }
582
608
 
583
609
  on "unwatch", %{
584
610
  <% raise "No pagers given in options for vm" unless @options[:pagers] %>
@@ -150,6 +150,16 @@ use the modification helpers. These modification helpers implement copy on write
150
150
  * Spec helpers
151
151
  * If in `@debug` mode, the variable `vm_write_list` contains an array dictionary of the last page passed to the pager (tail is latest).
152
152
 
153
+ ###`read_sync`
154
+ Read from the disk synchronously, or memory if it exists, and return the value in `read_sync_res`. This will not watch the page.
155
+ * Parameters
156
+ * `ns` - Namespace of the page
157
+ * `id` - id of the page
158
+ * Event Responses
159
+ * `read_sync_res`
160
+ * `ns` - The namespace of the page, e.g. 'user'
161
+ * `page` - The page that was retrieved (or null if it dosen't exist)
162
+
153
163
  ##Cache
154
164
  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.
155
165
 
@@ -1,3 +1,3 @@
1
1
  module Flok
2
- VERSION = "0.0.47"
2
+ VERSION = "0.0.48"
3
3
  end
@@ -0,0 +1,29 @@
1
+ controller :my_controller do
2
+ services :vm
3
+
4
+ on_entry %{
5
+ read_sync_res_params = [];
6
+ }
7
+
8
+ action :my_action do
9
+ on_entry %{
10
+ var info = {
11
+ ns: "spec",
12
+ id: "test"
13
+ }
14
+
15
+ var info2 = {
16
+ ns: "spec",
17
+ id: "test2"
18
+ }
19
+
20
+ Request("vm", "read_sync", info);
21
+
22
+ Request("vm", "read_sync", info2);
23
+ }
24
+
25
+ on "read_sync_res", %{
26
+ read_sync_res_params.push(params);
27
+ }
28
+ end
29
+ end
@@ -655,6 +655,42 @@ RSpec.describe "kern:vm_service" do
655
655
  @driver.mexpect("if_per_get", ["vm", "spec", "test"], 2)
656
656
  end
657
657
 
658
+ it "Does send a read request from disk cache when synchronously reading a key for the first time" do
659
+ ctx = flok_new_user File.read('./spec/kern/assets/vm/controller19c.rb'), File.read("./spec/kern/assets/vm/config4.rb")
660
+
661
+ ctx.eval %{
662
+ base = _embed("my_controller", 1, {}, null);
663
+
664
+ //Call pageout *now*
665
+ vm_pageout();
666
+
667
+ //Drain queue
668
+ int_dispatch([]);
669
+ }
670
+
671
+ @driver.ignore_up_to "if_per_get", 0
672
+ @driver.mexpect("if_per_get", ["vm", "spec", "test"], 0)
673
+
674
+ @driver.int "int_per_get_res", ["vm", "spec", {
675
+ "_id" => "default",
676
+ "_hash" => nil,
677
+ "_next" => nil,
678
+ "entries" => [],
679
+ }]
680
+
681
+ @driver.ignore_up_to "if_per_get", 0
682
+ @driver.mexpect("if_per_get", ["vm", "spec", "test2"], 0)
683
+
684
+ dump = ctx.evald %{
685
+ dump.read_sync_in_progress = read_sync_in_progress;
686
+ dump.read_sync_res_params = read_sync_res_params;
687
+ }
688
+
689
+ expect(dump["read_sync_in_progress"]).to eq(nil)
690
+ expect(dump["read_sync_res_params"][0]["ns"]).to eq("spec")
691
+ expect(dump["read_sync_res_params"][0]["page"]["_id"]).to eq("default")
692
+ end
693
+
658
694
  it "Does send a sync read request from disk cache when watching a key for the first time with sync: true" do
659
695
  ctx = flok_new_user File.read('./spec/kern/assets/vm/controller19b.rb'), File.read("./spec/kern/assets/vm/config4.rb")
660
696
 
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.47
4
+ version: 0.0.48
5
5
  platform: ruby
6
6
  authors:
7
7
  - seo
@@ -1207,6 +1207,7 @@ files:
1207
1207
  - spec/kern/assets/vm/controller18.rb
1208
1208
  - spec/kern/assets/vm/controller19.rb
1209
1209
  - spec/kern/assets/vm/controller19b.rb
1210
+ - spec/kern/assets/vm/controller19c.rb
1210
1211
  - spec/kern/assets/vm/controller2.rb
1211
1212
  - spec/kern/assets/vm/controller20.rb
1212
1213
  - spec/kern/assets/vm/controller21.rb
@@ -2117,6 +2118,7 @@ test_files:
2117
2118
  - spec/kern/assets/vm/controller18.rb
2118
2119
  - spec/kern/assets/vm/controller19.rb
2119
2120
  - spec/kern/assets/vm/controller19b.rb
2121
+ - spec/kern/assets/vm/controller19c.rb
2120
2122
  - spec/kern/assets/vm/controller2.rb
2121
2123
  - spec/kern/assets/vm/controller20.rb
2122
2124
  - spec/kern/assets/vm/controller21.rb