github.com/ydb-platform/ydb-go-sdk/v3@v3.89.2/topic/client.go (about)

     1  package topic
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/ydb-platform/ydb-go-sdk/v3/internal/tx"
     7  	"github.com/ydb-platform/ydb-go-sdk/v3/topic/topiclistener"
     8  	"github.com/ydb-platform/ydb-go-sdk/v3/topic/topicoptions"
     9  	"github.com/ydb-platform/ydb-go-sdk/v3/topic/topicreader"
    10  	"github.com/ydb-platform/ydb-go-sdk/v3/topic/topictypes"
    11  	"github.com/ydb-platform/ydb-go-sdk/v3/topic/topicwriter"
    12  )
    13  
    14  // Client is interface for topic client
    15  // Attention: the interface may be extended in the future.
    16  type Client interface {
    17  	// Alter change topic options
    18  	Alter(ctx context.Context, path string, opts ...topicoptions.AlterOption) error
    19  
    20  	// Create topic
    21  	Create(ctx context.Context, path string, opts ...topicoptions.CreateOption) error
    22  
    23  	// Describe topic
    24  	Describe(ctx context.Context, path string, opts ...topicoptions.DescribeOption) (topictypes.TopicDescription, error)
    25  
    26  	// Describe topic consumer
    27  	DescribeTopicConsumer(
    28  		ctx context.Context, path string, consumer string, opts ...topicoptions.DescribeConsumerOption,
    29  	) (topictypes.TopicConsumerDescription, error)
    30  
    31  	// Drop topic
    32  	Drop(ctx context.Context, path string, opts ...topicoptions.DropOption) error
    33  
    34  	// StartListener starts read listen topic with the handler
    35  	// it is fast non block call, connection starts in background
    36  	//
    37  	// Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental
    38  	StartListener(
    39  		consumer string,
    40  		handler topiclistener.EventHandler,
    41  		readSelectors topicoptions.ReadSelectors,
    42  		opts ...topicoptions.ListenerOption,
    43  	) (*topiclistener.TopicListener, error)
    44  
    45  	// StartReader start read messages from topic
    46  	// it is fast non block call, connection starts in background
    47  	StartReader(
    48  		consumer string,
    49  		readSelectors topicoptions.ReadSelectors,
    50  		opts ...topicoptions.ReaderOption,
    51  	) (*topicreader.Reader, error)
    52  
    53  	// StartWriter start write session to topic
    54  	// it is fast non block call, connection starts in background
    55  	StartWriter(topicPath string, opts ...topicoptions.WriterOption) (*topicwriter.Writer, error)
    56  
    57  	// StartTransactionalWriter start writer for write messages within transaction
    58  	//
    59  	// Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental
    60  	StartTransactionalWriter(
    61  		tx tx.Identifier,
    62  		topicpath string,
    63  		opts ...topicoptions.WriterOption,
    64  	) (*topicwriter.TxWriter, error)
    65  }