async def publish_event(
        self,
        stream: str,
        type: str,
        body: Optional[Any] = None,
        id: Optional[uuid.UUID] = None,
        metadata: Optional[Any] = None,
        expected_version: int = -2,
        require_master: bool = False,
    ) -> None:
        """
        Publish a single event to the EventStore.

        This method publishes a single event to the remote server and waits

        for acknowledgement.

        Args:
            stream: The stream to publish the event to.
            type: the event's type.
            body: a serializable body for the event.
            id: a unique id for the event. PhotonPump will automatically generate an
                id if none is provided.
            metadata: Optional serializable metadata block for the event.
            expected_version: Used for concurrency control.
                If a positive integer is provided, EventStore will check that the stream
                is at that version before accepting a write.

                There are three magic values:
                    -4: StreamMustExist. Checks that the stream already exists.
                    -2: Any. Disables concurrency checks
                    -1: NoStream. Checks that the stream does not yet exist.
                    0: EmptyStream. Checks that the stream has been explicitly created but
                    does not yet contain any events.
            require_master: If true, slave nodes will reject this message.

        Examples:

            >>> async with connect() as conn:
            >>>     await conn.publish_event(
            >>>         "inventory_item-1",
            >>>         "item_created",
            >>>         body={ "item-id": 1, "created-date": "2018-08-19" },
            >>>         expected_version=ExpectedVersion.StreamMustNotExist
            >>>     )
            >>>
            >>>     await conn.publish_event(
            >>>         "inventory_item-1",
            >>>         "item_deleted",
            >>>         expected_version=1,
            >>>         metadata={'deleted-by': 'bob' }
            >>>     )
        """
        event = msg.NewEvent(type, id or uuid.uuid4(), body, metadata)
        conversation = convo.WriteEvents(
            stream,
            [event],
            expected_version=expected_version,
            require_master=require_master,
        )
        result = await self.dispatcher.start_conversation(conversation)

        return await result
async def publish_event ( self , stream : str , type : str , body : Optional [ Any ] = None , id : Optional [ uuid . UUID ] = None , metadata : Optional [ Any ] = None , expected_version : int = - 2 , require_master : bool = False , ) -> None : event = msg . NewEvent ( type , id or uuid . uuid4 ( ) , body , metadata ) conversation = convo . WriteEvents ( stream , [ event ] , expected_version = expected_version , require_master = require_master , ) result = await self . dispatcher . start_conversation ( conversation ) return await result
Publish a single event to the EventStore.

        This method publishes a single event to the remote server and waits

        for acknowledgement.

        Args:
            stream: The stream to publish the event to.
            type: the event's type.
            body: a serializable body for the event.
            id: a unique id for the event. PhotonPump will automatically generate an
                id if none is provided.
            metadata: Optional serializable metadata block for the event.
            expected_version: Used for concurrency control.
                If a positive integer is provided, EventStore will check that the stream
                is at that version before accepting a write.

                There are three magic values:
                    -4: StreamMustExist. Checks that the stream already exists.
                    -2: Any. Disables concurrency checks
                    -1: NoStream. Checks that the stream does not yet exist.
                    0: EmptyStream. Checks that the stream has been explicitly created but
                    does not yet contain any events.
            require_master: If true, slave nodes will reject this message.

        Examples:

            >>> async with connect() as conn:
            >>>     await conn.publish_event(
            >>>         "inventory_item-1",
            >>>         "item_created",
            >>>         body={ "item-id": 1, "created-date": "2018-08-19" },
            >>>         expected_version=ExpectedVersion.StreamMustNotExist
            >>>     )
            >>>
            >>>     await conn.publish_event(
            >>>         "inventory_item-1",
            >>>         "item_deleted",
            >>>         expected_version=1,
            >>>         metadata={'deleted-by': 'bob' }
            >>>     )