Skip to content

Commit e294338

Browse files
authored
Gracefully shutdown websocket listeners (#136)
1 parent a56db3e commit e294338

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+659
-715
lines changed

.travis.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ done
2626

2727
rm -f coverage.txt
2828
for dir in $(go list ./... | grep -v vendor); do
29-
go test -timeout 300s -coverprofile=profile.out $dir
29+
go test -timeout 60s -coverprofile=profile.out $dir
3030
exit_code=$?
3131
if [ "0" != "$exit_code" ]; then
3232
exit $exit_code

CHANGELOG.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
All notable changes to this project are documented in this file.
2+
3+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
4+
5+
# v1.0.0-rc8 - 2019-06-21
6+
#### Changed
7+
* Enable graceful shutdown of socket listeners
8+
* Update `godep` dependency versions
9+
* Refactor process handling to be `context`-based
10+
11+
12+
# v1.0.0-rc7 - 2019-04-12
13+
#### Changed
14+
* Fix an issue with taking the address of a pointer reference, see #132
15+
16+
17+
# v1.0.0-rc6 - 2018-09-24
18+
#### Added
19+
* Enable handling socket errors
20+
* Add initial error codes
21+
* Example documentation
22+
* Add useful docker-compose
23+
24+
#### Changed
25+
* Cleanup logging code
26+
27+
28+
# v1.0.0-rc5 - 2018-09-15
29+
#### Changed
30+
* Fixes an issue with transitive dependencies
31+
32+
33+
# v1.0.0-rc4 - 2018-08-22
34+
#### Changed
35+
* Replace logging package
36+
* Various log cleanup
37+
38+
39+
# v1.0.0-rc3 - 2018-07-23
40+
#### Changed
41+
* Updates related to upstream dependencies
42+
43+
44+
# v1.0.0-rc2 - 2018-06-01
45+
#### Added
46+
* Add test coverage for socket timeouts
47+
48+
#### Changed
49+
* Fix an issue with zombie listen process
50+
* Fix an issue with zombie stop process
51+
52+
53+
# v1.0.0-rc1 - 2018-05-30
54+
#### Changed
55+
* Initial refactoring
56+
* Refactor test scripts
57+
* Gocyclo

Gopkg.lock

Lines changed: 7 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[[constraint]]
22
name = "github.com/bdlm/errors"
3-
version = "=0.1.1"
3+
version = "~0.1.1"
44

55
[[constraint]]
66
name = "github.com/bdlm/log"
7-
version = "=0.1.10"
7+
version = "~0.1.10"

README.md

Lines changed: 4 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
<a href="https://github.com/mkenney/software-guides/blob/master/STABILITY-BADGES.md#release-candidate"><img src="https://img.shields.io/badge/stability-pre--release-48c9b0.svg" alt="Release Candidate"></a>
1010
<a href="https://travis-ci.org/mkenney/go-chrome"><img src="https://travis-ci.org/mkenney/go-chrome.svg?branch=master" alt="Build status"></a>
1111
<a href="https://codecov.io/gh/mkenney/go-chrome"><img src="https://img.shields.io/codecov/c/github/mkenney/go-chrome/master.svg" alt="Coverage status"></a>
12-
<a href="https://goreportcard.com/report/github.com/mkenney/go-chrome"><img src="https://goreportcard.com/badge/github.com/mkenney/go-chrome" alt="Go Report Card"></a>
1312
<a href="https://github.com/mkenney/go-chrome/issues"><img src="https://img.shields.io/github/issues-raw/mkenney/go-chrome.svg" alt="Github issues"></a>
1413
<a href="https://github.com/mkenney/go-chrome/pulls"><img src="https://img.shields.io/github/issues-pr/mkenney/go-chrome.svg" alt="Github pull requests"></a>
1514
<a href="https://godoc.org/github.com/mkenney/go-chrome"><img src="https://godoc.org/github.com/mkenney/go-chrome?status.svg" alt="GoDoc"></a>
@@ -21,9 +20,9 @@ The API is fairly settled and basic code-coverage tests have been implemented bu
2120

2221
This implementation is based on the [Tip-of-Tree](https://chromedevtools.github.io/devtools-protocol/tot/) documentation and may be prone to change. At some point stable versions will be implemented as well, hopefully beginning with v1.3.
2322

24-
# Examples
23+
# Documentation and Examples
2524

26-
There are a few small examples of how to use the framework API on the [wiki](https://github.com/mkenney/go-chrome/wiki) and in the [`/_examples`](https://github.com/mkenney/go-chrome/tree/master/_examples) directory.
25+
There are a few small examples of how to use the framework API on the [wiki](https://github.com/mkenney/go-chrome/wiki) and in the [`/_examples`](https://github.com/mkenney/go-chrome/tree/master/_examples) directory. Additional documentation is available on the [wiki](https://github.com/mkenney/go-chrome/wiki) as well.
2726

2827
# TODO
2928

@@ -42,111 +41,6 @@ If you would like to contribute but aren't sure how, take a look at the [issue t
4241

4342
There are also always [tests that could be written](https://codecov.io/gh/mkenney/go-chrome). There are [many](https://github.com/mkenney/go-chrome/blob/master/tot/socket/cdtp.animation_test.go) [examples](https://github.com/mkenney/go-chrome/blob/master/tot/cdtp/animation/enum.animation.type_test.go) of tests in the package.
4443

45-
# Announcements
44+
# [`CHANGELOG`](CHANGELOG.md)
4645

47-
## v1.0.0-rc7 released
48-
49-
[`v1.0.0-rc7`](https://github.com/mkenney/go-chrome/releases/tag/v1.0.0-rc7) has been released.
50-
51-
* fixes an issue with taking the address of a pointer reference, see [#132](https://github.com/mkenney/go-chrome/issues/132)
52-
53-
Please [open an issue](https://github.com/mkenney/go-chrome/issues/new/choose) to report any problems or suggest any changes.
54-
55-
```toml
56-
[[constraint]]
57-
name = "github.com/mkenney/go-chrome"
58-
version = "1.0.0-rc7"
59-
```
60-
61-
```mod
62-
require (
63-
github.com/mkenney/go-chrome v1.0.0-rc7
64-
)
65-
```
66-
67-
## v1.0.0-rc6 released
68-
69-
[`v1.0.0-rc6`](https://github.com/mkenney/go-chrome/releases/tag/v1.0.0-rc6) has been released.
70-
71-
* enable handling socket errors
72-
* add initial error codes
73-
* cleanup logging code
74-
* example documentation
75-
* add useful docker-compose
76-
77-
Please [open an issue](https://github.com/mkenney/go-chrome/issues/new/choose) to report any problems or suggest any changes.
78-
79-
```toml
80-
[[constraint]]
81-
name = "github.com/mkenney/go-chrome"
82-
version = "1.0.0-rc6"
83-
```
84-
85-
## v1.0.0-rc5 released
86-
87-
[`v1.0.0-rc5`](https://github.com/mkenney/go-chrome/releases/tag/v1.0.0-rc5) has been released.
88-
89-
* Fixes a `dep` issue with transitive dependencies
90-
91-
Please [open an issue](https://github.com/mkenney/go-chrome/issues/new/choose) to report any problems or suggest any changes.
92-
93-
```toml
94-
[[constraint]]
95-
name = "github.com/mkenney/go-chrome"
96-
version = "1.0.0-rc5"
97-
```
98-
99-
## v1.0.0-rc4 released
100-
101-
[`v1.0.0-rc4`](https://github.com/mkenney/go-chrome/releases/tag/v1.0.0-rc4) has been released.
102-
103-
* Updates the log package
104-
* Cleans up and clarifies some log messages
105-
106-
Please [open an issue](https://github.com/mkenney/go-chrome/issues/new/choose) to report any problems or suggest any changes.
107-
108-
```toml
109-
[[constraint]]
110-
name = "github.com/mkenney/go-chrome"
111-
version = "1.0.0-rc4"
112-
```
113-
114-
## v1.0.0-rc3 released
115-
116-
[`v1.0.0-rc3`](https://github.com/mkenney/go-chrome/releases/tag/v1.0.0-rc3) has been released.
117-
118-
* Fixes an issue with an upstream dependency
119-
120-
Please [open an issue](https://github.com/mkenney/go-chrome/issues/new/choose) to report any problems or suggest any changes.
121-
122-
```toml
123-
[[constraint]]
124-
name = "github.com/mkenney/go-chrome"
125-
version = "1.0.0-rc3"
126-
```
127-
128-
## v1.0.0-rc2 released
129-
130-
[`v1.0.0-rc2`](https://github.com/mkenney/go-chrome/releases/tag/v1.0.0-rc2) has been released.
131-
132-
* Fixes an issue with zombie listen process
133-
* Fixes an issue with zombie stop process
134-
* Adds test coverage for socket timeouts
135-
136-
Please [open an issue](https://github.com/mkenney/go-chrome/issues/new/choose) to report any problems or suggest any changes.
137-
138-
```toml
139-
[[constraint]]
140-
name = "github.com/mkenney/go-chrome"
141-
version = "1.0.0-rc2"
142-
```
143-
144-
## v1.0.0-rc1 released
145-
146-
[`v1.0.0-rc1`](https://github.com/mkenney/go-chrome/releases/tag/v1.0.0-rc1) has been released. Please [open an issue](https://github.com/mkenney/go-chrome/issues/new/choose) to report any problems or suggest any changes.
147-
148-
```toml
149-
[[constraint]]
150-
name = "github.com/mkenney/go-chrome"
151-
version = "1.0.0-rc1"
152-
```
46+
All notable changes to this project are documented in the [`CHANGELOG`](CHANGELOG.md). The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

tot/mock.socket_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ handleEvent() as appropriate.
129129
130130
Listen is a Socketer implementation.
131131
*/
132-
func (socket *MockSocket) Listen() {
132+
func (socket *MockSocket) Listen() error {
133+
return nil
133134
}
134135

135136
/*

tot/socket/cdtp.accessibility_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
func TestAccessibilityGetPartialAXTree(t *testing.T) {
1313
socketURL, _ := url.Parse("https://test:9222/TestAccessibilityGetPartialAXTree")
1414
mockSocket := NewMock(socketURL)
15-
mockSocket.Listen()
15+
go func() { _ = mockSocket.Listen() }()
1616
defer mockSocket.Stop()
1717

1818
params := &accessibility.PartialAXTreeParams{

tot/socket/cdtp.animation_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
func TestAnimationDisable(t *testing.T) {
1515
socketURL, _ := url.Parse("https://test:9222/TestAnimationDisable")
1616
mockSocket := NewMock(socketURL)
17-
mockSocket.Listen()
17+
go func() {_ = mockSocket.Listen()}()
1818
defer mockSocket.Stop()
1919

2020
resultChan := mockSocket.Animation().Disable()
@@ -46,7 +46,7 @@ func TestAnimationDisable(t *testing.T) {
4646
func TestAnimationEnable(t *testing.T) {
4747
socketURL, _ := url.Parse("https://test:9222/TestAnimationEnable")
4848
mockSocket := NewMock(socketURL)
49-
mockSocket.Listen()
49+
go func() {_ = mockSocket.Listen()}()
5050
defer mockSocket.Stop()
5151

5252
resultChan := mockSocket.Animation().Enable()
@@ -78,7 +78,7 @@ func TestAnimationEnable(t *testing.T) {
7878
func TestAnimationGetCurrentTime(t *testing.T) {
7979
socketURL, _ := url.Parse("https://test:9222/TestAnimationGetCurrentTime")
8080
mockSocket := NewMock(socketURL)
81-
mockSocket.Listen()
81+
go func() {_ = mockSocket.Listen()}()
8282
defer mockSocket.Stop()
8383

8484
params := &animation.GetCurrentTimeParams{
@@ -141,7 +141,7 @@ func TestAnimationGetCurrentTime(t *testing.T) {
141141
func TestAnimationGetPlaybackRate(t *testing.T) {
142142
socketURL, _ := url.Parse("https://test:9222/TestAnimationGetPlaybackRate")
143143
mockSocket := NewMock(socketURL)
144-
mockSocket.Listen()
144+
go func() {_ = mockSocket.Listen()}()
145145
defer mockSocket.Stop()
146146

147147
resultChan := mockSocket.Animation().GetPlaybackRate()
@@ -184,7 +184,7 @@ func TestAnimationGetPlaybackRate(t *testing.T) {
184184
func TestAnimationReleaseAnimations(t *testing.T) {
185185
socketURL, _ := url.Parse("https://test:9222/TestAnimationReleaseAnimations")
186186
mockSocket := NewMock(socketURL)
187-
mockSocket.Listen()
187+
go func() {_ = mockSocket.Listen()}()
188188
defer mockSocket.Stop()
189189

190190
params := &animation.ReleaseAnimationsParams{
@@ -219,7 +219,7 @@ func TestAnimationReleaseAnimations(t *testing.T) {
219219
func TestAnimationResolveAnimation(t *testing.T) {
220220
socketURL, _ := url.Parse("https://test:9222/TestAnimationResolveAnimation")
221221
mockSocket := NewMock(socketURL)
222-
mockSocket.Listen()
222+
go func() {_ = mockSocket.Listen()}()
223223
defer mockSocket.Stop()
224224

225225
params := &animation.ResolveAnimationParams{
@@ -287,7 +287,7 @@ func TestAnimationResolveAnimation(t *testing.T) {
287287
func TestAnimationSeekAnimations(t *testing.T) {
288288
socketURL, _ := url.Parse("https://test:9222/TestAnimationSeekAnimations")
289289
mockSocket := NewMock(socketURL)
290-
mockSocket.Listen()
290+
go func() {_ = mockSocket.Listen()}()
291291
defer mockSocket.Stop()
292292

293293
params := &animation.SeekAnimationsParams{
@@ -323,7 +323,7 @@ func TestAnimationSeekAnimations(t *testing.T) {
323323
func TestAnimationSetPaused(t *testing.T) {
324324
socketURL, _ := url.Parse("https://test:9222/TestAnimationSetPaused")
325325
mockSocket := NewMock(socketURL)
326-
mockSocket.Listen()
326+
go func() {_ = mockSocket.Listen()}()
327327
defer mockSocket.Stop()
328328

329329
params := &animation.SetPausedParams{
@@ -359,7 +359,7 @@ func TestAnimationSetPaused(t *testing.T) {
359359
func TestAnimationSetPlaybackRate(t *testing.T) {
360360
socketURL, _ := url.Parse("https://test:9222/TestAnimationSetPlaybackRate")
361361
mockSocket := NewMock(socketURL)
362-
mockSocket.Listen()
362+
go func() {_ = mockSocket.Listen()}()
363363
defer mockSocket.Stop()
364364

365365
params := &animation.SetPlaybackRateParams{
@@ -394,7 +394,7 @@ func TestAnimationSetPlaybackRate(t *testing.T) {
394394
func TestAnimationSetTiming(t *testing.T) {
395395
socketURL, _ := url.Parse("https://test:9222/TestAnimationSetTiming")
396396
mockSocket := NewMock(socketURL)
397-
mockSocket.Listen()
397+
go func() {_ = mockSocket.Listen()}()
398398
defer mockSocket.Stop()
399399

400400
params := &animation.SetTimingParams{
@@ -431,7 +431,7 @@ func TestAnimationSetTiming(t *testing.T) {
431431
func TestAnimationOnAnimationCanceled(t *testing.T) {
432432
socketURL, _ := url.Parse("https://test:9222/TestAnimationOnAnimationCanceled")
433433
mockSocket := NewMock(socketURL)
434-
mockSocket.Listen()
434+
go func() {_ = mockSocket.Listen()}()
435435
defer mockSocket.Stop()
436436

437437
resultChan := make(chan *animation.CanceledEvent)
@@ -480,7 +480,7 @@ func TestAnimationOnAnimationCanceled(t *testing.T) {
480480
func TestAnimationOnAnimationCreated(t *testing.T) {
481481
socketURL, _ := url.Parse("https://test:9222/TestAnimationOnAnimationCreated")
482482
mockSocket := NewMock(socketURL)
483-
mockSocket.Listen()
483+
go func() {_ = mockSocket.Listen()}()
484484
defer mockSocket.Stop()
485485

486486
resultChan := make(chan *animation.CreatedEvent)
@@ -529,7 +529,7 @@ func TestAnimationOnAnimationCreated(t *testing.T) {
529529
func TestAnimationOnAnimationStarted(t *testing.T) {
530530
socketURL, _ := url.Parse("https://test:9222/TestAnimationOnAnimationStarted")
531531
mockSocket := NewMock(socketURL)
532-
mockSocket.Listen()
532+
go func() {_ = mockSocket.Listen()}()
533533
defer mockSocket.Stop()
534534

535535
resultChan := make(chan *animation.StartedEvent)

0 commit comments

Comments
 (0)