()
| 33 | ) |
| 34 | |
| 35 | func init() { |
| 36 | encryptFunc := func(in, pass, salt []byte) (out []byte, err error) { |
| 37 | out, err = symmetric.EncryptWithPassword(in, pass, salt) |
| 38 | return |
| 39 | } |
| 40 | |
| 41 | decryptFunc := func(in, pass, salt []byte) (out []byte, err error) { |
| 42 | out, err = symmetric.DecryptWithPassword(in, pass, salt) |
| 43 | return |
| 44 | } |
| 45 | |
| 46 | sleepFunc := func(t int64) int64 { |
| 47 | log.Info("sqlite func sleep start") |
| 48 | time.Sleep(time.Duration(t)) |
| 49 | log.Info("sqlite func sleep end") |
| 50 | return t |
| 51 | } |
| 52 | |
| 53 | regCustomFunc := func(c *sqlite3.SQLiteConn) (err error) { |
| 54 | if err = c.RegisterFunc("sleep", sleepFunc, true); err != nil { |
| 55 | return |
| 56 | } |
| 57 | if err = c.RegisterFunc("encrypt", encryptFunc, true); err != nil { |
| 58 | return |
| 59 | } |
| 60 | if err = c.RegisterFunc("decrypt", decryptFunc, true); err != nil { |
| 61 | return |
| 62 | } |
| 63 | return |
| 64 | } |
| 65 | |
| 66 | sql.Register(dirtyReadDriver, &sqlite3.SQLiteDriver{ |
| 67 | ConnectHook: func(c *sqlite3.SQLiteConn) (err error) { |
| 68 | if _, err = c.Exec("PRAGMA read_uncommitted=1", nil); err != nil { |
| 69 | return |
| 70 | } |
| 71 | if err = regCustomFunc(c); err != nil { |
| 72 | return |
| 73 | } |
| 74 | return |
| 75 | }, |
| 76 | }) |
| 77 | sql.Register(serializableDriver, &sqlite3.SQLiteDriver{ |
| 78 | ConnectHook: func(c *sqlite3.SQLiteConn) (err error) { |
| 79 | if err = regCustomFunc(c); err != nil { |
| 80 | return |
| 81 | } |
| 82 | return |
| 83 | }, |
| 84 | }) |
| 85 | } |
| 86 | |
| 87 | // SQLite3 is the sqlite3 implementation of the xenomint/interfaces.Storage interface. |
| 88 | type SQLite3 struct { |
nothing calls this directly
no test coverage detected