How to use the eventsourcing.domain.model.decorators.retry function in eventsourcing

To help you get started, we’ve selected a few eventsourcing examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github johnbywater / eventsourcing / eventsourcing / infrastructure / cassandra / datastore.py View on Github external
    @retry(NoHostAvailable, max_attempts=10, wait=0.5)
    def truncate_tables(self):
        for table in self.tables:
            remaining_objects = table.objects.all().limit(10)
            while remaining_objects:
                for obj in remaining_objects:
                    obj.delete()
                remaining_objects = table.objects.all().limit(10)
github johnbywater / eventsourcing / eventsourcing / system / runner.py View on Github external
    @retry((OperationalError, RecordConflictError), max_attempts=100, wait=0.01)
    def _run_process(self, prompt: Optional[PromptToPull] = None) -> None:
        self.app.run(prompt)
github johnbywater / eventsourcing / eventsourcing / application / multiprocess.py View on Github external
    @retry((OperationalError, RecordConflictError), max_attempts=100, wait=0.1)
    def run_process(self, prompt=None):
        self.process.run(prompt)
github johnbywater / eventsourcing / eventsourcing / infrastructure / cassandra / datastore.py View on Github external
    @retry(NoHostAvailable, max_attempts=10, wait=0.5)
    def drop_tables(self):
        drop_keyspace(name=self.settings.default_keyspace)
github johnbywater / eventsourcing / eventsourcing / infrastructure / cassandra / datastore.py View on Github external
    @retry((NoHostAvailable, OperationTimedOut), max_attempts=10, wait=0.5)
    def setup_tables(self):
        # Avoid warnings about this variable not being set.
        os.environ["CQLENG_ALLOW_SCHEMA_MANAGEMENT"] = "1"

        # Attempt to create the keyspace.
        create_keyspace_simple(
            name=self.settings.default_keyspace,
            replication_factor=self.settings.replication_factor,
        )
        for table in self.tables:
            self.setup_table(table)
github johnbywater / eventsourcing / eventsourcing / system / runner.py View on Github external
    @retry(CausalDependencyFailed, max_attempts=100, wait=0.2)
    @retry((OperationalError, RecordConflictError), max_attempts=100, wait=0.01)
    def _run_process(self, prompt: Optional[PromptToPull] = None) -> None:
        self.app.run(prompt)
github johnbywater / eventsourcing / eventsourcing / application / multiprocess.py View on Github external
    @retry(CausalDependencyFailed, max_attempts=100, wait=0.1)
    def loop_on_prompts(self):

        # Run once, in case prompts were missed.
        self.run_process()

        # Loop on getting prompts.
        while True:
            try:
                # Todo: Make the poll interval gradually increase if there are only timeouts?
                item = self.inbox.get(timeout=self.poll_interval)
                self.inbox.task_done()

                if item == "QUIT":
                    self.process.close()
                    break
github johnbywater / eventsourcing / eventsourcing / domain / model / array.py View on Github external
    @retry(ConcurrencyError, max_attempts=50, wait=0.01)
    def append(self, item):
        """Sets item in next position after the last item."""
        self.__setitem__(self.get_next_position(), item)
github johnbywater / eventsourcing / eventsourcing / contrib / paxos / application.py View on Github external
    @retry((RecordConflictError, OperationalError), max_attempts=10, wait=0)
    def propose_value(self, key, value, assume_leader=False):
        """
        Starts new Paxos aggregate and proposes a value for a key.

        Decorated with retry in case of notification log conflict
        or operational error.
        """
        assert isinstance(key, UUID)
        paxos_aggregate = PaxosAggregate.start(
            originator_id=key, quorum_size=self.quorum_size, network_uid=self.name
        )
        msg = paxos_aggregate.propose_value(value, assume_leader=assume_leader)
        while msg:
            msg = paxos_aggregate.receive_message(msg)
        new_events = paxos_aggregate.__batch_pending_events__()
        self.record_process_event(ProcessEvent(new_events))
github johnbywater / eventsourcing / eventsourcing / domain / model / sequence.py View on Github external
    @retry(ConcurrencyError, max_retries=50, wait=0.01)
    def append(self, item, position=None):
        root, height, apex, last, i = self.get_last_sequence()
        assert isinstance(root, Sequence)

        thread_id = get_ident()

        if last is None:
            # print("{} Building root for: {}".format(thread_id, self.id))

            root.register()
            apex_id = self.create_sequence_id(0, self.repo.sequence_size)
            apex = self.subrepo[apex_id]
            apex.register()
            root.append(apex_id, position=0)
            last = apex
        assert isinstance(last, Sequence)