Skip to content

Commit 01da629

Browse files
committed
remove database docker interface and cmd
1 parent 84efade commit 01da629

File tree

12 files changed

+23
-129
lines changed

12 files changed

+23
-129
lines changed

common/docker/docker_geth.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func NewImgGeth(t *testing.T, image, volume, ipc string, hPort, wPort int) ImgIn
5555

5656
// Start run image and check if it is running healthily.
5757
func (i *ImgGeth) Start() error {
58-
id := getContainerID(i.name)
58+
id := GetContainerID(i.name)
5959
if id != "" {
6060
return fmt.Errorf("container already exist, name: %s", i.name)
6161
}
@@ -99,7 +99,7 @@ func (i *ImgGeth) isOk() bool {
9999

100100
select {
101101
case <-okCh:
102-
i.id = getContainerID(i.name)
102+
i.id = GetContainerID(i.name)
103103
return i.id != ""
104104
case <-time.NewTimer(time.Second * 10).C:
105105
return false
@@ -115,7 +115,7 @@ func (i *ImgGeth) Stop() error {
115115

116116
ctx := context.Background()
117117
// check if container is running, stop the running container.
118-
id := getContainerID(i.name)
118+
id := GetContainerID(i.name)
119119
if id != "" {
120120
timeout := time.Second * 3
121121
if err := cli.ContainerStop(ctx, id, &timeout); err != nil {

common/docker/interface.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ import (
77
"github.com/docker/docker/api/types/filters"
88
)
99

10-
// ImgInstance is the geth img instance.
10+
// ImgInstance is an img instance.
1111
type ImgInstance interface {
1212
Start() error
1313
Stop() error
1414
Endpoint() string
1515
}
1616

17-
func getContainerID(name string) string {
17+
// GetContainerID returns the ID of Container.
18+
func GetContainerID(name string) string {
1819
filter := filters.NewArgs()
1920
filter.Add("name", name)
2021
lst, _ := cli.ContainerList(context.Background(), types.ContainerListOptions{

coordinator/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ export TEST_DB_DSN="postgres://admin:123456@localhost/test_db?sslmode=disable"
3838
* use specified ports and config.json
3939

4040
```bash
41-
./build/bin/coordinator --config ./config.json --http --http.addr localhost --http.port 8290
41+
./build/bin/coordinator --config ./config.json --http --http.addr localhost --http.port 8390
4242
```

coordinator/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package rollers
1+
package coordinator
22

33
import (
44
"fmt"

coordinator/conns.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package rollers
1+
package coordinator
22

33
import (
44
cmap "github.com/orcaman/concurrent-map"

coordinator/manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package rollers
1+
package coordinator
22

33
import (
44
"context"

coordinator/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package rollers
1+
package coordinator
22

33
import (
44
"context"

database/docker/cmd.go

Lines changed: 0 additions & 84 deletions
This file was deleted.

database/docker/docker_db.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99

1010
"github.com/docker/docker/api/types"
1111
"github.com/docker/docker/client"
12+
13+
"scroll-tech/common/docker"
1214
)
1315

1416
var (
@@ -35,24 +37,24 @@ type ImgDB struct {
3537
password string
3638

3739
running bool
38-
*Cmd
40+
*docker.Cmd
3941
}
4042

4143
// NewImgDB return postgres db img instance.
42-
func NewImgDB(t *testing.T, image, password, dbName string, port int) ImgInstance {
44+
func NewImgDB(t *testing.T, image, password, dbName string, port int) docker.ImgInstance {
4345
return &ImgDB{
4446
image: image,
4547
name: fmt.Sprintf("%s-%s_%d", image, dbName, port),
4648
password: password,
4749
dbName: dbName,
4850
port: port,
49-
Cmd: NewCmd(t),
51+
Cmd: docker.NewCmd(t),
5052
}
5153
}
5254

5355
// Start postgres db container.
5456
func (i *ImgDB) Start() error {
55-
id := getContainerID(i.name)
57+
id := docker.GetContainerID(i.name)
5658
if id != "" {
5759
return fmt.Errorf("container already exist, name: %s", i.name)
5860
}
@@ -74,7 +76,7 @@ func (i *ImgDB) Stop() error {
7476

7577
ctx := context.Background()
7678
// check if container is running, stop the running container.
77-
id := getContainerID(i.name)
79+
id := docker.GetContainerID(i.name)
7880
if id != "" {
7981
timeout := time.Second * 3
8082
if err := cli.ContainerStop(ctx, id, &timeout); err != nil {
@@ -122,7 +124,7 @@ func (i *ImgDB) isOk() bool {
122124
select {
123125
case <-okCh:
124126
time.Sleep(time.Millisecond * 1500)
125-
i.id = getContainerID(i.name)
127+
i.id = docker.GetContainerID(i.name)
126128
return i.id != ""
127129
case <-time.NewTimer(time.Second * 10).C:
128130
return false

database/docker/interface.go

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)