Skip to content

Commit cdc6b2c

Browse files
authored
Add SQLite plugin (#6689)
* Reapply "Add SQLite plugin (#6643)" (#6670) This reverts commit e36c818. * support github.com/ncruces/go-sqlite3 args * make pr * fix tests * address comments
1 parent 8da3ba4 commit cdc6b2c

File tree

12 files changed

+472
-54
lines changed

12 files changed

+472
-54
lines changed

cmd/server/go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ require (
2626
github.com/gocql/gocql v0.0.0-20211015133455-b225f9b53fa1 // indirect
2727
github.com/gogo/protobuf v1.3.2 // indirect
2828
github.com/golang/mock v1.6.0 // indirect
29-
github.com/google/uuid v1.5.0 // indirect
29+
github.com/google/uuid v1.6.0 // indirect
3030
github.com/hashicorp/go-version v1.2.0 // indirect
3131
github.com/iancoleman/strcase v0.2.0 // indirect
3232
github.com/jmoiron/sqlx v1.2.1-0.20200615141059-0794cb1f47ee // indirect
@@ -57,7 +57,7 @@ require (
5757
go.uber.org/yarpc v1.70.3 // indirect
5858
go.uber.org/zap v1.13.0 // indirect
5959
golang.org/x/net v0.26.0 // indirect
60-
golang.org/x/sync v0.7.0 // indirect
60+
golang.org/x/sync v0.10.0 // indirect
6161
golang.org/x/time v0.5.0 // indirect
6262
golang.org/x/tools v0.22.0 // indirect
6363
gonum.org/v1/gonum v0.7.0 // indirect
@@ -146,14 +146,14 @@ require (
146146
go.opencensus.io v0.24.0 // indirect
147147
go.uber.org/dig v1.10.0 // indirect
148148
go.uber.org/net/metrics v1.3.0 // indirect
149-
golang.org/x/crypto v0.24.0 // indirect
149+
golang.org/x/crypto v0.32.0 // indirect
150150
golang.org/x/exp v0.0.0-20231226003508-02704c960a9b // indirect
151151
golang.org/x/exp/typeparams v0.0.0-20220218215828-6cf2b201936e // indirect
152152
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
153153
golang.org/x/mod v0.18.0 // indirect
154154
golang.org/x/oauth2 v0.11.0 // indirect
155-
golang.org/x/sys v0.21.0 // indirect
156-
golang.org/x/text v0.16.0 // indirect
155+
golang.org/x/sys v0.29.0 // indirect
156+
golang.org/x/text v0.21.0 // indirect
157157
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
158158
google.golang.org/api v0.128.0 // indirect
159159
google.golang.org/appengine v1.6.7 // indirect

cmd/server/go.sum

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm4
201201
github.com/google/s2a-go v0.1.4 h1:1kZ/sQM3srePvKs3tXAvQzo66XfcReoqFpIpIccE7Oc=
202202
github.com/google/s2a-go v0.1.4/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A=
203203
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
204-
github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU=
205-
github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
204+
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
205+
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
206206
github.com/googleapis/enterprise-certificate-proxy v0.2.4 h1:uGy6JWR/uMIILU8wbf+OkstIrNiMjGpEIyhx8f6W7s4=
207207
github.com/googleapis/enterprise-certificate-proxy v0.2.4/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k=
208208
github.com/googleapis/gax-go/v2 v2.12.0 h1:A+gCJKdRfqXkr+BIRGtZLibNXf0m1f9E4HG56etFpas=
@@ -495,8 +495,8 @@ golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9/go.mod h1:LzIPMQfyMNhhGPh
495495
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
496496
golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
497497
golang.org/x/crypto v0.0.0-20220314234659-1baeb1ce4c0b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
498-
golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI=
499-
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
498+
golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
499+
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
500500
golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
501501
golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
502502
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
@@ -563,8 +563,8 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ
563563
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
564564
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
565565
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
566-
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
567-
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
566+
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
567+
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
568568
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
569569
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
570570
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -598,8 +598,8 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
598598
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
599599
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
600600
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
601-
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
602-
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
601+
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
602+
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
603603
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
604604
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
605605
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@@ -611,8 +611,8 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
611611
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
612612
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
613613
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
614-
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
615-
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
614+
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
615+
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
616616
golang.org/x/time v0.0.0-20170927054726-6dc17368e09b/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
617617
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
618618
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=

common/archiver/gcloud/go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ require (
2222
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13
2323
github.com/gogo/protobuf v1.3.2 // indirect
2424
github.com/golang/mock v1.6.0 // indirect
25-
github.com/google/uuid v1.5.0 // indirect
25+
github.com/google/uuid v1.6.0 // indirect
2626
github.com/m3db/prometheus_client_golang v0.8.1 // indirect
2727
github.com/opentracing/opentracing-go v1.2.0 // indirect
2828
github.com/pborman/uuid v0.0.0-20180906182336-adf5a7427709 // indirect
@@ -41,7 +41,7 @@ require (
4141
go.uber.org/yarpc v1.70.3 // indirect
4242
go.uber.org/zap v1.13.0 // indirect
4343
golang.org/x/net v0.26.0 // indirect
44-
golang.org/x/sync v0.7.0 // indirect
44+
golang.org/x/sync v0.10.0 // indirect
4545
golang.org/x/time v0.5.0 // indirect
4646
golang.org/x/tools v0.22.0 // indirect
4747
google.golang.org/grpc v1.59.0 // indirect
@@ -95,12 +95,12 @@ require (
9595
github.com/uber-go/mapdecode v1.0.0 // indirect
9696
go.opencensus.io v0.24.0 // indirect
9797
go.uber.org/net/metrics v1.3.0 // indirect
98-
golang.org/x/crypto v0.24.0 // indirect
98+
golang.org/x/crypto v0.32.0 // indirect
9999
golang.org/x/exp/typeparams v0.0.0-20220218215828-6cf2b201936e // indirect
100100
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
101101
golang.org/x/mod v0.18.0 // indirect
102-
golang.org/x/sys v0.21.0 // indirect
103-
golang.org/x/text v0.16.0 // indirect
102+
golang.org/x/sys v0.29.0 // indirect
103+
golang.org/x/text v0.21.0 // indirect
104104
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
105105
google.golang.org/appengine v1.6.7 // indirect
106106
google.golang.org/genproto v0.0.0-20231016165738-49dd2c1f3d0b // indirect

common/archiver/gcloud/go.sum

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm4
138138
github.com/google/s2a-go v0.1.4 h1:1kZ/sQM3srePvKs3tXAvQzo66XfcReoqFpIpIccE7Oc=
139139
github.com/google/s2a-go v0.1.4/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A=
140140
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
141-
github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU=
142-
github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
141+
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
142+
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
143143
github.com/googleapis/enterprise-certificate-proxy v0.2.4 h1:uGy6JWR/uMIILU8wbf+OkstIrNiMjGpEIyhx8f6W7s4=
144144
github.com/googleapis/enterprise-certificate-proxy v0.2.4/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k=
145145
github.com/googleapis/gax-go/v2 v2.12.0 h1:A+gCJKdRfqXkr+BIRGtZLibNXf0m1f9E4HG56etFpas=
@@ -346,8 +346,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
346346
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
347347
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
348348
golang.org/x/crypto v0.0.0-20220314234659-1baeb1ce4c0b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
349-
golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI=
350-
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
349+
golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
350+
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
351351
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
352352
golang.org/x/exp v0.0.0-20231226003508-02704c960a9b h1:kLiC65FbiHWFAOu+lxwNPujcsl8VYyTYYEZnsOO1WK4=
353353
golang.org/x/exp v0.0.0-20231226003508-02704c960a9b/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI=
@@ -408,8 +408,8 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ
408408
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
409409
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
410410
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
411-
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
412-
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
411+
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
412+
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
413413
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
414414
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
415415
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -437,8 +437,8 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
437437
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
438438
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
439439
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
440-
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
441-
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
440+
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
441+
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
442442
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
443443
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
444444
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@@ -450,8 +450,8 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
450450
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
451451
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
452452
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
453-
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
454-
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
453+
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
454+
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
455455
golang.org/x/time v0.0.0-20170927054726-6dc17368e09b/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
456456
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
457457
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=

common/persistence/sql/sqlplugin/sqlite/db.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ import (
2929

3030
"github.com/uber/cadence/common/persistence/sql/sqlplugin"
3131
"github.com/uber/cadence/common/persistence/sql/sqlplugin/mysql"
32+
33+
// import sqlite driver
34+
_ "github.com/ncruces/go-sqlite3/driver"
35+
// import embed sqlite db
36+
_ "github.com/ncruces/go-sqlite3/embed"
3237
)
3338

3439
var (
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
// The MIT License (MIT)
2+
3+
// Copyright (c) 2017-2020 Uber Technologies Inc.
4+
5+
// Permission is hereby granted, free of charge, to any person obtaining a copy
6+
// of this software and associated documentation files (the "Software"), to deal
7+
// in the Software without restriction, including without limitation the rights
8+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
// copies of the Software, and to permit persons to whom the Software is
10+
// furnished to do so, subject to the following conditions:
11+
//
12+
// The above copyright notice and this permission notice shall be included in all
13+
// copies or substantial portions of the Software.
14+
//
15+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
// SOFTWARE.
22+
23+
package sqlite
24+
25+
import (
26+
"bytes"
27+
"fmt"
28+
"sort"
29+
"strings"
30+
31+
"github.com/uber/cadence/common/config"
32+
)
33+
34+
const (
35+
// if journal mode is not provided, we set it to WAL by default
36+
// WAL mode allows readers and writers from different processes
37+
// to access the database concurrently by default
38+
// https://sqlite.org/pragma.html#pragma_journal_mode
39+
// https://www.sqlite.org/wal.html
40+
pragmaJournalModeAttrName = "_pragma.journal_mode"
41+
pragmaJournalModeDefaultValue = "WAL"
42+
43+
// if busy_timeout is not provided, we set it to 60 seconds by default
44+
// https://sqlite.org/pragma.html#pragma_busy_timeout
45+
pragmaBusyTimeoutAttrName = "_pragma.busy_timeout"
46+
pragmaBusyTimeoutDefault = "60000"
47+
)
48+
49+
const (
50+
// pragmaKey is the key is used to set pragma arguments in the DSN
51+
pragmaKey = "_pragma"
52+
53+
// pragmaPrefix is the prefix used to identify pragma arguments in the config
54+
pragmaPrefix = "_pragma."
55+
)
56+
57+
// buildDSN builds the data source name for sqlite from config.SQL
58+
// If DatabaseName is not provided, then sqlite will use in-memory database, otherwise it will use the file as the database
59+
// All dsn attributes can be set up in the ConnectAttributes field of the config.SQL
60+
// Available attributes can be found here: https://github.com/ncruces/go-sqlite3/blob/main/driver/driver.go
61+
// PRAGMA attributes should start with "_pragma." prefix
62+
// example: "_pragma.journal_mode":"wal" will be transformed to "_pragma=journal_mode(wal)"
63+
// More about PRAGMA attributes: https://sqlite.org/pragma.html
64+
// Default PRAGMA values if not provided:
65+
// - journal_mode: WAL (file only) - https://sqlite.org/pragma.html#pragma_journal_mode
66+
// - busy_timeout: 60 seconds - https://sqlite.org/pragma.html#pragma_busy_timeout
67+
func buildDSN(cfg *config.SQL) string {
68+
69+
// by default, we use in-memory database if no database name is provided
70+
var dsn = "file::memory:"
71+
72+
// if database name is provided, then sqlite will use the file as the database
73+
if cfg.DatabaseName != "" {
74+
dsn = fmt.Sprintf("file:%s", cfg.DatabaseName)
75+
76+
}
77+
78+
if dsnAttrs := buildDSNAttrs(cfg); dsnAttrs != "" {
79+
dsn += "?" + dsnAttrs
80+
}
81+
82+
return dsn
83+
}
84+
85+
// buildDSNAttrs builds the data source name attributes for sqlite from config.SQL
86+
func buildDSNAttrs(cfg *config.SQL) string {
87+
88+
sanitizedAttrs := sanitizeDSNAttrs(cfg.ConnectAttributes)
89+
90+
if cfg.DatabaseName != "" {
91+
defaultIfEmpty(sanitizedAttrs, pragmaJournalModeAttrName, pragmaJournalModeDefaultValue)
92+
}
93+
94+
defaultIfEmpty(sanitizedAttrs, pragmaBusyTimeoutAttrName, pragmaBusyTimeoutDefault)
95+
return joinDSNAttrs(sanitizedAttrs)
96+
}
97+
98+
// defaultIfEmpty sets the value to the key if the key is not present in the attributes
99+
func defaultIfEmpty(attrs map[string]string, key, value string) {
100+
if hasAttr(attrs, key) {
101+
return
102+
}
103+
attrs[key] = value
104+
}
105+
106+
// hasAttr checks if the attributes map has any of the keys
107+
func hasAttr(attrs map[string]string, keys ...string) bool {
108+
for key := range attrs {
109+
for _, k := range keys {
110+
if key == k {
111+
return true
112+
}
113+
}
114+
}
115+
return false
116+
}
117+
118+
// sanitizeDSNAttrs sanitizes the attributes by trimming the keys and values
119+
func sanitizeDSNAttrs(attrs map[string]string) map[string]string {
120+
sanitized := make(map[string]string, len(attrs))
121+
122+
for k, v := range attrs {
123+
k, v = sanitizeDSNAttrKey(k), sanitizeDSNAttrValue(v)
124+
sanitized[k] = v
125+
}
126+
127+
return sanitized
128+
}
129+
130+
// isPragmaKey checks if the key is a pragma key
131+
func isPragmaKey(key string) bool {
132+
return strings.HasPrefix(key, pragmaPrefix)
133+
}
134+
135+
// transformPragmaArgument transforms the pragma argument to the format that can be used in the DSN
136+
// example: "_pragma.journal_mode":"wal" -> "_pragma=journal_mode(wal)"
137+
func transformPragmaArgument(key, value string) (newKey, newValue string) {
138+
return pragmaKey, fmt.Sprintf("%s(%s)", strings.TrimPrefix(key, pragmaPrefix), value)
139+
}
140+
141+
// sanitizeDSNAttrElem trims the value, lowercases it
142+
func sanitizeDSNAttrKey(v string) string {
143+
return strings.TrimSpace(strings.ToLower(v))
144+
}
145+
146+
// sanitizeDSNAttrElem trims the value, lowercases it
147+
func sanitizeDSNAttrValue(v string) string {
148+
return strings.TrimSpace(v)
149+
}
150+
151+
// sortedKeys returns the sorted keys of the map
152+
func sortMapKeys(m map[string]string) []string {
153+
keys := make([]string, 0, len(m))
154+
for k := range m {
155+
keys = append(keys, k)
156+
}
157+
158+
sort.Strings(keys)
159+
return keys
160+
}
161+
162+
// joinDSNAttrs joins the attributes into a single string
163+
// with key=value pairs separated by & and escaped
164+
func joinDSNAttrs(attrs map[string]string) string {
165+
first := true
166+
var buf bytes.Buffer
167+
168+
// sort the keys to make the order of the attributes deterministic
169+
sortedKeys := sortMapKeys(attrs)
170+
171+
for _, k := range sortedKeys {
172+
v := attrs[k]
173+
174+
// pragma arguments should be transformed to the format that can be used in the DSN
175+
if isPragmaKey(k) {
176+
k, v = transformPragmaArgument(k, v)
177+
}
178+
179+
if !first {
180+
buf.WriteString("&")
181+
}
182+
first = false
183+
buf.WriteString(k)
184+
buf.WriteString("=")
185+
buf.WriteString(v)
186+
}
187+
return buf.String()
188+
}

0 commit comments

Comments
 (0)