@@ -102,11 +102,11 @@ func NewStorage(ctx context.Context, cfg *config.Config, poolSize int) (_ *Stora
102102 return nil , err
103103 }
104104
105- s .x .DB (). SetMaxOpenConns (poolSize )
106- s .x .DB (). SetMaxIdleConns (poolSize )
107- s .x .DB (). SetConnMaxIdleTime (time .Second )
105+ s .x .SetMaxOpenConns (poolSize )
106+ s .x .SetMaxIdleConns (poolSize )
107+ s .x .SetConnMaxIdleTime (time .Second )
108108
109- s .x .SetTableMapper (newMapper (cfg .Table , "entry" ))
109+ s .x .SetTableMapper (newMapper (cfg .Table , cfg . Table ))
110110
111111 s .x .SetLogLevel (log .LOG_DEBUG )
112112
@@ -134,8 +134,8 @@ func (s *Storage) Read(ctx context.Context, id generator.RowID) (row generator.R
134134 row .ID = id
135135
136136 err = retry .Do (ydb .WithTxControl (ctx , readTx ), s .x .DB ().DB ,
137- func (ctx context.Context , cc * sql.Conn ) (err error ) {
138- has , err := s .x .Context (ctx ).Get (& row )
137+ func (ctx context.Context , _ * sql.Conn ) (err error ) {
138+ has , err := s .x .Context (ctx ).Where ( "hash = Digest::NumericHash(?)" , id ). Get (& row )
139139 if err != nil {
140140 return fmt .Errorf ("get entry error: %w" , err )
141141 }
@@ -173,7 +173,7 @@ func (s *Storage) Write(ctx context.Context, row generator.Row) (attempts int, e
173173 defer cancel ()
174174
175175 err = retry .Do (ydb .WithTxControl (ctx , writeTx ), s .x .DB ().DB ,
176- func (ctx context.Context , cc * sql.Conn ) (err error ) {
176+ func (ctx context.Context , _ * sql.Conn ) (err error ) {
177177 if err = ctx .Err (); err != nil {
178178 return err
179179 }
@@ -208,7 +208,9 @@ func (s *Storage) createTable(ctx context.Context) error {
208208 ctx , cancel := context .WithTimeout (ctx , time .Duration (s .cfg .WriteTimeout )* time .Millisecond )
209209 defer cancel ()
210210
211- return s .x .Context (ctx ).CreateTable (generator.Row {})
211+ return retry .Do (ctx , s .x .DB ().DB , func (ctx context.Context , _ * sql.Conn ) error {
212+ return s .x .Context (ctx ).CreateTable (generator.Row {})
213+ })
212214}
213215
214216func (s * Storage ) dropTable (ctx context.Context ) error {
@@ -219,7 +221,9 @@ func (s *Storage) dropTable(ctx context.Context) error {
219221 ctx , cancel := context .WithTimeout (ctx , time .Duration (s .cfg .WriteTimeout )* time .Millisecond )
220222 defer cancel ()
221223
222- return s .x .Context (ctx ).DropTable (generator.Row {})
224+ return retry .Do (ctx , s .x .DB ().DB , func (ctx context.Context , _ * sql.Conn ) error {
225+ return s .x .Context (ctx ).DropTable (generator.Row {})
226+ })
223227}
224228
225229func (s * Storage ) close (ctx context.Context ) error {
0 commit comments