Skip to content
Permalink
Browse files

Add a heartbeat mechanism, and timeouts support (#53)

* Add a hearthbeat mechanism, and timeouts support

* Fix typo...

* Bump dependencies
  • Loading branch information...
dunglas committed Mar 8, 2019
1 parent 802628b commit a65ad865405db13f0bc46df3bbeb64c0206dc345
Showing with 452 additions and 23 deletions.
  1. +1 −0 .env
  2. +1 −1 .travis.yml
  3. +3 −0 README.md
  4. +61 −13 go.mod
  5. +262 −0 go.sum
  6. +36 −0 hub/options.go
  7. +19 −0 hub/options_test.go
  8. +4 −2 hub/server.go
  9. +29 −7 hub/subscribe.go
  10. +36 −0 hub/subscribe_test.go
1 .env
@@ -13,3 +13,4 @@ LOG_FORMAT=JSON
PUBLISH_ALLOWED_ORIGINS=http://localhost:3000,http://localhost:8000
PUBLISHER_JWT_KEY=
SUBSCRIBER_JWT_KEY=
HEARTBEAT_INTERVAL=10s
@@ -1,6 +1,6 @@
language: go
go:
- '1.11'
- '1.12'

env:
- GO111MODULE=on
@@ -216,11 +216,14 @@ Be sure to update the value of `ACME_HOSTS` to match your domain name(s), a Let'
* `DB_PATH`: the path of the [bbolt](https://github.com/etcd-io/bbolt) database (default to `updates.db` in the current directory)
* `DEBUG`: set to `1` to enable the debug mode (prints recovery stack traces)
* `DEMO`: set to `1` to enable the demo mode (automatically enabled when `DEBUG=1`)
* `HEARTBEAT_INTERVAL`: interval between heartbeats (useful with some proxies, and old browsers), set to `0s` to disable (default), example `15s`
* `JWT_KEY`: the JWT key to use for both publishers and subscribers
* `LOG_FORMAT`: the log format, can be `JSON`, `FLUENTD` or `TEXT` (default)
* `PUBLISH_ALLOWED_ORIGINS`: a comma separated list of origins allowed to publish (only applicable when using cookie-based auth)
* `PUBLISHER_JWT_KEY`: must contain the secret key to valid publishers' JWT, can be omited if `JWT_KEY` is set
* `READ_TIMEOUT`: maximum duration for reading the entire request, including the body, set to `0` to disable (default), example: `2m`
* `SUBSCRIBER_JWT_KEY`: must contain the secret key to valid subscribers' JWT, can be omited if `JWT_KEY` is set
* `WRITE_TIMEOUT`: maximum duration before timing out writes of the response, set to `0` to disable (default), example: `2m`

If `ACME_HOSTS` or both `CERT_FILE` and `CERT_KEY` are provided, an HTTPS server supporting HTTP/2 connection will be started.
If not, an HTTP server will be started (**not secure**).
74 go.mod
@@ -1,27 +1,75 @@
module github.com/dunglas/mercure

require (
cloud.google.com/go v0.36.0 // indirect
dmitri.shuralyov.com/app/changes v0.0.0-20181114035150-5af16e21babb // indirect
dmitri.shuralyov.com/service/change v0.0.0-20190301072032-c25fb47d71b3 // indirect
github.com/Shopify/sarama v1.21.0 // indirect
github.com/boltdb/bolt v1.3.1 // indirect
github.com/codegangsta/negroni v1.0.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/coreos/go-systemd v0.0.0-20190212144455-93d5ec2c7f76 // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/gliderlabs/ssh v0.1.3 // indirect
github.com/go-logfmt/logfmt v0.4.0 // indirect
github.com/gogo/protobuf v1.2.1 // indirect
github.com/golang/lint v0.0.0-20190301231843-5614ed5bae6f // indirect
github.com/golang/protobuf v1.3.0 // indirect
github.com/golang/snappy v0.0.1 // indirect
github.com/google/pprof v0.0.0-20190228041337-2ef8d84b2e3c // indirect
github.com/googleapis/gax-go v2.0.2+incompatible // indirect
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e // indirect
github.com/gorilla/handlers v1.4.0
github.com/gorilla/mux v1.6.2
github.com/gorilla/mux v1.7.0
github.com/gregjones/httpcache v0.0.0-20190212212710-3befbb6ad0cc // indirect
github.com/grpc-ecosystem/grpc-gateway v1.8.2 // indirect
github.com/hashicorp/golang-lru v0.5.1 // indirect
github.com/joho/godotenv v1.3.0
github.com/joonix/log v0.0.0-20180502111528-d2d3f2f4a806
github.com/kr/pretty v0.1.0 // indirect
github.com/joonix/log v0.0.0-20190213172830-51a6cca1fed3
github.com/kisielk/errcheck v1.2.0 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/mattn/goveralls v0.0.2 // indirect
github.com/onsi/gomega v1.4.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/microcosm-cc/bluemonday v1.0.2 // indirect
github.com/onsi/ginkgo v1.8.0 // indirect
github.com/openzipkin/zipkin-go v0.1.5 // indirect
github.com/pkg/errors v0.8.1 // indirect
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 // indirect
github.com/prometheus/procfs v0.0.0-20190306233201-d0f344d83b0c // indirect
github.com/rogpeppe/fastuuid v1.0.0 // indirect
github.com/russross/blackfriday v2.0.0+incompatible // indirect
github.com/satori/go.uuid v1.2.1-0.20180103174451-36e9d2ebbde5
github.com/sirupsen/logrus v1.0.6
github.com/stretchr/testify v1.2.2
github.com/unrolled/secure v0.0.0-20180914162101-439d7b25425f
github.com/shurcooL/go v0.0.0-20190121191506-3fef8c783dec // indirect
github.com/shurcooL/gofontwoff v0.0.0-20181114050219-180f79e6909d // indirect
github.com/shurcooL/highlight_diff v0.0.0-20181222201841-111da2e7d480 // indirect
github.com/shurcooL/highlight_go v0.0.0-20181215221002-9d8641ddf2e1 // indirect
github.com/shurcooL/home v0.0.0-20190204141146-5c8ae21d4240 // indirect
github.com/shurcooL/htmlg v0.0.0-20190120222857-1e8a37b806f3 // indirect
github.com/shurcooL/httpfs v0.0.0-20181222201310-74dc9339e414 // indirect
github.com/shurcooL/issues v0.0.0-20190120000219-08d8dadf8acb // indirect
github.com/shurcooL/issuesapp v0.0.0-20181229001453-b8198a402c58 // indirect
github.com/shurcooL/notifications v0.0.0-20181111060504-bcc2b3082a7a // indirect
github.com/shurcooL/octicon v0.0.0-20181222203144-9ff1a4cf27f4 // indirect
github.com/shurcooL/reactions v0.0.0-20181222204718-145cd5e7f3d1 // indirect
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
github.com/shurcooL/webdavfs v0.0.0-20181215192745-5988b2d638f6 // indirect
github.com/sirupsen/logrus v1.3.0
github.com/stretchr/testify v1.3.0
github.com/unrolled/secure v1.0.0
github.com/yosida95/uritemplate v0.0.0-20170413134207-5c22f358020b
go.etcd.io/bbolt v1.3.0
golang.org/x/crypto v0.0.0-20180910181607-0e37d006457b
golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09 // indirect
go.etcd.io/bbolt v1.3.2
go.opencensus.io v0.19.1 // indirect
go4.org v0.0.0-20190218023631-ce4c26f7be8e // indirect
golang.org/x/build v0.0.0-20190307215223-c78805dbabc8 // indirect
golang.org/x/crypto v0.0.0-20190228161510-8dd112bcdc25
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8 // indirect
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f // indirect
golang.org/x/net v0.0.0-20190301231341-16b79f2e4e95 // indirect
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421 // indirect
golang.org/x/perf v0.0.0-20190306144031-151b6387e3f2 // indirect
golang.org/x/sys v0.0.0-20190308023053-584f3b12f43e // indirect
golang.org/x/tools v0.0.0-20190308142131-b40df0fb21c3 // indirect
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19 // indirect
gopkg.in/airbrake/gobrake.v2 v2.0.9 // indirect
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 // indirect
honnef.co/go/tools v0.0.0-20190215041234-466a0476246c // indirect
sourcegraph.com/sqs/pbtypes v1.0.0 // indirect
)
Oops, something went wrong.

0 comments on commit a65ad86

Please sign in to comment.
You can’t perform that action at this time.