Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Commit dabd31d

Browse files
author
noah
committed
fix: rm opencensus
1 parent 8e7b2e5 commit dabd31d

File tree

5 files changed

+5
-39
lines changed

5 files changed

+5
-39
lines changed

cmd/server/db.go

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,20 @@
11
package main
22

33
import (
4-
"context"
54
"database/sql"
6-
"database/sql/driver"
75
"fmt"
86

9-
"contrib.go.opencensus.io/integrations/ocsql"
107
"entgo.io/ent/dialect"
118
entsql "entgo.io/ent/dialect/sql"
12-
"github.com/go-sql-driver/mysql"
139

1410
"github.com/gitploy-io/gitploy/ent"
1511
)
1612

17-
type (
18-
MySQLConnector struct {
19-
dsn string
20-
}
21-
)
22-
23-
func (c MySQLConnector) Connect(context.Context) (driver.Conn, error) {
24-
return c.Driver().Open(c.dsn)
25-
}
26-
27-
func (c MySQLConnector) Driver() driver.Driver {
28-
return ocsql.Wrap(
29-
mysql.MySQLDriver{},
30-
ocsql.WithAllTraceOptions(),
31-
ocsql.WithRowsClose(false),
32-
ocsql.WithRowsNext(false),
33-
ocsql.WithDisableErrSkip(true),
34-
)
35-
}
36-
3713
func OpenDB(driver string, dsn string) (*ent.Client, error) {
38-
if driver == dialect.SQLite {
14+
if driver == dialect.SQLite || driver == dialect.MySQL {
3915
return ent.Open(driver, dsn)
4016
}
4117

42-
if driver == dialect.MySQL {
43-
db := sql.OpenDB(MySQLConnector{dsn})
44-
drv := entsql.OpenDB(dialect.MySQL, db)
45-
return ent.NewClient(ent.Driver(drv)), nil
46-
}
47-
4818
if driver == dialect.Postgres {
4919
db, err := sql.Open("pgx", dsn)
5020
if err != nil {

cmd/server/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/gitploy-io/gitploy/internal/pkg/store"
1717
"github.com/gitploy-io/gitploy/internal/server"
1818

19+
_ "github.com/go-sql-driver/mysql"
1920
_ "github.com/jackc/pgx/v4/stdlib"
2021
_ "github.com/mattn/go-sqlite3"
2122
)

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ module github.com/gitploy-io/gitploy
33
go 1.15
44

55
require (
6-
contrib.go.opencensus.io/integrations/ocsql v0.1.7
76
entgo.io/ent v0.9.0
87
github.com/AlekSi/pointer v1.1.0
98
github.com/asaskevich/EventBus v0.0.0-20200907212545-49d423059eef

go.sum

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0Zeo
3131
cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=
3232
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
3333
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
34-
contrib.go.opencensus.io/integrations/ocsql v0.1.7 h1:G3k7C0/W44zcqkpRSFyjU9f6HZkbwIrL//qqnlqWZ60=
35-
contrib.go.opencensus.io/integrations/ocsql v0.1.7/go.mod h1:8DsSdjz3F+APR+0z0WkU1aRorQCFfRxvqjUUPMbF3fE=
3634
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
3735
entgo.io/ent v0.9.0 h1:2S1zfpMMW6p+wctj6kcYUprNPNjLWFW06T5MdyAfmWc=
3836
entgo.io/ent v0.9.0/go.mod h1:6NUeTfUN5mp5YN+5tgoH1SlakSvYPTBOYotSOvaI4ak=
@@ -132,7 +130,6 @@ github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfU
132130
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
133131
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
134132
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
135-
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY=
136133
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
137134
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
138135
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
@@ -427,7 +424,6 @@ go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
427424
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
428425
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
429426
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
430-
go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M=
431427
go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E=
432428
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
433429
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=

internal/server/web/index.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ func (w *Web) Signin(c *gin.Context) {
149149
}
150150

151151
if u, err = w.i.CreateUser(ctx, u); err != nil {
152-
w.log.Error("It has failed to save a new user.", zap.Error(err))
153-
c.String(http.StatusInternalServerError, "It has failed to save a new user.")
152+
w.log.Error("It has failed to create a new user.", zap.Error(err))
153+
c.String(http.StatusInternalServerError, "It has failed to sign in.")
154154
return
155155
}
156156
} else if err != nil {
@@ -160,7 +160,7 @@ func (w *Web) Signin(c *gin.Context) {
160160
} else {
161161
if u, _ = w.i.UpdateUser(ctx, u); err != nil {
162162
w.log.Error("It has failed to update the user.", zap.Error(err))
163-
c.String(http.StatusInternalServerError, "It has failed to update the user.")
163+
c.String(http.StatusInternalServerError, "It has failed to sign in.")
164164
return
165165
}
166166
}

0 commit comments

Comments
 (0)