9
9
% % Key = binary() | string()
10
10
% % Value = binary() | string()
11
11
% % Timeout = pos_integer() | 'infinity'
12
- % % Result = ok | {add_err , any()}
12
+ % % Result = ok | {error , any()}
13
13
% % @end
14
- -spec add (url (), key (), value (), pos_timeout ()) -> ok | {add_err , any ()}.
14
+ -spec add (url (), key (), value (), pos_timeout ()) -> ok | {error , any ()}.
15
15
add (Url , Key , Value , Timeout ) ->
16
16
{ok , Exists } = exists (Url , Key , Timeout ),
17
17
case Exists of
@@ -22,7 +22,7 @@ add(Url, Key, Value, Timeout) ->
22
22
Result = etcd :set (Url , MemberKey , Value , Timeout ),
23
23
case Result of
24
24
{ok , {set , _ , _ , _ , _ , _ , _ , _ }} -> ok ;
25
- _ -> {add_err , Result }
25
+ _ -> {error , Result }
26
26
end .
27
27
28
28
% % @spec (Url, Key, Value, TTL, Timeout) -> Result
@@ -31,9 +31,9 @@ add(Url, Key, Value, Timeout) ->
31
31
% % Value = binary() | string()
32
32
% % TTL = pos_integer()
33
33
% % Timeout = pos_integer() | 'infinity'
34
- % % Result = ok | {add_err , any()}
34
+ % % Result = ok | {error , any()}
35
35
% % @end
36
- -spec add (url (), key (), value (), pos_integer (), pos_timeout ()) -> ok | {add_err , any ()}.
36
+ -spec add (url (), key (), value (), pos_integer (), pos_timeout ()) -> ok | {error , any ()}.
37
37
add (Url , Key , Value , TTL , Timeout ) ->
38
38
{ok , Exists } = exists (Url , Key , Timeout ),
39
39
case Exists of
@@ -43,54 +43,54 @@ add(Url, Key, Value, TTL, Timeout) ->
43
43
Result = etcd :set (Url , MemberKey , Value , TTL , Timeout ),
44
44
case Result of
45
45
{ok , {set , _ , _ , _ , _ , _ , _ , _ }} -> ok ;
46
- _ -> {add_err , Result }
46
+ _ -> {error , Result }
47
47
end .
48
48
49
49
% % @spec (Url, Key, Value, Timeout) -> Result
50
50
% % Url = string()
51
51
% % Key = binary() | string()
52
52
% % Value = binary() | string()
53
53
% % Timeout = pos_integer() | 'infinity'
54
- % % Result = ok | {del_err , any()}
54
+ % % Result = ok | {error , any()}
55
55
% % @end
56
- -spec del (url (), key (), value (), pos_timeout ()) -> ok | {del_err , any ()}.
56
+ -spec del (url (), key (), value (), pos_timeout ()) -> ok | {error , any ()}.
57
57
del (Url , Key , Value , Timeout ) ->
58
58
{ok , exists } = exists (Url , Key , Timeout ),
59
59
MemberKey = io_lib :format (" ~s /~s " , [Key , hash (Value )]),
60
60
Result = etcd :delete (Url , MemberKey , Timeout ),
61
61
case Result of
62
62
{ok , {delete , _ , _ , _ }} -> ok ;
63
- {ok , {error , 100 , _ , _ }} -> {del_err , not_in_set };
64
- _ -> {del_err , Result }
63
+ {ok , {error , 100 , _ , _ }} -> {error , not_in_set };
64
+ _ -> {error , Result }
65
65
end .
66
66
67
67
% % @spec (Url, Key, Value, Timeout) -> Result
68
68
% % Url = string()
69
69
% % Key = binary() | string()
70
70
% % Value = binary() | string()
71
71
% % Timeout = pos_integer() | 'infinity'
72
- % % Result = {ok, boolean()} | {ismember_err , any()}
72
+ % % Result = {ok, boolean()} | {error , any()}
73
73
% % @end
74
- -spec ismember (url (), key (), value (), pos_timeout ()) -> {ok , boolean ()} | {ismember_err , any ()}.
74
+ -spec ismember (url (), key (), value (), pos_timeout ()) -> {ok , boolean ()} | {error , any ()}.
75
75
ismember (Url , Key , Value , Timeout ) ->
76
76
{ok , exists } = exists (Url , Key , Timeout ),
77
77
MemberKey = io_lib :format (" ~s /~s " , [Key , hash (Value )]),
78
78
Result = etcd :get (Url , MemberKey , Timeout ),
79
79
case Result of
80
80
{ok , {get , _ , _ , _ , _ }} -> {ok , true };
81
81
{ok , {error , 100 , _ , _ }} -> {ok , false };
82
- {ok , Response } when is_list (Response ) -> {ismember_err , directory };
83
- _ -> {ismember_err , Result }
82
+ {ok , Response } when is_list (Response ) -> {error , directory };
83
+ _ -> {error , Result }
84
84
end .
85
85
86
86
% % @spec (Url, Key, Value, Timeout) -> Result
87
87
% % Url = string()
88
88
% % Key = binary() | string()
89
89
% % Value = binary() | string()
90
90
% % Timeout = pos_integer() | 'infinity'
91
- % % Result = {ok, [binary()]} | {members_err , any()}
91
+ % % Result = {ok, [binary()]} | {error , any()}
92
92
% % @end
93
- -spec members (url (), key (), pos_timeout ()) -> {ok , [binary ()]} | {members_err , any ()}.
93
+ -spec members (url (), key (), pos_timeout ()) -> {ok , [binary ()]} | {error , any ()}.
94
94
members (Url , Key , Timeout ) ->
95
95
{ok , exists } = exists (Url , Key , Timeout ),
96
96
HeadKey = get_head_key (Key ),
@@ -100,9 +100,9 @@ members(Url, Key, Timeout) ->
100
100
Response1 = lists :keydelete (list_to_binary (HeadKey ), 2 , Response ),
101
101
{ok , [ Value || {get , _ , Value , _ , _ } <- Response1 ]};
102
102
{ok , {get , _ , _ , _ , _ }} ->
103
- {members_err , not_a_directory };
103
+ {error , not_a_directory };
104
104
_ ->
105
- {members_err , Result }
105
+ {error , Result }
106
106
end .
107
107
108
108
% % @private
@@ -121,13 +121,13 @@ get_head_key(Key) ->
121
121
io_lib :format (" ~s /set-~s " , [Key , hash (Key )]).
122
122
123
123
% % @private
124
- -spec exists (url (), key (), pos_timeout ()) -> {ok , exists | not_exists } | {exists_err , any ()}.
124
+ -spec exists (url (), key (), pos_timeout ()) -> {ok , exists | not_exists } | {error , any ()}.
125
125
exists (Url , Key , Timeout ) ->
126
126
Result = etcd :get (Url , get_head_key (Key ), Timeout ),
127
127
case Result of
128
128
{ok , {get , _ , _ , _ , _ }} -> {ok , exists };
129
129
{ok , {error , 100 , _ , _ }} -> {ok , not_exists };
130
- {ok , _Response } when is_list (_Response ) -> {exists_err , directory };
131
- _ -> {exists_err , Result }
130
+ {ok , _Response } when is_list (_Response ) -> {error , directory };
131
+ _ -> {error , Result }
132
132
end .
133
133
0 commit comments