Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dbp-relay-checkin-bundle
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
digital blueprint
Check In
dbp-relay-checkin-bundle
Commits
b94985f5
Commit
b94985f5
authored
3 years ago
by
Reiter, Christoph
Browse files
Options
Downloads
Patches
Plain Diff
Add some basic health checks
parent
a79f1b8d
No related branches found
No related tags found
No related merge requests found
Pipeline
#89360
passed
3 years ago
Stage: test
Changes
3
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Resources/config/services.yaml
+4
-0
4 additions, 0 deletions
src/Resources/config/services.yaml
src/Service/CheckinApi.php
+22
-0
22 additions, 0 deletions
src/Service/CheckinApi.php
src/Service/HealthCheck.php
+64
-0
64 additions, 0 deletions
src/Service/HealthCheck.php
with
90 additions
and
0 deletions
src/Resources/config/services.yaml
+
4
−
0
View file @
b94985f5
...
...
@@ -3,6 +3,10 @@ services:
public
:
false
autowire
:
true
Dbp\Relay\CheckinBundle\Service\HealthCheck
:
autowire
:
true
autoconfigure
:
true
Dbp\Relay\CheckinBundle\DataPersister\
:
resource
:
'
../../DataPersister'
autowire
:
true
...
...
This diff is collapsed.
Click to expand it.
src/Service/CheckinApi.php
+
22
−
0
View file @
b94985f5
...
...
@@ -141,6 +141,28 @@ class CheckinApi implements LoggerAwareInterface
return
new
Client
(
$client_options
);
}
/**
* Check if CampusQR is reachable.
*/
public
function
checkConnection
():
void
{
$client
=
$this
->
getClient
();
$client
->
request
(
'GET'
,
$this
->
campusQRUrl
);
}
/**
* Check if we can talk to the API.
*/
public
function
checkApi
():
void
{
$client
=
$this
->
getClient
();
$options
=
[
'headers'
=>
[
'X-Authorization'
=>
$this
->
campusQRToken
],
];
$url
=
$this
->
urls
->
getLocationListRequestUrl
(
$this
->
campusQRUrl
);
$client
->
request
(
'GET'
,
$url
,
$options
);
}
private
function
getLocationClient
():
Client
{
$stack
=
HandlerStack
::
create
(
$this
->
clientHandler
);
...
...
This diff is collapsed.
Click to expand it.
src/Service/HealthCheck.php
0 → 100644
+
64
−
0
View file @
b94985f5
<?php
declare
(
strict_types
=
1
);
namespace
Dbp\Relay\CheckinBundle\Service
;
use
Dbp\Relay\CoreBundle\HealthCheck\CheckInterface
;
use
Dbp\Relay\CoreBundle\HealthCheck\CheckOptions
;
use
Dbp\Relay\CoreBundle\HealthCheck\CheckResult
;
class
HealthCheck
implements
CheckInterface
{
private
$api
;
public
function
__construct
(
CheckinApi
$api
)
{
$this
->
api
=
$api
;
}
public
function
getName
():
string
{
return
'checkin'
;
}
public
function
checkConnection
():
CheckResult
{
$result
=
new
CheckResult
(
'Check if CampusQR is reachable'
);
try
{
$this
->
api
->
checkConnection
();
}
catch
(
\Throwable
$e
)
{
$result
->
set
(
CheckResult
::
STATUS_FAILURE
,
$e
->
getMessage
());
return
$result
;
}
$result
->
set
(
CheckResult
::
STATUS_SUCCESS
);
return
$result
;
}
public
function
checkApi
():
CheckResult
{
$result
=
new
CheckResult
(
'Check if we can use the CampusQR API'
);
try
{
$this
->
api
->
checkApi
();
}
catch
(
\Throwable
$e
)
{
$result
->
set
(
CheckResult
::
STATUS_FAILURE
,
$e
->
getMessage
());
return
$result
;
}
$result
->
set
(
CheckResult
::
STATUS_SUCCESS
);
return
$result
;
}
public
function
check
(
CheckOptions
$options
):
array
{
return
[
$this
->
checkConnection
(),
$this
->
checkApi
(),
];
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment