mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-08 21:02:12 +02:00
Concurrency in triples query
This commit is contained in:
parent
72ddc9deb8
commit
0786c558b2
1 changed files with 11 additions and 1 deletions
|
|
@ -17,12 +17,14 @@ from . producer_spec import ProducerSpec
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
default_ident = "triples-query"
|
default_ident = "triples-query"
|
||||||
|
default_concurrency = 10
|
||||||
|
|
||||||
class TriplesQueryService(FlowProcessor):
|
class TriplesQueryService(FlowProcessor):
|
||||||
|
|
||||||
def __init__(self, **params):
|
def __init__(self, **params):
|
||||||
|
|
||||||
id = params.get("id")
|
id = params.get("id")
|
||||||
|
concurrency = params.get("concurrency", default_concurrency)
|
||||||
|
|
||||||
super(TriplesQueryService, self).__init__(**params | { "id": id })
|
super(TriplesQueryService, self).__init__(**params | { "id": id })
|
||||||
|
|
||||||
|
|
@ -30,7 +32,8 @@ class TriplesQueryService(FlowProcessor):
|
||||||
ConsumerSpec(
|
ConsumerSpec(
|
||||||
name = "request",
|
name = "request",
|
||||||
schema = TriplesQueryRequest,
|
schema = TriplesQueryRequest,
|
||||||
handler = self.on_message
|
handler = self.on_message,
|
||||||
|
concurrency = concurrency,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -109,6 +112,13 @@ class TriplesQueryService(FlowProcessor):
|
||||||
|
|
||||||
FlowProcessor.add_args(parser)
|
FlowProcessor.add_args(parser)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'-c', '--concurrency',
|
||||||
|
type=int,
|
||||||
|
default=default_concurrency,
|
||||||
|
help=f'Number of concurrent requests (default: {default_concurrency})'
|
||||||
|
)
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
|
|
||||||
Processor.launch(default_ident, __doc__)
|
Processor.launch(default_ident, __doc__)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue