Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sven Franck
jio
Commits
d310b2cb
Commit
d310b2cb
authored
Feb 21, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
'Replace' job rule now add callbacks to the job. 'DontAccept' rule is not used anymore.
parent
23bc8ffb
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
54 deletions
+45
-54
src/jio/commands/command.js
src/jio/commands/command.js
+27
-8
src/jio/jobs/job.js
src/jio/jobs/job.js
+2
-9
src/jio/jobs/jobRules.js
src/jio/jobs/jobRules.js
+13
-13
test/jiotests.js
test/jiotests.js
+3
-24
No files found.
src/jio/commands/command.js
View file @
d310b2cb
...
@@ -35,8 +35,8 @@ var command = function (spec, my) {
...
@@ -35,8 +35,8 @@ var command = function (spec, my) {
priv
.
docid
=
spec
.
docid
||
priv
.
doc
.
_id
;
priv
.
docid
=
spec
.
docid
||
priv
.
doc
.
_id
;
priv
.
option
=
spec
.
options
||
{};
priv
.
option
=
spec
.
options
||
{};
priv
.
callbacks
=
spec
.
callbacks
||
{};
priv
.
callbacks
=
spec
.
callbacks
||
{};
priv
.
success
=
priv
.
callbacks
.
success
||
function
()
{}
;
priv
.
success
=
[
priv
.
callbacks
.
success
||
function
()
{}]
;
priv
.
error
=
priv
.
callbacks
.
error
||
function
()
{}
;
priv
.
error
=
[
priv
.
callbacks
.
error
||
function
()
{}]
;
priv
.
retry
=
function
()
{
priv
.
retry
=
function
()
{
that
.
error
({
that
.
error
({
status
:
13
,
status
:
13
,
...
@@ -232,11 +232,14 @@ var command = function (spec, my) {
...
@@ -232,11 +232,14 @@ var command = function (spec, my) {
*/
*/
that
.
executeOn
=
function
(
storage
)
{};
that
.
executeOn
=
function
(
storage
)
{};
that
.
success
=
function
(
return_value
)
{
that
.
success
=
function
(
return_value
)
{
var
i
;
priv
.
on_going
=
false
;
priv
.
on_going
=
false
;
priv
.
success
(
return_value
);
for
(
i
=
0
;
i
<
priv
.
success
.
length
;
i
+=
1
)
{
priv
.
success
[
i
](
return_value
);
}
priv
.
end
(
doneStatus
());
priv
.
end
(
doneStatus
());
priv
.
success
=
function
()
{}
;
priv
.
success
=
[]
;
priv
.
error
=
function
()
{}
;
priv
.
error
=
[]
;
};
};
that
.
retry
=
function
(
return_error
)
{
that
.
retry
=
function
(
return_error
)
{
priv
.
on_going
=
false
;
priv
.
on_going
=
false
;
...
@@ -247,15 +250,31 @@ var command = function (spec, my) {
...
@@ -247,15 +250,31 @@ var command = function (spec, my) {
}
}
};
};
that
.
error
=
function
(
return_error
)
{
that
.
error
=
function
(
return_error
)
{
var
i
;
priv
.
on_going
=
false
;
priv
.
on_going
=
false
;
priv
.
error
(
return_error
);
for
(
i
=
0
;
i
<
priv
.
error
.
length
;
i
+=
1
)
{
priv
.
error
[
i
](
return_error
);
}
priv
.
end
(
failStatus
());
priv
.
end
(
failStatus
());
priv
.
success
=
function
()
{}
;
priv
.
success
=
[]
;
priv
.
error
=
function
()
{}
;
priv
.
error
=
[]
;
};
};
that
.
end
=
function
()
{
that
.
end
=
function
()
{
priv
.
end
(
doneStatus
());
priv
.
end
(
doneStatus
());
};
};
that
.
addCallbacks
=
function
(
success
,
error
)
{
if
(
arguments
.
length
>
1
)
{
priv
.
success
.
push
(
success
||
function
()
{});
priv
.
error
.
push
(
error
||
function
()
{});
}
else
{
priv
.
success
.
push
(
function
(
response
)
{
(
success
||
function
()
{})(
undefined
,
response
);
});
priv
.
error
.
push
(
function
(
err
)
{
(
success
||
function
()
{})(
err
,
undefined
);
});
}
};
that
.
onSuccessDo
=
function
(
fun
)
{
that
.
onSuccessDo
=
function
(
fun
)
{
if
(
fun
)
{
if
(
fun
)
{
priv
.
success
=
fun
;
priv
.
success
=
fun
;
...
...
src/jio/jobs/job.js
View file @
d310b2cb
...
@@ -155,16 +155,9 @@ var job = function (spec) {
...
@@ -155,16 +155,9 @@ var job = function (spec) {
* @param {object} job The other job.
* @param {object} job The other job.
*/
*/
that
.
update
=
function
(
job
)
{
that
.
update
=
function
(
job
)
{
priv
.
command
.
error
({
priv
.
command
.
addCallbacks
(
job
.
getCommand
().
onSuccessDo
()[
0
],
status
:
12
,
job
.
getCommand
().
onErrorDo
()[
0
]);
statusText
:
'
Replaced
'
,
error
:
'
replaced
'
,
message
:
'
Job has been replaced by another one.
'
,
reason
:
'
job has been replaced by another one
'
});
priv
.
date
=
new
Date
(
job
.
getDate
().
getTime
());
priv
.
date
=
new
Date
(
job
.
getDate
().
getTime
());
priv
.
command
=
job
.
getCommand
();
priv
.
status
=
job
.
getStatus
();
};
};
/**
/**
...
...
src/jio/jobs/jobRules.js
View file @
d310b2cb
...
@@ -210,7 +210,7 @@ var jobRules = (function () {
...
@@ -210,7 +210,7 @@ var jobRules = (function () {
For more information, see documentation
For more information, see documentation
*/
*/
that
.
addActionRule
(
'
post
'
,
true
,
'
post
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
post
'
,
true
,
'
post
'
,
that
.
update
);
that
.
addActionRule
(
'
post
'
,
true
,
'
put
'
,
that
.
wait
);
that
.
addActionRule
(
'
post
'
,
true
,
'
put
'
,
that
.
wait
);
that
.
addActionRule
(
'
post
'
,
true
,
'
get
'
,
that
.
wait
);
that
.
addActionRule
(
'
post
'
,
true
,
'
get
'
,
that
.
wait
);
that
.
addActionRule
(
'
post
'
,
true
,
'
remove
'
,
that
.
wait
);
that
.
addActionRule
(
'
post
'
,
true
,
'
remove
'
,
that
.
wait
);
...
@@ -221,12 +221,12 @@ var jobRules = (function () {
...
@@ -221,12 +221,12 @@ var jobRules = (function () {
that
.
addActionRule
(
'
post
'
,
false
,
'
remove
'
,
that
.
eliminate
);
that
.
addActionRule
(
'
post
'
,
false
,
'
remove
'
,
that
.
eliminate
);
that
.
addActionRule
(
'
post
'
,
false
,
'
putAttachment
'
,
that
.
wait
);
that
.
addActionRule
(
'
post
'
,
false
,
'
putAttachment
'
,
that
.
wait
);
that
.
addActionRule
(
'
put
'
,
true
,
'
post
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
put
'
,
true
,
'
post
'
,
that
.
update
);
that
.
addActionRule
(
'
put
'
,
true
,
'
put
'
,
that
.
wait
);
that
.
addActionRule
(
'
put
'
,
true
,
'
put
'
,
that
.
wait
);
that
.
addActionRule
(
'
put
'
,
true
,
'
get
'
,
that
.
wait
);
that
.
addActionRule
(
'
put
'
,
true
,
'
get
'
,
that
.
wait
);
that
.
addActionRule
(
'
put
'
,
true
,
'
remove
'
,
that
.
wait
);
that
.
addActionRule
(
'
put
'
,
true
,
'
remove
'
,
that
.
wait
);
that
.
addActionRule
(
'
put
'
,
true
,
'
putAttachment
'
,
that
.
wait
);
that
.
addActionRule
(
'
put
'
,
true
,
'
putAttachment
'
,
that
.
wait
);
that
.
addActionRule
(
'
put
'
,
false
,
'
post
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
put
'
,
false
,
'
post
'
,
that
.
update
);
that
.
addActionRule
(
'
put
'
,
false
,
'
put
'
,
that
.
update
);
that
.
addActionRule
(
'
put
'
,
false
,
'
put
'
,
that
.
update
);
that
.
addActionRule
(
'
put
'
,
false
,
'
get
'
,
that
.
wait
);
that
.
addActionRule
(
'
put
'
,
false
,
'
get
'
,
that
.
wait
);
that
.
addActionRule
(
'
put
'
,
false
,
'
remove
'
,
that
.
eliminate
);
that
.
addActionRule
(
'
put
'
,
false
,
'
remove
'
,
that
.
eliminate
);
...
@@ -234,7 +234,7 @@ var jobRules = (function () {
...
@@ -234,7 +234,7 @@ var jobRules = (function () {
that
.
addActionRule
(
'
get
'
,
true
,
'
post
'
,
that
.
wait
);
that
.
addActionRule
(
'
get
'
,
true
,
'
post
'
,
that
.
wait
);
that
.
addActionRule
(
'
get
'
,
true
,
'
put
'
,
that
.
wait
);
that
.
addActionRule
(
'
get
'
,
true
,
'
put
'
,
that
.
wait
);
that
.
addActionRule
(
'
get
'
,
true
,
'
get
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
get
'
,
true
,
'
get
'
,
that
.
update
);
that
.
addActionRule
(
'
get
'
,
true
,
'
remove
'
,
that
.
wait
);
that
.
addActionRule
(
'
get
'
,
true
,
'
remove
'
,
that
.
wait
);
that
.
addActionRule
(
'
get
'
,
true
,
'
putAttachment
'
,
that
.
wait
);
that
.
addActionRule
(
'
get
'
,
true
,
'
putAttachment
'
,
that
.
wait
);
that
.
addActionRule
(
'
get
'
,
false
,
'
post
'
,
that
.
wait
);
that
.
addActionRule
(
'
get
'
,
false
,
'
post
'
,
that
.
wait
);
...
@@ -244,24 +244,24 @@ var jobRules = (function () {
...
@@ -244,24 +244,24 @@ var jobRules = (function () {
that
.
addActionRule
(
'
get
'
,
false
,
'
putAttachment
'
,
that
.
wait
);
that
.
addActionRule
(
'
get
'
,
false
,
'
putAttachment
'
,
that
.
wait
);
that
.
addActionRule
(
'
remove
'
,
true
,
'
post
'
,
that
.
wait
);
that
.
addActionRule
(
'
remove
'
,
true
,
'
post
'
,
that
.
wait
);
that
.
addActionRule
(
'
remove
'
,
true
,
'
get
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
remove
'
,
true
,
'
get
'
,
that
.
update
);
that
.
addActionRule
(
'
remove
'
,
true
,
'
remove
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
remove
'
,
true
,
'
remove
'
,
that
.
update
);
that
.
addActionRule
(
'
remove
'
,
true
,
'
putAttachment
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
remove
'
,
true
,
'
putAttachment
'
,
that
.
update
);
that
.
addActionRule
(
'
remove
'
,
false
,
'
post
'
,
that
.
eliminate
);
that
.
addActionRule
(
'
remove
'
,
false
,
'
post
'
,
that
.
eliminate
);
that
.
addActionRule
(
'
remove
'
,
false
,
'
put
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
remove
'
,
false
,
'
put
'
,
that
.
update
);
that
.
addActionRule
(
'
remove
'
,
false
,
'
get
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
remove
'
,
false
,
'
get
'
,
that
.
update
);
that
.
addActionRule
(
'
remove
'
,
false
,
'
remove
'
,
that
.
update
);
that
.
addActionRule
(
'
remove
'
,
false
,
'
remove
'
,
that
.
update
);
that
.
addActionRule
(
'
remove
'
,
false
,
'
putAttachment
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
remove
'
,
false
,
'
putAttachment
'
,
that
.
update
);
that
.
addActionRule
(
'
allDocs
'
,
true
,
'
allDocs
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
allDocs
'
,
true
,
'
allDocs
'
,
that
.
update
);
that
.
addActionRule
(
'
allDocs
'
,
false
,
'
allDocs
'
,
that
.
update
);
that
.
addActionRule
(
'
allDocs
'
,
false
,
'
allDocs
'
,
that
.
update
);
that
.
addActionRule
(
'
putAttachment
'
,
true
,
'
post
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
putAttachment
'
,
true
,
'
post
'
,
that
.
update
);
that
.
addActionRule
(
'
putAttachment
'
,
true
,
'
put
'
,
that
.
wait
);
that
.
addActionRule
(
'
putAttachment
'
,
true
,
'
put
'
,
that
.
wait
);
that
.
addActionRule
(
'
putAttachment
'
,
true
,
'
get
'
,
that
.
wait
);
that
.
addActionRule
(
'
putAttachment
'
,
true
,
'
get
'
,
that
.
wait
);
that
.
addActionRule
(
'
putAttachment
'
,
true
,
'
remove
'
,
that
.
wait
);
that
.
addActionRule
(
'
putAttachment
'
,
true
,
'
remove
'
,
that
.
wait
);
that
.
addActionRule
(
'
putAttachment
'
,
true
,
'
putAttachment
'
,
that
.
wait
);
that
.
addActionRule
(
'
putAttachment
'
,
true
,
'
putAttachment
'
,
that
.
wait
);
that
.
addActionRule
(
'
putAttachment
'
,
false
,
'
post
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
putAttachment
'
,
false
,
'
post
'
,
that
.
update
);
that
.
addActionRule
(
'
putAttachment
'
,
false
,
'
put
'
,
that
.
wait
);
that
.
addActionRule
(
'
putAttachment
'
,
false
,
'
put
'
,
that
.
wait
);
that
.
addActionRule
(
'
putAttachment
'
,
false
,
'
get
'
,
that
.
wait
);
that
.
addActionRule
(
'
putAttachment
'
,
false
,
'
get
'
,
that
.
wait
);
that
.
addActionRule
(
'
putAttachment
'
,
false
,
'
remove
'
,
that
.
eliminate
);
that
.
addActionRule
(
'
putAttachment
'
,
false
,
'
remove
'
,
that
.
eliminate
);
...
...
test/jiotests.js
View file @
d310b2cb
...
@@ -634,13 +634,13 @@ test ("Several Jobs at the same time", function () {
...
@@ -634,13 +634,13 @@ test ("Several Jobs at the same time", function () {
});
});
test
(
"
Similar Jobs at the same time (
Replac
e)
"
,
function
()
{
test
(
"
Similar Jobs at the same time (
Updat
e)
"
,
function
()
{
var
o
=
generateTools
(
this
);
var
o
=
generateTools
(
this
);
o
.
jio
=
JIO
.
newJio
({
"
type
"
:
"
dummyallok
"
});
o
.
jio
=
JIO
.
newJio
({
"
type
"
:
"
dummyallok
"
});
o
.
spy
(
o
,
"
status
"
,
12
,
"
job1 replaced
"
,
"
f
"
);
o
.
spy
(
o
,
"
value
"
,
{
"
ok
"
:
true
,
"
id
"
:
"
file
"
},
"
job1 ok
"
,
"
f
"
);
o
.
spy
(
o
,
"
status
"
,
12
,
"
job2 replaced
"
,
"
f2
"
);
o
.
spy
(
o
,
"
value
"
,
{
"
ok
"
:
true
,
"
id
"
:
"
file
"
},
"
job2 ok
"
,
"
f2
"
);
o
.
spy
(
o
,
"
value
"
,
{
"
ok
"
:
true
,
"
id
"
:
"
file
"
},
"
job3 ok
"
,
"
f3
"
);
o
.
spy
(
o
,
"
value
"
,
{
"
ok
"
:
true
,
"
id
"
:
"
file
"
},
"
job3 ok
"
,
"
f3
"
);
o
.
jio
.
put
({
"
_id
"
:
"
file
"
,
"
content
"
:
"
content
"
},
o
.
f
);
o
.
jio
.
put
({
"
_id
"
:
"
file
"
,
"
content
"
:
"
content
"
},
o
.
f
);
o
.
jio
.
put
({
"
_id
"
:
"
file
"
,
"
content
"
:
"
content
"
},
o
.
f2
);
o
.
jio
.
put
({
"
_id
"
:
"
file
"
,
"
content
"
:
"
content
"
},
o
.
f2
);
...
@@ -697,27 +697,6 @@ test ("One document aim jobs at the same time (Elimination)" , function () {
...
@@ -697,27 +697,6 @@ test ("One document aim jobs at the same time (Elimination)" , function () {
});
});
test
(
"
One document aim jobs at the same time (Not Acceptable)
"
,
function
()
{
var
o
=
generateTools
(
this
);
o
.
jio
=
JIO
.
newJio
({
"
type
"
:
"
dummyallok
"
});
o
.
spy
(
o
,
"
value
"
,
{
"
_id
"
:
"
file
"
,
"
title
"
:
"
get_title
"
},
"
job1
"
,
"
f
"
);
o
.
spy
(
o
,
"
status
"
,
11
,
"
job2 is not acceptable
"
,
"
f2
"
);
o
.
jio
.
get
({
"
_id
"
:
"
file
"
},
o
.
f
);
o
.
testLastJobId
(
1
,
"
job1 added to queue
"
);
o
.
waitUntilLastJobIs
(
"
on going
"
);
o
.
jio
.
get
({
"
_id
"
:
"
file
"
},
o
.
f2
);
o
.
testLastJobId
(
1
,
"
job2 not added
"
);
o
.
tick
(
o
,
1000
,
"
f
"
);
o
.
tick
(
o
,
"
f2
"
);
o
.
jio
.
stop
();
});
test
(
"
Server will be available soon (Wait for time)
"
,
function
()
{
test
(
"
Server will be available soon (Wait for time)
"
,
function
()
{
var
o
=
generateTools
(
this
);
var
o
=
generateTools
(
this
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment