All Versions
11
Latest Version
Avg Release Cycle
71 days
Latest Release
344 days ago

Changelog History
Page 1

  • v1.1.9

    November 18, 2020
  • v1.1.8

    March 16, 2020
  • v1.1.7

    September 11, 2019
  • v1.1.6

    August 28, 2019
  • v1.1.5

    July 17, 2019
  • v1.1.4

    July 16, 2019
  • v1.1.3

    April 28, 2019
  • v1.1.2 Changes

    April 16, 2019

    ๐Ÿ‘Œ Supports Go Modules ( GO111MODULE=on )

  • v1.1.1 Changes

    December 12, 2018

    ๐Ÿ›  Fix import command ( see #9 )

  • v1.1.0 Changes

    December 11, 2018

    ๐Ÿ‘Œ Supports Distributed Transaction

    How To Use

    Set before/after callback for commit

    octillery.BeforeCommitCallback(func(tx \*sql.Tx, writeQueries []\*sql.QueryLog) error { // write all writeQueries to log (WAL) in application sidereturn nil})) octillery.AfterCommitCallback(func(tx \*sql.Tx) error {}, func(tx \*sql.Tx, isCriticalError bool, failureWriteQueries []\*sql.QueryLog) error { if isCriticalError { // distributed transaction error// record failureWriteQueries and should execute after. } }))
    

    Also, callback function can set at *sql.Tx scope too.

    tx, \_ := db.Begin() tx.BeforeCommitCallback(func(writeQueries []\*sql.QueryLog) error { // write all writeQueries to log (WAL) in application sidereturn nil})) tx.AfterCommitCallback(func() error {}, func(isCriticalError bool, failureWriteQueries []\*sql.QueryLog) error { if isCriticalError { // distributed transaction error// record failureWriteQueries and should execute after. } }))
    

    Exec for multiple databases

    You can use *sql.Tx to multiple databases.

    (tableA and tableB are stored other databases)

    tx, \_ := db.Begin() tx.Exec("insert into tableA ...") // (1)tx.Exec("insert into tableB ...") // (2)// tx.Commit() commit (1) before it commit (2)// if (1) and (2) are success too, call AfterCommitSuccessCallback// if (1) and (2) are failure too, call AfterCommitFailureCallback with NOT CriticalError// if (1) is failure, instantly call AfterCommitFailureCallback with NOT CriticalError// if (1) is OK but (2) is failure, call AfterCommitFailureCallback with CriticalErrorif err := tx.Commit(); err != nil { ... }
    

    ๐Ÿš‘ Recover from CriticalError

    writeQueryLogs := queryLogsfromWAL()tx, \_ := db.Begin()for \_, writeQueryLog := range writeQueryLogs { isCommittedQuery, err := tx.IsAlreadyCommittedQueryLog(writeQueryLog) if err != nil { .... } if !isCommittedQuery { result, err := tx.ExecWithQueryLog(writeQueryLog) .... } }
    

    ๐Ÿ‘ If disable distributed transaction support

    set distributed_transaction: false in databases.yml