@@ -1576,7 +1576,7 @@ def redeliver_unacknowledged_messages(self):
15761576 """
15771577 self ._consumer .redeliver_unacknowledged_messages ()
15781578
1579- def seek (self , messageid ):
1579+ def seek (self , messageid : Union [ MessageId , _pulsar . MessageId , int ] ):
15801580 """
15811581 Reset the subscription associated with this consumer to a specific message id or publish timestamp.
15821582 The message id can either be a specific message or represent the first or last messages in the topic.
@@ -1586,10 +1586,10 @@ def seek(self, messageid):
15861586 Parameters
15871587 ----------
15881588
1589- messageid:
1589+ messageid: MessageId, _pulsar.MessageId or int
15901590 The message id for seek, OR an integer event time to seek to
15911591 """
1592- self ._consumer .seek (messageid )
1592+ self ._consumer .seek (_seek_arg_convert ( messageid ) )
15931593
15941594 def close (self ):
15951595 """
@@ -1745,7 +1745,7 @@ def has_message_available(self):
17451745 """
17461746 return self ._reader .has_message_available ();
17471747
1748- def seek (self , messageid ):
1748+ def seek (self , messageid : Union [ MessageId , _pulsar . MessageId , int ] ):
17491749 """
17501750 Reset this reader to a specific message id or publish timestamp.
17511751 The message id can either be a specific message or represent the first or last messages in the topic.
@@ -1755,10 +1755,10 @@ def seek(self, messageid):
17551755 Parameters
17561756 ----------
17571757
1758- messageid:
1758+ messageid: MessageId, _pulsar.MessageId or int
17591759 The message id for seek, OR an integer event time to seek to
17601760 """
1761- self ._reader .seek (messageid )
1761+ self ._reader .seek (_seek_arg_convert ( messageid ) )
17621762
17631763 def close (self ):
17641764 """
@@ -1829,3 +1829,11 @@ def wrapper(consumer, msg):
18291829 m ._schema = schema
18301830 listener (c , m )
18311831 return wrapper
1832+
1833+ def _seek_arg_convert (seek_arg ):
1834+ if isinstance (seek_arg , MessageId ):
1835+ return seek_arg ._msg_id
1836+ elif isinstance (seek_arg , (_pulsar .MessageId , int )):
1837+ return seek_arg
1838+ else :
1839+ raise ValueError (f"invalid seek_arg type { type (seek_arg )} " )
0 commit comments