@@ -4,7 +4,7 @@ Dancer2::Plugin::ProbabilityRoute - plugin to define behavior with probability m
4
4
5
5
# VERSION
6
6
7
- version 0.02
7
+ version 0.03
8
8
9
9
# SYNOPSIS
10
10
@@ -18,7 +18,7 @@ version 0.02
18
18
"A is returned for you";
19
19
},
20
20
50 => sub {
21
- "A is returned for you";
21
+ "B is returned for you";
22
22
}
23
23
};
24
24
@@ -43,16 +43,25 @@ route as long as they don't purge their cookies.
43
43
44
44
## probability\_ route
45
45
46
- Use this keyword to declare a route that gets triggered only under a given
47
- probability.
48
- The sequence is important: the first declaration for a given method/path tuple
49
- is the default version of the route.
46
+ Use this keyword to declare a route that is devided into multiple versions,
47
+ each them triggered for a certain percentage of users.
48
+
49
+ The sequence is important: the first declaration is the default version of
50
+ the route (if the user has no cookies).
50
51
51
52
Here is an example of a 30, 50, 20 split:
52
53
53
- probability_route 30, 'get', '/' => sub { "30% chances to get there" };
54
- probability_route 50, 'get', '/' => sub { "50% chances to get there" };
55
- probability_route 20, 'get', '/' => sub { "20% chances to get there" };
54
+ get '/test' => probability
55
+ 30 => sub {
56
+ "30% of users see that.";
57
+ },
58
+ 50 => sub {
59
+ "50% of users see that.";
60
+ },
61
+ 20 => sub {
62
+ "20% of users see that.";
63
+ },
64
+ };
56
65
57
66
To provide stability for each user, the session ID is used as a pivot, to build
58
67
a _ user\_ score_ , which is an number between 0 and 99.
@@ -89,6 +98,10 @@ This module has been written during the
89
98
design and helped me make this module so easy to write it took less than half
90
99
a day to get it into CPAN.
91
100
101
+ The second release was made thanks to the observations of
102
+ [ Russell Jenkins] ( http://search.cpan.org/~russellj/ ) who suggested a better API,
103
+ allowing for a more straight-forward approach.
104
+
92
105
# AUTHOR
93
106
94
107
Alexis Sukrieh
< [email protected] >
0 commit comments