tiny fixes

This commit is contained in:
finley
2022-08-20 22:28:06 +08:00
parent 23a6f95c18
commit 9da335811f
8 changed files with 60 additions and 11 deletions

View File

@@ -35,6 +35,7 @@ type Connection struct {
multiState bool
queue [][][]byte
watching map[string]uint32
txErrors []error
// selected db
selectedDB int
@@ -65,11 +66,9 @@ func (c *Connection) Write(b []byte) error {
if len(b) == 0 {
return nil
}
c.mu.Lock()
c.waitingReply.Add(1)
defer func() {
c.waitingReply.Done()
c.mu.Unlock()
}()
_, err := c.conn.Write(b)
@@ -151,6 +150,16 @@ func (c *Connection) EnqueueCmd(cmdLine [][]byte) {
c.queue = append(c.queue, cmdLine)
}
// AddTxError stores syntax error within transaction
func (c *Connection) AddTxError(err error) {
c.txErrors = append(c.txErrors, err)
}
// GetTxErrors returns syntax error within transaction
func (c *Connection) GetTxErrors() []error {
return c.txErrors
}
// ClearQueuedCmds clears queued commands of current transaction
func (c *Connection) ClearQueuedCmds() {
c.queue = nil