mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-21 11:11:03 +02:00
- Rename 'client' to 'pulsar_client' in async_processor. Less likely to
be a name clash. - Turned on Metrics API in api-gateway.
This commit is contained in:
parent
93a50ab218
commit
950c624013
7 changed files with 19 additions and 19 deletions
|
|
@ -30,7 +30,7 @@ class AsyncProcessor:
|
||||||
self.id = params.get("id")
|
self.id = params.get("id")
|
||||||
|
|
||||||
# Register a pulsar client
|
# Register a pulsar client
|
||||||
self.pulsar_client = PulsarClient(**params)
|
self.pulsar_client_object = PulsarClient(**params)
|
||||||
|
|
||||||
# Initialise metrics, records the parameters
|
# Initialise metrics, records the parameters
|
||||||
ProcessorMetrics(processor = self.id).info({
|
ProcessorMetrics(processor = self.id).info({
|
||||||
|
|
@ -61,7 +61,7 @@ class AsyncProcessor:
|
||||||
self.config_sub_task = Consumer(
|
self.config_sub_task = Consumer(
|
||||||
|
|
||||||
taskgroup = self.taskgroup,
|
taskgroup = self.taskgroup,
|
||||||
client = self.client,
|
client = self.pulsar_client,
|
||||||
subscriber = config_subscriber_id,
|
subscriber = config_subscriber_id,
|
||||||
flow = None,
|
flow = None,
|
||||||
|
|
||||||
|
|
@ -85,16 +85,16 @@ class AsyncProcessor:
|
||||||
# This is called to stop all threads. An over-ride point for extra
|
# This is called to stop all threads. An over-ride point for extra
|
||||||
# functionality
|
# functionality
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self.client.close()
|
self.pulsar_client.close()
|
||||||
self.running = False
|
self.running = False
|
||||||
|
|
||||||
# Returns the pulsar host
|
# Returns the pulsar host
|
||||||
@property
|
@property
|
||||||
def pulsar_host(self): return self.client.pulsar_host
|
def pulsar_host(self): return self.pulsar_client_object.pulsar_host
|
||||||
|
|
||||||
# Returns the pulsar client
|
# Returns the pulsar client
|
||||||
@property
|
@property
|
||||||
def client(self): return self.pulsar_client.client
|
def pulsar_client(self): return self.pulsar_client_object.client
|
||||||
|
|
||||||
# Register a new event handler for configuration change
|
# Register a new event handler for configuration change
|
||||||
def register_config_handler(self, handler):
|
def register_config_handler(self, handler):
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ class ConsumerSpec(Spec):
|
||||||
consumer = Consumer(
|
consumer = Consumer(
|
||||||
taskgroup = processor.taskgroup,
|
taskgroup = processor.taskgroup,
|
||||||
flow = flow,
|
flow = flow,
|
||||||
client = processor.client,
|
client = processor.pulsar_client,
|
||||||
topic = definition[self.name],
|
topic = definition[self.name],
|
||||||
subscriber = processor.id + "--" + self.name,
|
subscriber = processor.id + "--" + self.name,
|
||||||
schema = self.schema,
|
schema = self.schema,
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ class ProducerSpec(Spec):
|
||||||
)
|
)
|
||||||
|
|
||||||
producer = Producer(
|
producer = Producer(
|
||||||
client = processor.client,
|
client = processor.pulsar_client,
|
||||||
topic = definition[self.name],
|
topic = definition[self.name],
|
||||||
schema = self.schema,
|
schema = self.schema,
|
||||||
metrics = producer_metrics,
|
metrics = producer_metrics,
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ class RequestResponseSpec(Spec):
|
||||||
)
|
)
|
||||||
|
|
||||||
rr = self.impl(
|
rr = self.impl(
|
||||||
client = processor.client,
|
client = processor.pulsar_client,
|
||||||
subscription = flow.id,
|
subscription = flow.id,
|
||||||
consumer_name = flow.id,
|
consumer_name = flow.id,
|
||||||
request_topic = definition[self.request_name],
|
request_topic = definition[self.request_name],
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ class SubscriberSpec(Spec):
|
||||||
)
|
)
|
||||||
|
|
||||||
subscriber = Subscriber(
|
subscriber = Subscriber(
|
||||||
client = processor.client,
|
client = processor.pulsar_client,
|
||||||
topic = definition[self.name],
|
topic = definition[self.name],
|
||||||
subscription = flow.id,
|
subscription = flow.id,
|
||||||
consumer_name = flow.id,
|
consumer_name = flow.id,
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ class Processor(AsyncProcessor):
|
||||||
|
|
||||||
self.config_request_consumer = Consumer(
|
self.config_request_consumer = Consumer(
|
||||||
taskgroup = self.taskgroup,
|
taskgroup = self.taskgroup,
|
||||||
client = self.client,
|
client = self.pulsar_client,
|
||||||
flow = None,
|
flow = None,
|
||||||
topic = config_request_queue,
|
topic = config_request_queue,
|
||||||
subscriber = id,
|
subscriber = id,
|
||||||
|
|
@ -97,14 +97,14 @@ class Processor(AsyncProcessor):
|
||||||
)
|
)
|
||||||
|
|
||||||
self.config_response_producer = Producer(
|
self.config_response_producer = Producer(
|
||||||
client = self.client,
|
client = self.pulsar_client,
|
||||||
topic = config_response_queue,
|
topic = config_response_queue,
|
||||||
schema = ConfigResponse,
|
schema = ConfigResponse,
|
||||||
metrics = config_response_metrics,
|
metrics = config_response_metrics,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.config_push_producer = Producer(
|
self.config_push_producer = Producer(
|
||||||
client = self.client,
|
client = self.pulsar_client,
|
||||||
topic = config_push_queue,
|
topic = config_push_queue,
|
||||||
schema = ConfigPush,
|
schema = ConfigPush,
|
||||||
metrics = config_push_metrics,
|
metrics = config_push_metrics,
|
||||||
|
|
@ -112,7 +112,7 @@ class Processor(AsyncProcessor):
|
||||||
|
|
||||||
self.flow_request_consumer = Consumer(
|
self.flow_request_consumer = Consumer(
|
||||||
taskgroup = self.taskgroup,
|
taskgroup = self.taskgroup,
|
||||||
client = self.client,
|
client = self.pulsar_client,
|
||||||
flow = None,
|
flow = None,
|
||||||
topic = flow_request_queue,
|
topic = flow_request_queue,
|
||||||
subscriber = id,
|
subscriber = id,
|
||||||
|
|
@ -122,7 +122,7 @@ class Processor(AsyncProcessor):
|
||||||
)
|
)
|
||||||
|
|
||||||
self.flow_response_producer = Producer(
|
self.flow_response_producer = Producer(
|
||||||
client = self.client,
|
client = self.pulsar_client,
|
||||||
topic = flow_response_queue,
|
topic = flow_response_queue,
|
||||||
schema = FlowResponse,
|
schema = FlowResponse,
|
||||||
metrics = flow_response_metrics,
|
metrics = flow_response_metrics,
|
||||||
|
|
|
||||||
|
|
@ -266,11 +266,11 @@ class Api:
|
||||||
# auth = self.auth,
|
# auth = self.auth,
|
||||||
# services = self.services,
|
# services = self.services,
|
||||||
# ),
|
# ),
|
||||||
# MetricsEndpoint(
|
MetricsEndpoint(
|
||||||
# endpoint_path = "/api/v1/metrics",
|
endpoint_path = "/api/v1/metrics",
|
||||||
# prometheus_url = self.prometheus_url,
|
prometheus_url = self.prometheus_url,
|
||||||
# auth = self.auth,
|
auth = self.auth,
|
||||||
# ),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
for ep in self.endpoints:
|
for ep in self.endpoints:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue