Leak the adequate amount of data from the bucket.

        This should be called before any consumption takes place.

        Returns:
            int: the new capacity of the bucket

def leak(self):
        """Leak the adequate amount of data from the bucket.

        This should be called before any consumption takes place.

        Returns:
            int: the new capacity of the bucket
        """
        capacity, last_leak = self.storage.mget(self.key_amount, self.key_last_leak,
                coherent=True)

        now = time.time()

        if last_leak:
            elapsed = now - last_leak
            decrement = elapsed * self.rate

            new_capacity = max(int(capacity - decrement), 0)
        else:
            new_capacity = 0

        self.storage.mset({
            self.key_amount: new_capacity,
            self.key_last_leak: now,
        })

        return new_capacity