Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Cameo
cameo
Commits
1717f6fb
Commit
1717f6fb
authored
Oct 12, 2020
by
legoc
Browse files
(split) Added getExitCode() in Instance, the server sends the status with the exit code
parent
77a8a9f2
Changes
6
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
1717f6fb
...
...
@@ -7,6 +7,7 @@
* Removed Configuration::getRetries().
* Added storage functions: This::storeKeyValue(), This::getKeyValue(), This::removeKey(), Instance::getKeyValue().
* Added Instance::getPastStates().
* Added Instance.getExitCode().
0.3.3
-----
...
...
include/Application.h
View file @
1717f6fb
...
...
@@ -234,6 +234,11 @@ public:
*/
std
::
set
<
State
>
getPastStates
()
const
;
/**
* Returns the exit code.
*/
int
getExitCode
()
const
;
bool
getBinaryResult
(
std
::
string
&
result
);
bool
getResult
(
std
::
string
&
result
);
...
...
@@ -260,6 +265,7 @@ private:
State
m_lastState
;
bool
m_hasResult
;
std
::
string
m_resultData
;
int
m_exitCode
;
std
::
unique_ptr
<
WaitingImpl
>
m_waiting
;
};
...
...
src/Application.cpp
View file @
1717f6fb
...
...
@@ -439,7 +439,8 @@ Instance::Instance(Server * server) :
m_pastStates
(
0
),
m_initialState
(
UNKNOWN
),
m_lastState
(
UNKNOWN
),
m_hasResult
(
false
)
{
m_hasResult
(
false
),
m_exitCode
(
-
1
)
{
m_waiting
.
reset
(
new
GenericWaitingImpl
(
bind
(
&
Instance
::
cancelWaitFor
,
this
)));
}
...
...
@@ -572,6 +573,11 @@ State Instance::waitFor(int states, const std::string& eventName, StateHandlerTy
m_pastStates
=
status
->
getPastStates
();
m_lastState
=
state
;
// Assign the exit code.
if
(
status
->
getExitCode
()
!=
-
1
)
{
m_exitCode
=
status
->
getExitCode
();
}
// Call the state handler.
if
(
handler
!=
nullptr
)
{
handler
(
state
);
...
...
@@ -651,6 +657,10 @@ std::set<State> Instance::getPastStates() const {
return
m_server
->
getPastStates
(
m_id
);
}
int
Instance
::
getExitCode
()
const
{
return
m_exitCode
;
}
bool
Instance
::
getBinaryResult
(
std
::
string
&
result
)
{
waitFor
();
...
...
src/EventStreamSocket.cpp
View file @
1717f6fb
...
...
@@ -59,6 +59,9 @@ std::unique_ptr<Event> EventStreamSocket::receive(bool blocking) {
application
::
State
state
=
event
[
message
::
StatusEvent
::
APPLICATION_STATE
].
GetInt
();
application
::
State
pastStates
=
event
[
message
::
StatusEvent
::
PAST_APPLICATION_STATES
].
GetInt
();
if
(
event
.
HasMember
(
message
::
StatusEvent
::
EXIT_CODE
))
{
return
unique_ptr
<
Event
>
(
new
StatusEvent
(
id
,
name
,
state
,
pastStates
,
event
[
message
::
StatusEvent
::
EXIT_CODE
].
GetInt
()));
}
return
unique_ptr
<
Event
>
(
new
StatusEvent
(
id
,
name
,
state
,
pastStates
));
}
else
if
(
response
==
message
::
Event
::
RESULT
)
{
...
...
src/StatusEvent.cpp
View file @
1717f6fb
...
...
@@ -20,14 +20,18 @@
namespace
cameo
{
StatusEvent
::
StatusEvent
(
int
id
,
const
std
::
string
&
name
,
application
::
State
state
,
application
::
State
pastStates
)
:
StatusEvent
::
StatusEvent
(
int
id
,
const
std
::
string
&
name
,
application
::
State
state
,
application
::
State
pastStates
,
int
exitCode
)
:
Event
(
id
,
name
),
m_state
(
state
),
m_pastStates
(
pastStates
)
{
m_pastStates
(
pastStates
),
m_exitCode
(
exitCode
)
{
}
StatusEvent
::
StatusEvent
(
const
StatusEvent
&
event
)
:
Event
(
event
),
m_state
(
event
.
m_state
),
m_pastStates
(
event
.
m_pastStates
)
{
Event
(
event
),
m_state
(
event
.
m_state
),
m_pastStates
(
event
.
m_pastStates
),
m_exitCode
(
event
.
m_exitCode
)
{
}
StatusEvent
*
StatusEvent
::
clone
()
{
...
...
@@ -42,6 +46,10 @@ application::State StatusEvent::getPastStates() const {
return
m_pastStates
;
}
int
StatusEvent
::
getExitCode
()
const
{
return
m_exitCode
;
}
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
cameo
::
StatusEvent
&
status
)
{
os
<<
"name="
<<
status
.
m_name
<<
"
\n
id="
<<
status
.
m_id
...
...
src/StatusEvent.h
View file @
1717f6fb
...
...
@@ -28,17 +28,19 @@ class StatusEvent : public Event {
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
,
const
StatusEvent
&
);
public:
StatusEvent
(
int
id
,
const
std
::
string
&
name
,
application
::
State
state
,
application
::
State
pastStates
);
StatusEvent
(
int
id
,
const
std
::
string
&
name
,
application
::
State
state
,
application
::
State
pastStates
,
int
exitCode
=
-
1
);
StatusEvent
(
const
StatusEvent
&
event
);
virtual
StatusEvent
*
clone
();
application
::
State
getState
()
const
;
application
::
State
getPastStates
()
const
;
int
getExitCode
()
const
;
private:
application
::
State
m_state
;
application
::
State
m_pastStates
;
int
m_exitCode
;
// TODO replace with optional
};
std
::
ostream
&
operator
<<
(
std
::
ostream
&
,
const
StatusEvent
&
);
...
...
Shervin Nourbakhsh
@nourbakhsh
mentioned in commit
46e44691
·
Apr 23, 2021
mentioned in commit
46e44691
mentioned in commit 46e44691a03808a23a464818487b0dd014a9c57e
Toggle commit list
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