Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
engine-api
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
Container Registry
Model registry
Operate
Environments
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AURA
engine-api
Commits
eaab4bf4
Commit
eaab4bf4
authored
4 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
Settings for deployment mode.
parent
85872d54
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
config/sample/sample-development.engine-api.ini
+18
-0
18 additions, 0 deletions
config/sample/sample-development.engine-api.ini
src/service.py
+33
-1
33 additions, 1 deletion
src/service.py
with
51 additions
and
1 deletion
config/sample/sample-development.engine-api.ini
+
18
−
0
View file @
eaab4bf4
...
@@ -20,3 +20,21 @@ debug_flask="false"
...
@@ -20,3 +20,21 @@ debug_flask="false"
[api]
[api]
api_port
=
8008
api_port
=
8008
[federation]
# Engine API supports two deployment models:
#
# - "main": Deployed together with some `engine` (Single instance or for redundant engines)
# - "sync": Independent deployment, in charge of syncing data of two main-nodes
#
# The `synch_host` identifies the host where data is gathered from/synced to, depended on the
# chosen `node_type`.
#
node_type
=
"main"
sync_host
=
"http://localhost:8010"
; node_type="sync"
; main_host_1="http://localhost:8008"
; main_host_2="http://localhost:8009"
This diff is collapsed.
Click to expand it.
src/service.py
+
33
−
1
View file @
eaab4bf4
...
@@ -19,9 +19,18 @@
...
@@ -19,9 +19,18 @@
import
datetime
import
datetime
from
enum
import
Enum
from
models
import
PlayLog
,
TrackSchema
from
models
import
PlayLog
,
TrackSchema
class
NodeType
(
Enum
):
"""
Types of API Server deployment models.
"""
MAIN
=
"
main
"
SYNC
=
"
sync
"
class
ApiService
():
class
ApiService
():
"""
"""
...
@@ -30,12 +39,35 @@ class ApiService():
...
@@ -30,12 +39,35 @@ class ApiService():
config
=
None
config
=
None
logger
=
None
logger
=
None
node_type
=
None
sync_host
=
None
main_hosts
=
None
def
__init__
(
self
,
config
,
logger
):
def
__init__
(
self
,
config
,
logger
):
"""
Initialize Service.
"""
self
.
config
=
config
self
.
config
=
config
self
.
logger
=
logger
self
.
logger
=
logger
# Evaluate deployment mode
node_type
=
config
.
get
(
"
node_type
"
)
if
not
node_type
==
NodeType
.
MAIN
.
value
:
self
.
node_type
=
NodeType
.
SYNC
self
.
main_hosts
=
[
config
.
get
(
"
main_host_1
"
),
config
.
get
(
"
main_host_2
"
)
]
self
.
logger
.
info
(
"
Running in
'
SYNC
'
mode. Syncing data of
'
%s
'"
%
(
self
.
main_hosts
))
else
:
self
.
node_type
=
NodeType
.
MAIN
# Validate sync host
self
.
sync_host
=
config
.
get
(
"
sync_host
"
)
if
not
self
.
sync_host
:
raise
ValueError
(
"
Invalid sync_host
'
%s
'
!
"
%
self
.
sync_host
)
self
.
logger
.
info
(
"
Running in
'
MAIN
'
mode. Pushing data to
'
%s
'"
%
(
self
.
sync_host
))
def
current_track
(
self
):
def
current_track
(
self
):
"""
"""
...
@@ -71,9 +103,9 @@ class ApiService():
...
@@ -71,9 +103,9 @@ class ApiService():
Get paginated playlog entries for since the given timestamp.
Get paginated playlog entries for since the given timestamp.
Args:
Args:
since_time (datetime): Get entries after this timestamp (e.g. '2020-08-29T09:12:33.001Z')
page (Integer): The number of items to skip before starting to collect the result set
page (Integer): The number of items to skip before starting to collect the result set
size (Integer): The numbers of items to return per page
size (Integer): The numbers of items to return per page
since_time (datetime): Optionally, get entries after this timestamp (e.g.
"
2020-08-29T09:12:33.001Z
"
)
Returns:
Returns:
(List[PlayLogEntry])
(List[PlayLogEntry])
...
...
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