fraggle 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/README.md +40 -30
  2. metadata +2 -2
data/README.md CHANGED
@@ -12,47 +12,57 @@
12
12
  require 'fraggle'
13
13
 
14
14
  EM.start do
15
- c = Fraggle.connect "127.0.0.1", 8046
16
-
17
- ## Setting a key
18
- c.set "/foo", "bar", :missing do |e|
19
- if ! e.err
20
- e.cas # => "123"
21
- end
22
- end
15
+ # Fraggle keeps track of this addr plus all others it finds once
16
+ # connected. In the event of a lost connection, fraggle will attempt
17
+ # other doozers until one accepts or it runs out of options; An
18
+ # AssemlyError will be raised if that later happens.
19
+ c = Fraggle.connect "127.0.0.1:8046"
23
20
 
24
21
  c.get "/foo" do |e|
25
- if err != nil
26
- e.body # => "bar"
27
- e.cas # => "123"
28
- e.dir? # => false
22
+ if e.ok?
23
+ e.value # => "bar"
24
+ e.cas # => "123"
25
+ e.dir? # => false
26
+ e.notdir? # => true
29
27
  end
30
28
  end
31
29
 
32
30
  watch = c.watch "/foo" do |e|
33
31
  # The event has:
34
32
  # ------------------------
35
- # NOTE: `err` will be set iff the glob is bad
36
- # e.err # => nil
37
- # e.path # => "/foo"
38
- # e.body # => "bar"
39
- # e.cas # => "123"
40
- # e.set? # => true
41
- # e.del? # => false
42
- # e.done? # => true
43
- # ------------------------
44
-
45
- if e.done?
46
- # This watch was closed, do something if you wish.
47
- else
48
- done_something_with(e)
33
+ e.err_code # => nil
34
+ e.err_detail # => nil
35
+ e.path # => "/foo"
36
+ e.value # => "bar"
37
+ e.cas # => "123"
38
+ e.dir? # => false
39
+ e.notdir? # => true
40
+ e.set? # => true
41
+ e.del? # => false
42
+
43
+ done_something_with(e)
44
+
45
+ # Phoney check for example
46
+ if can_stop_watching?(path)
47
+ c.cancel(watch)
48
+ end
49
+ end
49
50
 
50
- # Phoney check for example
51
- if can_stop_watching?(path)
52
- c.close(watch)
51
+ ## Setting a key (this will trigger the watch above)
52
+ c.set "/foo", "zomg!", :missing do |e|
53
+ case true
54
+ when e.mismatch? # CAS mis-match
55
+ # retry if we must
56
+ c.set "/foo", "zomg!", e.cas do |e|
57
+ if ! e.ok?
58
+ # we give up
59
+ end
53
60
  end
61
+ when e.ok?
62
+ e.cas # => "123"
63
+ else
64
+ raise e.err_detail
54
65
  end
55
-
56
66
  end
57
67
 
58
68
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Blake Mizerany