mirror of
https://github.com/projecthorus/sondehub-infra.git
synced 2024-12-18 20:57:56 +00:00
cache config
This commit is contained in:
parent
d3ca3cebfe
commit
735827d4cb
@ -16,6 +16,8 @@ import es
|
||||
|
||||
# Setup SNS
|
||||
|
||||
TOPIC = config_handler.get("SNS","TOPIC")
|
||||
|
||||
def set_connection_header(request, operation_name, **kwargs):
|
||||
request.headers['Connection'] = 'keep-alive'
|
||||
|
||||
@ -28,7 +30,7 @@ def post(payload):
|
||||
f.write(json.dumps(payload).encode('utf-8'))
|
||||
payload = base64.b64encode(compressed.getvalue()).decode("utf-8")
|
||||
sns.publish(
|
||||
TopicArn=config_handler.get("SNS","TOPIC"),
|
||||
TopicArn=TOPIC,
|
||||
Message=payload
|
||||
)
|
||||
|
||||
|
@ -13,6 +13,8 @@ def set_connection_header(request, operation_name, **kwargs):
|
||||
sns = boto3.client("sns",region_name="us-east-1")
|
||||
sns.meta.events.register('request-created.sns', set_connection_header)
|
||||
|
||||
TOPIC = config_handler.get("HAM_SNS","TOPIC")
|
||||
|
||||
def check_fields_are_number(field, telemetry):
|
||||
if type(telemetry[field]) != float and type(telemetry[field]) != int:
|
||||
return (False, f"{field} should not be a float")
|
||||
@ -47,7 +49,7 @@ def telemetry_hide_filter(telemetry):
|
||||
|
||||
def post(payload):
|
||||
sns.publish(
|
||||
TopicArn=config_handler.get("HAM_SNS","TOPIC"),
|
||||
TopicArn=TOPIC,
|
||||
Message=json.dumps(payload)
|
||||
)
|
||||
|
||||
|
@ -13,6 +13,10 @@ import sys
|
||||
import uuid
|
||||
import config_handler
|
||||
|
||||
MQTT_ID = config_handler.get("MQTT","ID")
|
||||
MQTT_PREFIX = config_handler.get("MQTT","PREFIX")
|
||||
MQTT_BATCH = config_handler.get("MQTT","BATCH")
|
||||
|
||||
client = mqtt.Client(transport="websockets")
|
||||
|
||||
connected_flag = False
|
||||
@ -120,18 +124,18 @@ def lambda_handler(event, context):
|
||||
|
||||
body = json.dumps(payload)
|
||||
|
||||
serial = payload[config_handler.get("MQTT","ID")]
|
||||
serial = payload[MQTT_ID]
|
||||
while not connected_flag:
|
||||
time.sleep(0.01) # wait until connected
|
||||
client.publish(
|
||||
topic=f'{config_handler.get("MQTT","PREFIX")}/{serial}',
|
||||
topic=f'{MQTT_PREFIX}/{serial}',
|
||||
payload=body,
|
||||
qos=0,
|
||||
retain=False
|
||||
)
|
||||
if serial not in cache: # low bandwidth feeds with just the first packet
|
||||
client.publish(
|
||||
topic=f'{config_handler.get("MQTT","PREFIX")}-new/{serial}',
|
||||
topic=f'{MQTT_PREFIX}-new/{serial}',
|
||||
payload=body,
|
||||
qos=0,
|
||||
retain=False
|
||||
@ -141,7 +145,7 @@ def lambda_handler(event, context):
|
||||
while len(cache) > MAX_CACHE:
|
||||
del cache[next(iter(cache))]
|
||||
client.publish(
|
||||
topic=config_handler.get("MQTT","BATCH"),
|
||||
topic=MQTT_BATCH,
|
||||
payload=json.dumps(payloads),
|
||||
qos=0,
|
||||
retain=False
|
||||
|
@ -22,6 +22,8 @@ import config_handler
|
||||
logs = boto3.client('logs')
|
||||
sequenceToken = None
|
||||
|
||||
TOPIC = config_handler.get("SNS","TOPIC")
|
||||
|
||||
def set_connection_header(request, operation_name, **kwargs):
|
||||
request.headers['Connection'] = 'keep-alive'
|
||||
|
||||
@ -368,7 +370,7 @@ def post(payload):
|
||||
f.write(json.dumps(payload).encode('utf-8'))
|
||||
payload = base64.b64encode(compressed.getvalue()).decode("utf-8")
|
||||
sns.publish(
|
||||
TopicArn=config_handler.get("SNS","TOPIC"),
|
||||
TopicArn=TOPIC,
|
||||
Message=payload
|
||||
)
|
||||
|
||||
|
@ -14,6 +14,8 @@ CALLSIGN_BLOCK_LIST = ["CHANGEME_RDZTTGO"]
|
||||
|
||||
import es
|
||||
|
||||
TOPIC = config_handler.get("SNS","TOPIC")
|
||||
|
||||
# Setup SNS
|
||||
|
||||
def set_connection_header(request, operation_name, **kwargs):
|
||||
@ -28,7 +30,7 @@ def post(payload):
|
||||
f.write(json.dumps(payload).encode('utf-8'))
|
||||
payload = base64.b64encode(compressed.getvalue()).decode("utf-8")
|
||||
sns.publish(
|
||||
TopicArn=config_handler.get("SNS","TOPIC"),
|
||||
TopicArn=TOPIC,
|
||||
Message=payload
|
||||
)
|
||||
|
||||
|
@ -7,6 +7,8 @@ from email.utils import parsedate
|
||||
import os
|
||||
import config_handler
|
||||
|
||||
TOPIC = config_handler.get("HAM_SNS","TOPIC")
|
||||
|
||||
HELIUM_GW_VERSION = "2023.10.14"
|
||||
|
||||
# Mappings between input (Helium) field names, and field names fed into SondeHub-Amateur
|
||||
@ -47,7 +49,7 @@ sns.meta.events.register('request-created.sns', set_connection_header)
|
||||
|
||||
def post(payload):
|
||||
sns.publish(
|
||||
TopicArn=config_handler.get("HAM_SNS","TOPIC"),
|
||||
TopicArn=TOPIC,
|
||||
Message=json.dumps(payload)
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user