Skip to content

Commit 73cdcdc

Browse files
committed
client timeout + messages
1 parent 59e6c71 commit 73cdcdc

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

local/bin/sender.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
package main
22

33
import (
4+
"github.com/postgres-ci/hooks/git"
5+
46
"bytes"
57
"encoding/json"
68
"fmt"
79
"net/http"
810
"net/url"
911
"os"
10-
11-
"github.com/postgres-ci/hooks/git"
12+
"time"
1213
)
1314

1415
type Commit struct {
@@ -34,7 +35,9 @@ func main() {
3435
}
3536
}
3637

37-
var client http.Client
38+
var client = http.Client{
39+
Timeout: time.Second * 2,
40+
}
3841

3942
func send(commit Commit) error {
4043

@@ -59,5 +62,7 @@ func send(commit Commit) error {
5962
return nil
6063
}
6164

65+
fmt.Printf("\nCommit %s was sent to Postgres-CI server (%s://%s)\n\n", commit.ID, _url.Scheme, _url.Host)
66+
6267
return nil
6368
}

server-side/bin/sender.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package main
22

33
import (
4+
"github.com/postgres-ci/hooks/git"
5+
46
"bufio"
57
"bytes"
68
"encoding/json"
@@ -9,8 +11,7 @@ import (
911
"net/url"
1012
"os"
1113
"strings"
12-
13-
"github.com/postgres-ci/hooks/git"
14+
"time"
1415
)
1516

1617
func main() {
@@ -56,7 +57,9 @@ func main() {
5657
}
5758
}
5859

59-
var client http.Client
60+
var client = http.Client{
61+
Timeout: time.Second * 2,
62+
}
6063

6164
func send(push git.Push) error {
6265

@@ -81,5 +84,14 @@ func send(push git.Push) error {
8184
return nil
8285
}
8386

87+
fmt.Println("\nCommits:")
88+
89+
for _, commit := range push.Commits {
90+
91+
fmt.Printf(" %s %s %s\n", push.Ref, commit.ID, commit.Author.Name)
92+
}
93+
94+
fmt.Printf("\nwas sent to Postgres-CI server (%s://%s)\n\n", _url.Scheme, _url.Host)
95+
8496
return nil
8597
}

0 commit comments

Comments
 (0)