I have the following class that creates some comment
and save it to dynamo db that must contain unique comment id. How to "implement" counting - a simple counter that will create the unique id for a comment. I don't want to repeat rsu_id
value.
class RsuService(object):
next_id = 0
def __init__(self):
self.rsu_id = RsuService.next_id
RsuService.next_id += 1
async def create(self, alert_id, text):
message = {
'event_id': alert_id,
'text': text,
'is_rsu': True,
'comment_id': self.rsu_id
}
await save(message)
Is it good implementation? How to improve it?