def set_suppliers(customer_idurl, ecc_map, suppliers_list, revision=None, publisher_idurl=None, expire=60 * 60): if _Debug: lg.args(_DebugLevel, customer_idurl=customer_idurl, ecc_map=ecc_map, suppliers_list=suppliers_list, revision=revision) return dht_service.set_valid_data( key=dht_service.make_key( key=strng.to_text(customer_idurl), prefix='suppliers', ), json_data={ 'type': 'suppliers', 'timestamp': utime.get_sec1970(), 'revision': 0 if revision is None else revision, 'publisher_idurl': publisher_idurl.to_text() if publisher_idurl else None, 'customer_idurl': customer_idurl.to_text(), 'ecc_map': ecc_map, 'suppliers': list(map(lambda i: i.to_text(), suppliers_list)), }, rules=get_rules('suppliers'), expire=expire, collect_results=True, )
def set_message_broker(customer_idurl, broker_idurl, position=0, revision=None, expire=60 * 60): if _Debug: lg.args(_DebugLevel, customer=customer_idurl, pos=position, broker=broker_idurl, rev=revision) return dht_service.set_valid_data( key=dht_service.make_key( key='%s%d' % (strng.to_text(customer_idurl), position), prefix='message_broker', ), json_data={ 'type': 'message_broker', 'timestamp': utime.get_sec1970(), 'revision': 0 if revision is None else revision, 'customer_idurl': customer_idurl.to_text(), 'broker_idurl': broker_idurl.to_text(), # 'archive_folder_path': archive_folder_path, 'position': position, }, rules=get_rules('message_broker'), expire=expire, collect_results=True, )
def set_nickname(key, idurl): if _Debug: lg.args(_DebugLevel, key, idurl) nickname, _, pos = key.partition(':') json_data={ 'type': 'nickname', 'timestamp': utime.get_sec1970(), 'idurl': idurl.to_bin(), 'nickname': nickname, 'position': pos, } return dht_service.set_valid_data(key=key, json_data=json_data, rules=get_rules('nickname'), )
def set_identity(idurl, raw_xml_data): if _Debug: lg.args(_DebugLevel, idurl) return dht_service.set_valid_data( key=idurl, json_data={ 'type': 'identity', 'timestamp': utime.get_sec1970(), 'idurl': idurl, 'identity': raw_xml_data, }, rules=get_rules('identity'), )
def set_relation(key, idurl, data, prefix, index): if _Debug: lg.args(_DebugLevel, key, idurl, prefix, index) return dht_service.set_valid_data( key=key, json_data={ 'type': 'relation', 'timestamp': utime.get_sec1970(), 'idurl': idurl, 'index': index, 'prefix': prefix, 'data': data, }, rules=get_rules('relation'), expire=60 * 5, )
def set_relation(key, idurl, data, prefix, index, expire=60 * 60): # TODO: set_relation() is OBSOLETE... # because of performance reasonse it is better to maintain only one DHT record for each relation exclusively # need to use another solution here instead of storing multiple records... # check out family_memeber() if _Debug: lg.args(_DebugLevel, key, idurl, prefix, index) return dht_service.set_valid_data( key=key, json_data={ 'type': 'relation', 'timestamp': utime.get_sec1970(), 'idurl': idurl, 'index': index, 'prefix': prefix, 'data': data, }, rules=get_rules('relation'), expire=expire, )
def set_suppliers(customer_idurl, ecc_map, suppliers_list, revision=None, publisher_idurl=None, expire=60 * 60): return dht_service.set_valid_data( key=dht_service.make_key( key=strng.to_text(customer_idurl), prefix='suppliers', ), json_data={ 'type': 'suppliers', 'timestamp': utime.get_sec1970(), 'revision': revision, 'publisher_idurl': publisher_idurl, 'customer_idurl': customer_idurl, 'ecc_map': ecc_map, 'suppliers': suppliers_list, }, rules=get_rules('suppliers'), expire=expire, collect_results=True, )