|
22 | 22 | errors.New("ydb: first connection attempt not finished"), |
23 | 23 | )) |
24 | 24 | errReaderClosed = xerrors.Wrap(errors.New("ydb: reader closed")) |
25 | | - errUnexpectedEmptyConsumername = xerrors.Wrap(errors.New("ydb: create ydb reader with empty consumer name. Set one of: consumer name or option WithReaderWithoutConsumer")) //nolint:lll |
26 | 25 | errSetConsumerAndNoConsumer = xerrors.Wrap(errors.New("ydb: reader has non empty consumer name and set option WithReaderWithoutConsumer. Only one of them must be set")) //nolint:lll |
27 | | - errCantCommitWithoutConsumer = xerrors.Wrap(errors.New("ydb: reader can't commit messages without consumer")) |
28 | 26 | errCommitSessionFromOtherReader = xerrors.Wrap(errors.New("ydb: commit with session from other reader")) |
29 | 27 | ) |
30 | 28 |
|
@@ -88,8 +86,11 @@ func NewReader( |
88 | 86 | ) (Reader, error) { |
89 | 87 | cfg := convertNewParamsToStreamConfig(consumer, readSelectors, opts...) |
90 | 88 |
|
91 | | - if err := cfg.Validate(); err != nil { |
92 | | - return Reader{}, err |
| 89 | + if errs := cfg.Validate(); len(errs) > 0 { |
| 90 | + return Reader{}, xerrors.WithStackTrace(fmt.Errorf( |
| 91 | + "ydb: failed to start topic reader, because is contains error in config: %w", |
| 92 | + errors.Join(errs...), |
| 93 | + )) |
93 | 94 | } |
94 | 95 |
|
95 | 96 | readerID := nextReaderID() |
@@ -234,20 +235,6 @@ type ReaderConfig struct { |
234 | 235 | topicStreamReaderConfig |
235 | 236 | } |
236 | 237 |
|
237 | | -func (c *ReaderConfig) Validate() error { |
238 | | - if c.Consumer != "" && c.ReadWithoutConsumer { |
239 | | - return xerrors.WithStackTrace(errSetConsumerAndNoConsumer) |
240 | | - } |
241 | | - if c.Consumer == "" && !c.ReadWithoutConsumer { |
242 | | - return xerrors.WithStackTrace(errUnexpectedEmptyConsumername) |
243 | | - } |
244 | | - if c.ReadWithoutConsumer && c.CommitMode != CommitModeNone { |
245 | | - return xerrors.WithStackTrace(errCantCommitWithoutConsumer) |
246 | | - } |
247 | | - |
248 | | - return nil |
249 | | -} |
250 | | - |
251 | 238 | type PublicReaderOption func(cfg *ReaderConfig) |
252 | 239 |
|
253 | 240 | func WithCredentials(cred credentials.Credentials) PublicReaderOption { |
|
0 commit comments