mirror of
https://github.com/openfaas/faas.git
synced 2025-06-21 00:06:38 +00:00
Vendor new queue-worker version
Introduces 0.4.6 of queue-worker - see upstream repo for changes. Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
This commit is contained in:
4
gateway/vendor/github.com/nats-io/go-nats/.travis.yml
generated
vendored
4
gateway/vendor/github.com/nats-io/go-nats/.travis.yml
generated
vendored
@ -1,9 +1,9 @@
|
||||
language: go
|
||||
sudo: false
|
||||
go:
|
||||
- 1.10.x
|
||||
- 1.9.x
|
||||
- 1.8.x
|
||||
- 1.7.x
|
||||
install:
|
||||
- go get -t ./...
|
||||
- go get github.com/nats-io/gnatsd
|
||||
@ -18,4 +18,4 @@ before_script:
|
||||
- megacheck -ignore "$(cat staticcheck.ignore)" ./...
|
||||
script:
|
||||
- go test -i -race ./...
|
||||
- if [[ "$TRAVIS_GO_VERSION" == 1.7.* ]]; then ./scripts/cov.sh TRAVIS; else go test -v -race ./...; fi
|
||||
- if [[ "$TRAVIS_GO_VERSION" == 1.9.* ]]; then ./scripts/cov.sh TRAVIS; else go test -v -race ./...; fi
|
||||
|
213
gateway/vendor/github.com/nats-io/go-nats/LICENSE
generated
vendored
213
gateway/vendor/github.com/nats-io/go-nats/LICENSE
generated
vendored
@ -1,20 +1,201 @@
|
||||
The MIT License (MIT)
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
Copyright (c) 2012-2017 Apcera Inc.
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
1. Definitions.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
7
gateway/vendor/github.com/nats-io/go-nats/OWNERS
generated
vendored
Normal file
7
gateway/vendor/github.com/nats-io/go-nats/OWNERS
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
reviewers:
|
||||
- derekcollison
|
||||
- kozlovic
|
||||
- wallyqs
|
||||
approvers:
|
||||
- derekcollison
|
||||
- kozlovic
|
25
gateway/vendor/github.com/nats-io/go-nats/README.md
generated
vendored
25
gateway/vendor/github.com/nats-io/go-nats/README.md
generated
vendored
@ -1,7 +1,7 @@
|
||||
# NATS - Go Client
|
||||
A [Go](http://golang.org) client for the [NATS messaging system](https://nats.io).
|
||||
|
||||
[](http://opensource.org/licenses/MIT)
|
||||
[](https://www.apache.org/licenses/LICENSE-2.0)
|
||||
[](https://goreportcard.com/report/github.com/nats-io/go-nats) [](http://travis-ci.org/nats-io/go-nats) [](http://godoc.org/github.com/nats-io/go-nats) [](https://coveralls.io/r/nats-io/go-nats?branch=master)
|
||||
|
||||
## Installation
|
||||
@ -327,24 +327,5 @@ err := c.RequestWithContext(ctx, "foo", req, resp)
|
||||
|
||||
## License
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2012-2017 Apcera Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to
|
||||
deal in the Software without restriction, including without limitation the
|
||||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
sell copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
IN THE SOFTWARE.
|
||||
Unless otherwise noted, the NATS source files are distributed
|
||||
under the Apache Version 2.0 license found in the LICENSE file.
|
||||
|
13
gateway/vendor/github.com/nats-io/go-nats/bench/bench.go
generated
vendored
13
gateway/vendor/github.com/nats-io/go-nats/bench/bench.go
generated
vendored
@ -1,4 +1,15 @@
|
||||
// Copyright 2016 Apcera Inc. All rights reserved.
|
||||
// Copyright 2016-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package bench
|
||||
|
||||
|
13
gateway/vendor/github.com/nats-io/go-nats/bench/benchlib_test.go
generated
vendored
13
gateway/vendor/github.com/nats-io/go-nats/bench/benchlib_test.go
generated
vendored
@ -1,3 +1,16 @@
|
||||
// Copyright 2016-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package bench
|
||||
|
||||
import (
|
||||
|
13
gateway/vendor/github.com/nats-io/go-nats/context.go
generated
vendored
13
gateway/vendor/github.com/nats-io/go-nats/context.go
generated
vendored
@ -1,4 +1,15 @@
|
||||
// Copyright 2012-2017 Apcera Inc. All rights reserved.
|
||||
// Copyright 2016-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// +build go1.7
|
||||
|
||||
|
13
gateway/vendor/github.com/nats-io/go-nats/enc.go
generated
vendored
13
gateway/vendor/github.com/nats-io/go-nats/enc.go
generated
vendored
@ -1,4 +1,15 @@
|
||||
// Copyright 2012-2015 Apcera Inc. All rights reserved.
|
||||
// Copyright 2012-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package nats
|
||||
|
||||
|
13
gateway/vendor/github.com/nats-io/go-nats/enc_test.go
generated
vendored
13
gateway/vendor/github.com/nats-io/go-nats/enc_test.go
generated
vendored
@ -1,3 +1,16 @@
|
||||
// Copyright 2012-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package nats_test
|
||||
|
||||
import (
|
||||
|
13
gateway/vendor/github.com/nats-io/go-nats/encoders/builtin/default_enc.go
generated
vendored
13
gateway/vendor/github.com/nats-io/go-nats/encoders/builtin/default_enc.go
generated
vendored
@ -1,4 +1,15 @@
|
||||
// Copyright 2012-2015 Apcera Inc. All rights reserved.
|
||||
// Copyright 2012-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package builtin
|
||||
|
||||
|
13
gateway/vendor/github.com/nats-io/go-nats/encoders/builtin/gob_enc.go
generated
vendored
13
gateway/vendor/github.com/nats-io/go-nats/encoders/builtin/gob_enc.go
generated
vendored
@ -1,4 +1,15 @@
|
||||
// Copyright 2013-2015 Apcera Inc. All rights reserved.
|
||||
// Copyright 2013-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package builtin
|
||||
|
||||
|
13
gateway/vendor/github.com/nats-io/go-nats/encoders/builtin/json_enc.go
generated
vendored
13
gateway/vendor/github.com/nats-io/go-nats/encoders/builtin/json_enc.go
generated
vendored
@ -1,4 +1,15 @@
|
||||
// Copyright 2012-2015 Apcera Inc. All rights reserved.
|
||||
// Copyright 2012-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package builtin
|
||||
|
||||
|
13
gateway/vendor/github.com/nats-io/go-nats/encoders/protobuf/protobuf_enc.go
generated
vendored
13
gateway/vendor/github.com/nats-io/go-nats/encoders/protobuf/protobuf_enc.go
generated
vendored
@ -1,4 +1,15 @@
|
||||
// Copyright 2015 Apcera Inc. All rights reserved.
|
||||
// Copyright 2015-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package protobuf
|
||||
|
||||
|
13
gateway/vendor/github.com/nats-io/go-nats/example_test.go
generated
vendored
13
gateway/vendor/github.com/nats-io/go-nats/example_test.go
generated
vendored
@ -1,3 +1,16 @@
|
||||
// Copyright 2012-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package nats_test
|
||||
|
||||
import (
|
||||
|
13
gateway/vendor/github.com/nats-io/go-nats/examples/nats-bench.go
generated
vendored
13
gateway/vendor/github.com/nats-io/go-nats/examples/nats-bench.go
generated
vendored
@ -1,4 +1,15 @@
|
||||
// Copyright 2015 Apcera Inc. All rights reserved.
|
||||
// Copyright 2015-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package main
|
||||
|
||||
|
14
gateway/vendor/github.com/nats-io/go-nats/examples/nats-pub.go
generated
vendored
14
gateway/vendor/github.com/nats-io/go-nats/examples/nats-pub.go
generated
vendored
@ -1,4 +1,16 @@
|
||||
// Copyright 2012-2016 Apcera Inc. All rights reserved.
|
||||
// Copyright 2012-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// +build ignore
|
||||
|
||||
package main
|
||||
|
14
gateway/vendor/github.com/nats-io/go-nats/examples/nats-qsub.go
generated
vendored
14
gateway/vendor/github.com/nats-io/go-nats/examples/nats-qsub.go
generated
vendored
@ -1,4 +1,16 @@
|
||||
// Copyright 2012-2016 Apcera Inc. All rights reserved.
|
||||
// Copyright 2012-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// +build ignore
|
||||
|
||||
package main
|
||||
|
14
gateway/vendor/github.com/nats-io/go-nats/examples/nats-req.go
generated
vendored
14
gateway/vendor/github.com/nats-io/go-nats/examples/nats-req.go
generated
vendored
@ -1,4 +1,16 @@
|
||||
// Copyright 2012-2016 Apcera Inc. All rights reserved.
|
||||
// Copyright 2012-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// +build ignore
|
||||
|
||||
package main
|
||||
|
14
gateway/vendor/github.com/nats-io/go-nats/examples/nats-rply.go
generated
vendored
14
gateway/vendor/github.com/nats-io/go-nats/examples/nats-rply.go
generated
vendored
@ -1,4 +1,16 @@
|
||||
// Copyright 2012-2016 Apcera Inc. All rights reserved.
|
||||
// Copyright 2012-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// +build ignore
|
||||
|
||||
package main
|
||||
|
14
gateway/vendor/github.com/nats-io/go-nats/examples/nats-sub.go
generated
vendored
14
gateway/vendor/github.com/nats-io/go-nats/examples/nats-sub.go
generated
vendored
@ -1,4 +1,16 @@
|
||||
// Copyright 2012-2016 Apcera Inc. All rights reserved.
|
||||
// Copyright 2012-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// +build ignore
|
||||
|
||||
package main
|
||||
|
240
gateway/vendor/github.com/nats-io/go-nats/nats.go
generated
vendored
240
gateway/vendor/github.com/nats-io/go-nats/nats.go
generated
vendored
@ -1,4 +1,15 @@
|
||||
// Copyright 2012-2017 Apcera Inc. All rights reserved.
|
||||
// Copyright 2012-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// A Go client for the NATS messaging system (https://nats.io).
|
||||
package nats
|
||||
@ -11,15 +22,16 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
"net"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/nats-io/go-nats/util"
|
||||
@ -28,7 +40,7 @@ import (
|
||||
|
||||
// Default Constants
|
||||
const (
|
||||
Version = "1.3.1"
|
||||
Version = "1.5.0"
|
||||
DefaultURL = "nats://localhost:4222"
|
||||
DefaultPort = 4222
|
||||
DefaultMaxReconnect = 60
|
||||
@ -351,6 +363,12 @@ type Msg struct {
|
||||
Data []byte
|
||||
Sub *Subscription
|
||||
next *Msg
|
||||
barrier *barrierInfo
|
||||
}
|
||||
|
||||
type barrierInfo struct {
|
||||
refs int64
|
||||
f func()
|
||||
}
|
||||
|
||||
// Tracks various stats received and sent on this connection,
|
||||
@ -528,6 +546,14 @@ func MaxReconnects(max int) Option {
|
||||
}
|
||||
}
|
||||
|
||||
// ReconnectBufSize sets the buffer size of messages kept while busy reconnecting
|
||||
func ReconnectBufSize(size int) Option {
|
||||
return func(o *Options) error {
|
||||
o.ReconnectBufSize = size
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// Timeout is an Option to set the timeout for Dial on a connection.
|
||||
func Timeout(t time.Duration) Option {
|
||||
return func(o *Options) error {
|
||||
@ -568,7 +594,7 @@ func DiscoveredServersHandler(cb ConnHandler) Option {
|
||||
}
|
||||
}
|
||||
|
||||
// ErrHandler is an Option to set the async error handler.
|
||||
// ErrorHandler is an Option to set the async error handler.
|
||||
func ErrorHandler(cb ErrHandler) Option {
|
||||
return func(o *Options) error {
|
||||
o.AsyncErrorCB = cb
|
||||
@ -615,7 +641,7 @@ func SetCustomDialer(dialer CustomDialer) Option {
|
||||
}
|
||||
}
|
||||
|
||||
// UseOldRequestyStyle is an Option to force usage of the old Request style.
|
||||
// UseOldRequestStyle is an Option to force usage of the old Request style.
|
||||
func UseOldRequestStyle() Option {
|
||||
return func(o *Options) error {
|
||||
o.UseOldRequestStyle = true
|
||||
@ -665,7 +691,7 @@ func (nc *Conn) SetClosedHandler(cb ConnHandler) {
|
||||
nc.Opts.ClosedCB = cb
|
||||
}
|
||||
|
||||
// SetErrHandler will set the async error handler.
|
||||
// SetErrorHandler will set the async error handler.
|
||||
func (nc *Conn) SetErrorHandler(cb ErrHandler) {
|
||||
if nc == nil {
|
||||
return
|
||||
@ -1094,7 +1120,7 @@ func (nc *Conn) connect() error {
|
||||
} else {
|
||||
// Cancel out default connection refused, will trigger the
|
||||
// No servers error conditional
|
||||
if matched, _ := regexp.Match(`connection refused`, []byte(err.Error())); matched {
|
||||
if strings.Contains(err.Error(), "connection refused") {
|
||||
returnedErr = nil
|
||||
}
|
||||
}
|
||||
@ -1229,38 +1255,40 @@ func (nc *Conn) sendConnect() error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Now read the response from the server.
|
||||
br := bufio.NewReaderSize(nc.conn, defaultBufSize)
|
||||
line, err := br.ReadString('\n')
|
||||
// We don't want to read more than we need here, otherwise
|
||||
// we would need to transfer the excess read data to the readLoop.
|
||||
// Since in normal situations we just are looking for a PONG\r\n,
|
||||
// reading byte-by-byte here is ok.
|
||||
proto, err := nc.readProto()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// If opts.Verbose is set, handle +OK
|
||||
if nc.Opts.Verbose && line == okProto {
|
||||
if nc.Opts.Verbose && proto == okProto {
|
||||
// Read the rest now...
|
||||
line, err = br.ReadString('\n')
|
||||
proto, err = nc.readProto()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// We expect a PONG
|
||||
if line != pongProto {
|
||||
if proto != pongProto {
|
||||
// But it could be something else, like -ERR
|
||||
|
||||
// Since we no longer use ReadLine(), trim the trailing "\r\n"
|
||||
line = strings.TrimRight(line, "\r\n")
|
||||
proto = strings.TrimRight(proto, "\r\n")
|
||||
|
||||
// If it's a server error...
|
||||
if strings.HasPrefix(line, _ERR_OP_) {
|
||||
if strings.HasPrefix(proto, _ERR_OP_) {
|
||||
// Remove -ERR, trim spaces and quotes, and convert to lower case.
|
||||
line = normalizeErr(line)
|
||||
return errors.New("nats: " + line)
|
||||
proto = normalizeErr(proto)
|
||||
return errors.New("nats: " + proto)
|
||||
}
|
||||
|
||||
// Notify that we got an unexpected protocol.
|
||||
return fmt.Errorf("nats: expected '%s', got '%s'", _PONG_OP_, line)
|
||||
return fmt.Errorf("nats: expected '%s', got '%s'", _PONG_OP_, proto)
|
||||
}
|
||||
|
||||
// This is where we are truly connected.
|
||||
@ -1269,6 +1297,29 @@ func (nc *Conn) sendConnect() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// reads a protocol one byte at a time.
|
||||
func (nc *Conn) readProto() (string, error) {
|
||||
var (
|
||||
_buf = [10]byte{}
|
||||
buf = _buf[:0]
|
||||
b = [1]byte{}
|
||||
protoEnd = byte('\n')
|
||||
)
|
||||
for {
|
||||
if _, err := nc.conn.Read(b[:1]); err != nil {
|
||||
// Do not report EOF error
|
||||
if err == io.EOF {
|
||||
return string(buf), nil
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
buf = append(buf, b[0])
|
||||
if b[0] == protoEnd {
|
||||
return string(buf), nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A control protocol line.
|
||||
type control struct {
|
||||
op, args string
|
||||
@ -1460,10 +1511,12 @@ func (nc *Conn) processOpErr(err error) {
|
||||
nc.conn = nil
|
||||
}
|
||||
|
||||
// Create a new pending buffer to underpin the bufio Writer while
|
||||
// we are reconnecting.
|
||||
nc.pending = &bytes.Buffer{}
|
||||
nc.bw = bufio.NewWriterSize(nc.pending, nc.Opts.ReconnectBufSize)
|
||||
// Reset pending buffers before reconnecting.
|
||||
if nc.pending == nil {
|
||||
nc.pending = new(bytes.Buffer)
|
||||
}
|
||||
nc.pending.Reset()
|
||||
nc.bw.Reset(nc.pending)
|
||||
|
||||
go nc.doReconnect()
|
||||
nc.mu.Unlock()
|
||||
@ -1571,6 +1624,13 @@ func (nc *Conn) waitForMsgs(s *Subscription) {
|
||||
if s.pHead == nil {
|
||||
s.pTail = nil
|
||||
}
|
||||
if m.barrier != nil {
|
||||
s.mu.Unlock()
|
||||
if atomic.AddInt64(&m.barrier.refs, -1) == 0 {
|
||||
m.barrier.f()
|
||||
}
|
||||
continue
|
||||
}
|
||||
s.pMsgs--
|
||||
s.pBytes -= len(m.Data)
|
||||
}
|
||||
@ -1599,6 +1659,19 @@ func (nc *Conn) waitForMsgs(s *Subscription) {
|
||||
break
|
||||
}
|
||||
}
|
||||
// Check for barrier messages
|
||||
s.mu.Lock()
|
||||
for m := s.pHead; m != nil; m = s.pHead {
|
||||
if m.barrier != nil {
|
||||
s.mu.Unlock()
|
||||
if atomic.AddInt64(&m.barrier.refs, -1) == 0 {
|
||||
m.barrier.f()
|
||||
}
|
||||
s.mu.Lock()
|
||||
}
|
||||
s.pHead = m.next
|
||||
}
|
||||
s.mu.Unlock()
|
||||
}
|
||||
|
||||
// processMsg is called by parse and will place the msg on the
|
||||
@ -1812,32 +1885,67 @@ func (nc *Conn) processInfo(info string) error {
|
||||
if info == _EMPTY_ {
|
||||
return nil
|
||||
}
|
||||
if err := json.Unmarshal([]byte(info), &nc.info); err != nil {
|
||||
ncInfo := serverInfo{}
|
||||
if err := json.Unmarshal([]byte(info), &ncInfo); err != nil {
|
||||
return err
|
||||
}
|
||||
// Copy content into connection's info structure.
|
||||
nc.info = ncInfo
|
||||
// The array could be empty/not present on initial connect,
|
||||
// if advertise is disabled on that server, or servers that
|
||||
// did not include themselves in the async INFO protocol.
|
||||
// If empty, do not remove the implicit servers from the pool.
|
||||
if len(ncInfo.ConnectURLs) == 0 {
|
||||
return nil
|
||||
}
|
||||
// Note about pool randomization: when the pool was first created,
|
||||
// it was randomized (if allowed). We keep the order the same (removing
|
||||
// implicit servers that are no longer sent to us). New URLs are sent
|
||||
// to us in no specific order so don't need extra randomization.
|
||||
hasNew := false
|
||||
// This is what we got from the server we are connected to.
|
||||
urls := nc.info.ConnectURLs
|
||||
if len(urls) > 0 {
|
||||
added := false
|
||||
// If randomization is allowed, shuffle the received array, not the
|
||||
// entire pool. We want to preserve the pool's order up to this point
|
||||
// (this would otherwise be problematic for the (re)connect loop).
|
||||
if !nc.Opts.NoRandomize {
|
||||
for i := range urls {
|
||||
j := rand.Intn(i + 1)
|
||||
urls[i], urls[j] = urls[j], urls[i]
|
||||
}
|
||||
// Transform that to a map for easy lookups
|
||||
tmp := make(map[string]struct{}, len(urls))
|
||||
for _, curl := range urls {
|
||||
tmp[curl] = struct{}{}
|
||||
}
|
||||
// Walk the pool and removed the implicit servers that are no longer in the
|
||||
// given array/map
|
||||
sp := nc.srvPool
|
||||
for i := 0; i < len(sp); i++ {
|
||||
srv := sp[i]
|
||||
curl := srv.url.Host
|
||||
// Check if this URL is in the INFO protocol
|
||||
_, inInfo := tmp[curl]
|
||||
// Remove from the temp map so that at the end we are left with only
|
||||
// new (or restarted) servers that need to be added to the pool.
|
||||
delete(tmp, curl)
|
||||
// Keep servers that were set through Options, but also the one that
|
||||
// we are currently connected to (even if it is a discovered server).
|
||||
if !srv.isImplicit || srv.url == nc.url {
|
||||
continue
|
||||
}
|
||||
for _, curl := range urls {
|
||||
if _, present := nc.urls[curl]; !present {
|
||||
if err := nc.addURLToPool(fmt.Sprintf("nats://%s", curl), true); err != nil {
|
||||
continue
|
||||
}
|
||||
added = true
|
||||
}
|
||||
if !inInfo {
|
||||
// Remove from server pool. Keep current order.
|
||||
copy(sp[i:], sp[i+1:])
|
||||
nc.srvPool = sp[:len(sp)-1]
|
||||
sp = nc.srvPool
|
||||
i--
|
||||
}
|
||||
if added && !nc.initc && nc.Opts.DiscoveredServersCB != nil {
|
||||
nc.ach <- func() { nc.Opts.DiscoveredServersCB(nc) }
|
||||
}
|
||||
// If there are any left in the tmp map, these are new (or restarted) servers
|
||||
// and need to be added to the pool.
|
||||
for curl := range tmp {
|
||||
// Before adding, check if this is a new (as in never seen) URL.
|
||||
// This is used to figure out if we invoke the DiscoveredServersCB
|
||||
if _, present := nc.urls[curl]; !present {
|
||||
hasNew = true
|
||||
}
|
||||
nc.addURLToPool(fmt.Sprintf("nats://%s", curl), true)
|
||||
}
|
||||
if hasNew && !nc.initc && nc.Opts.DiscoveredServersCB != nil {
|
||||
nc.ach <- func() { nc.Opts.DiscoveredServersCB(nc) }
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -3006,3 +3114,51 @@ func (nc *Conn) TLSRequired() bool {
|
||||
defer nc.mu.Unlock()
|
||||
return nc.info.TLSRequired
|
||||
}
|
||||
|
||||
// Barrier schedules the given function `f` to all registered asynchronous
|
||||
// subscriptions.
|
||||
// Only the last subscription to see this barrier will invoke the function.
|
||||
// If no subscription is registered at the time of this call, `f()` is invoked
|
||||
// right away.
|
||||
// ErrConnectionClosed is returned if the connection is closed prior to
|
||||
// the call.
|
||||
func (nc *Conn) Barrier(f func()) error {
|
||||
nc.mu.Lock()
|
||||
if nc.isClosed() {
|
||||
nc.mu.Unlock()
|
||||
return ErrConnectionClosed
|
||||
}
|
||||
nc.subsMu.Lock()
|
||||
// Need to figure out how many non chan subscriptions there are
|
||||
numSubs := 0
|
||||
for _, sub := range nc.subs {
|
||||
if sub.typ == AsyncSubscription {
|
||||
numSubs++
|
||||
}
|
||||
}
|
||||
if numSubs == 0 {
|
||||
nc.subsMu.Unlock()
|
||||
nc.mu.Unlock()
|
||||
f()
|
||||
return nil
|
||||
}
|
||||
barrier := &barrierInfo{refs: int64(numSubs), f: f}
|
||||
for _, sub := range nc.subs {
|
||||
sub.mu.Lock()
|
||||
if sub.mch == nil {
|
||||
msg := &Msg{barrier: barrier}
|
||||
// Push onto the async pList
|
||||
if sub.pTail != nil {
|
||||
sub.pTail.next = msg
|
||||
} else {
|
||||
sub.pHead = msg
|
||||
sub.pCond.Signal()
|
||||
}
|
||||
sub.pTail = msg
|
||||
}
|
||||
sub.mu.Unlock()
|
||||
}
|
||||
nc.subsMu.Unlock()
|
||||
nc.mu.Unlock()
|
||||
return nil
|
||||
}
|
||||
|
127
gateway/vendor/github.com/nats-io/go-nats/nats_test.go
generated
vendored
127
gateway/vendor/github.com/nats-io/go-nats/nats_test.go
generated
vendored
@ -1,3 +1,16 @@
|
||||
// Copyright 2012-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package nats
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -10,6 +23,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"strings"
|
||||
@ -40,7 +54,7 @@ func stackFatalf(t *testing.T, f string, args ...interface{}) {
|
||||
lines = append(lines, msg)
|
||||
|
||||
// Generate the Stack of callers: Skip us and verify* frames.
|
||||
for i := 2; true; i++ {
|
||||
for i := 1; true; i++ {
|
||||
_, file, line, ok := runtime.Caller(i)
|
||||
if !ok {
|
||||
break
|
||||
@ -51,6 +65,23 @@ func stackFatalf(t *testing.T, f string, args ...interface{}) {
|
||||
t.Fatalf("%s", strings.Join(lines, "\n"))
|
||||
}
|
||||
|
||||
func TestVersionMatchesTag(t *testing.T) {
|
||||
tag := os.Getenv("TRAVIS_TAG")
|
||||
if tag == "" {
|
||||
t.SkipNow()
|
||||
}
|
||||
// We expect a tag of the form vX.Y.Z. If that's not the case,
|
||||
// we need someone to have a look. So fail if first letter is not
|
||||
// a `v`
|
||||
if tag[0] != 'v' {
|
||||
t.Fatalf("Expect tag to start with `v`, tag is: %s", tag)
|
||||
}
|
||||
// Strip the `v` from the tag for the version comparison.
|
||||
if Version != tag[1:] {
|
||||
t.Fatalf("Version (%s) does not match tag (%s)", Version, tag[1:])
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Reconnect tests
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -935,7 +966,7 @@ func TestAsyncINFO(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
checkPool := func(inThatOrder bool, urls ...string) {
|
||||
checkPool := func(urls ...string) {
|
||||
// Check both pool and urls map
|
||||
if len(c.srvPool) != len(urls) {
|
||||
stackFatalf(t, "Pool should have %d elements, has %d", len(urls), len(c.srvPool))
|
||||
@ -943,35 +974,27 @@ func TestAsyncINFO(t *testing.T) {
|
||||
if len(c.urls) != len(urls) {
|
||||
stackFatalf(t, "Map should have %d elements, has %d", len(urls), len(c.urls))
|
||||
}
|
||||
for i, url := range urls {
|
||||
if inThatOrder {
|
||||
if c.srvPool[i].url.Host != url {
|
||||
stackFatalf(t, "Pool should have %q at index %q, has %q", url, i, c.srvPool[i].url.Host)
|
||||
}
|
||||
} else {
|
||||
if _, present := c.urls[url]; !present {
|
||||
stackFatalf(t, "Pool should have %q", url)
|
||||
}
|
||||
for _, url := range urls {
|
||||
if _, present := c.urls[url]; !present {
|
||||
stackFatalf(t, "Pool should have %q", url)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now test the decoding of "connect_urls"
|
||||
|
||||
// No randomize for now
|
||||
c.Opts.NoRandomize = true
|
||||
// Reset the pool
|
||||
c.setupServerPool()
|
||||
// Reinitialize the parser
|
||||
c.ps = &parseState{}
|
||||
|
||||
info = []byte("INFO {\"connect_urls\":[\"localhost:5222\"]}\r\n")
|
||||
info = []byte("INFO {\"connect_urls\":[\"localhost:4222\", \"localhost:5222\"]}\r\n")
|
||||
err = c.parse(info)
|
||||
if err != nil || c.ps.state != OP_START {
|
||||
t.Fatalf("Unexpected: %d : %v\n", c.ps.state, err)
|
||||
}
|
||||
// Pool now should contain localhost:4222 (the default URL) and localhost:5222
|
||||
checkPool(true, "localhost:4222", "localhost:5222")
|
||||
checkPool("localhost:4222", "localhost:5222")
|
||||
|
||||
// Make sure that if client receives the same, it is not added again.
|
||||
err = c.parse(info)
|
||||
@ -979,84 +1002,16 @@ func TestAsyncINFO(t *testing.T) {
|
||||
t.Fatalf("Unexpected: %d : %v\n", c.ps.state, err)
|
||||
}
|
||||
// Pool should still contain localhost:4222 (the default URL) and localhost:5222
|
||||
checkPool(true, "localhost:4222", "localhost:5222")
|
||||
checkPool("localhost:4222", "localhost:5222")
|
||||
|
||||
// Receive a new URL
|
||||
info = []byte("INFO {\"connect_urls\":[\"localhost:6222\"]}\r\n")
|
||||
info = []byte("INFO {\"connect_urls\":[\"localhost:4222\", \"localhost:5222\", \"localhost:6222\"]}\r\n")
|
||||
err = c.parse(info)
|
||||
if err != nil || c.ps.state != OP_START {
|
||||
t.Fatalf("Unexpected: %d : %v\n", c.ps.state, err)
|
||||
}
|
||||
// Pool now should contain localhost:4222 (the default URL) localhost:5222 and localhost:6222
|
||||
checkPool(true, "localhost:4222", "localhost:5222", "localhost:6222")
|
||||
|
||||
// Receive more than 1 URL at once
|
||||
info = []byte("INFO {\"connect_urls\":[\"localhost:7222\", \"localhost:8222\"]}\r\n")
|
||||
err = c.parse(info)
|
||||
if err != nil || c.ps.state != OP_START {
|
||||
t.Fatalf("Unexpected: %d : %v\n", c.ps.state, err)
|
||||
}
|
||||
// Pool now should contain localhost:4222 (the default URL) localhost:5222, localhost:6222
|
||||
// localhost:7222 and localhost:8222
|
||||
checkPool(true, "localhost:4222", "localhost:5222", "localhost:6222", "localhost:7222", "localhost:8222")
|
||||
|
||||
// Test with pool randomization now. Note that with randominzation,
|
||||
// the initial pool is randomize, then each array of urls that the
|
||||
// client gets from the INFO protocol is randomized, but added to
|
||||
// the end of the pool.
|
||||
c.Opts.NoRandomize = false
|
||||
c.setupServerPool()
|
||||
|
||||
info = []byte("INFO {\"connect_urls\":[\"localhost:5222\"]}\r\n")
|
||||
err = c.parse(info)
|
||||
if err != nil || c.ps.state != OP_START {
|
||||
t.Fatalf("Unexpected: %d : %v\n", c.ps.state, err)
|
||||
}
|
||||
// Pool now should contain localhost:4222 (the default URL) and localhost:5222
|
||||
checkPool(true, "localhost:4222", "localhost:5222")
|
||||
|
||||
// Make sure that if client receives the same, it is not added again.
|
||||
err = c.parse(info)
|
||||
if err != nil || c.ps.state != OP_START {
|
||||
t.Fatalf("Unexpected: %d : %v\n", c.ps.state, err)
|
||||
}
|
||||
// Pool should still contain localhost:4222 (the default URL) and localhost:5222
|
||||
checkPool(true, "localhost:4222", "localhost:5222")
|
||||
|
||||
// Receive a new URL
|
||||
info = []byte("INFO {\"connect_urls\":[\"localhost:6222\"]}\r\n")
|
||||
err = c.parse(info)
|
||||
if err != nil || c.ps.state != OP_START {
|
||||
t.Fatalf("Unexpected: %d : %v\n", c.ps.state, err)
|
||||
}
|
||||
// Pool now should contain localhost:4222 (the default URL) localhost:5222 and localhost:6222
|
||||
checkPool(true, "localhost:4222", "localhost:5222", "localhost:6222")
|
||||
|
||||
// Receive more than 1 URL at once. Add more than 2 to increase the chance of
|
||||
// the array being shuffled.
|
||||
info = []byte("INFO {\"connect_urls\":[\"localhost:7222\", \"localhost:8222\", " +
|
||||
"\"localhost:9222\", \"localhost:10222\", \"localhost:11222\"]}\r\n")
|
||||
err = c.parse(info)
|
||||
if err != nil || c.ps.state != OP_START {
|
||||
t.Fatalf("Unexpected: %d : %v\n", c.ps.state, err)
|
||||
}
|
||||
// Pool now should contain localhost:4222 (the default URL) localhost:5222, localhost:6222
|
||||
// localhost:7222, localhost:8222, localhost:9222, localhost:10222 and localhost:11222
|
||||
checkPool(false, "localhost:4222", "localhost:5222", "localhost:6222", "localhost:7222", "localhost:8222",
|
||||
"localhost:9222", "localhost:10222", "localhost:11222")
|
||||
|
||||
// Finally, check that (part of) the pool should be randomized.
|
||||
allUrls := []string{"localhost:4222", "localhost:5222", "localhost:6222", "localhost:7222", "localhost:8222",
|
||||
"localhost:9222", "localhost:10222", "localhost:11222"}
|
||||
same := 0
|
||||
for i, url := range c.srvPool {
|
||||
if url.url.Host == allUrls[i] {
|
||||
same++
|
||||
}
|
||||
}
|
||||
if same == len(allUrls) {
|
||||
t.Fatal("Pool does not seem to be randomized")
|
||||
}
|
||||
checkPool("localhost:4222", "localhost:5222", "localhost:6222")
|
||||
|
||||
// Check that pool may be randomized on setup, but new URLs are always
|
||||
// added at end of pool.
|
||||
|
13
gateway/vendor/github.com/nats-io/go-nats/netchan.go
generated
vendored
13
gateway/vendor/github.com/nats-io/go-nats/netchan.go
generated
vendored
@ -1,4 +1,15 @@
|
||||
// Copyright 2013-2017 Apcera Inc. All rights reserved.
|
||||
// Copyright 2013-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package nats
|
||||
|
||||
|
13
gateway/vendor/github.com/nats-io/go-nats/parser.go
generated
vendored
13
gateway/vendor/github.com/nats-io/go-nats/parser.go
generated
vendored
@ -1,4 +1,15 @@
|
||||
// Copyright 2012-2017 Apcera Inc. All rights reserved.
|
||||
// Copyright 2012-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package nats
|
||||
|
||||
|
13
gateway/vendor/github.com/nats-io/go-nats/test/auth_test.go
generated
vendored
13
gateway/vendor/github.com/nats-io/go-nats/test/auth_test.go
generated
vendored
@ -1,3 +1,16 @@
|
||||
// Copyright 2012-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package test
|
||||
|
||||
import (
|
||||
|
13
gateway/vendor/github.com/nats-io/go-nats/test/basic_test.go
generated
vendored
13
gateway/vendor/github.com/nats-io/go-nats/test/basic_test.go
generated
vendored
@ -1,3 +1,16 @@
|
||||
// Copyright 2012-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package test
|
||||
|
||||
import (
|
||||
|
13
gateway/vendor/github.com/nats-io/go-nats/test/bench_test.go
generated
vendored
13
gateway/vendor/github.com/nats-io/go-nats/test/bench_test.go
generated
vendored
@ -1,3 +1,16 @@
|
||||
// Copyright 2012-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package test
|
||||
|
||||
import (
|
||||
|
254
gateway/vendor/github.com/nats-io/go-nats/test/cluster_test.go
generated
vendored
254
gateway/vendor/github.com/nats-io/go-nats/test/cluster_test.go
generated
vendored
@ -1,7 +1,22 @@
|
||||
// Copyright 2012-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"net"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strings"
|
||||
@ -9,6 +24,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/nats-io/gnatsd/server"
|
||||
"github.com/nats-io/gnatsd/test"
|
||||
"github.com/nats-io/go-nats"
|
||||
)
|
||||
@ -25,6 +41,17 @@ var testServers = []string{
|
||||
|
||||
var servers = strings.Join(testServers, ",")
|
||||
|
||||
func serverVersionAtLeast(major, minor, update int) error {
|
||||
var (
|
||||
ma, mi, up int
|
||||
)
|
||||
fmt.Sscanf(server.VERSION, "%d.%d.%d", &ma, &mi, &up)
|
||||
if ma > major || (ma == major && mi > minor) || (ma == major && mi == minor && up >= update) {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Server version is %v, requires %d.%d.%d+", server.VERSION, major, minor, update)
|
||||
}
|
||||
|
||||
func TestServersOption(t *testing.T) {
|
||||
opts := nats.GetDefaultOptions()
|
||||
opts.NoRandomize = true
|
||||
@ -604,3 +631,230 @@ func TestPingReconnect(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type checkPoolUpdatedDialer struct {
|
||||
conn net.Conn
|
||||
first, final bool
|
||||
ra int
|
||||
}
|
||||
|
||||
func (d *checkPoolUpdatedDialer) Dial(network, address string) (net.Conn, error) {
|
||||
doReal := false
|
||||
if d.first {
|
||||
d.first = false
|
||||
doReal = true
|
||||
} else if d.final {
|
||||
d.ra++
|
||||
return nil, fmt.Errorf("On purpose")
|
||||
} else {
|
||||
d.ra++
|
||||
if d.ra == 15 {
|
||||
d.ra = 0
|
||||
doReal = true
|
||||
}
|
||||
}
|
||||
if doReal {
|
||||
c, err := net.Dial(network, address)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
d.conn = c
|
||||
return c, nil
|
||||
}
|
||||
return nil, fmt.Errorf("On purpose")
|
||||
}
|
||||
|
||||
func TestServerPoolUpdatedWhenRouteGoesAway(t *testing.T) {
|
||||
if err := serverVersionAtLeast(1, 0, 7); err != nil {
|
||||
t.Skipf(err.Error())
|
||||
}
|
||||
s1Opts := test.DefaultTestOptions
|
||||
s1Opts.Host = "127.0.0.1"
|
||||
s1Opts.Port = 4222
|
||||
s1Opts.Cluster.Host = "127.0.0.1"
|
||||
s1Opts.Cluster.Port = 6222
|
||||
s1Opts.Routes = server.RoutesFromStr("nats://127.0.0.1:6223,nats://127.0.0.1:6224")
|
||||
s1 := test.RunServer(&s1Opts)
|
||||
defer s1.Shutdown()
|
||||
|
||||
s1Url := "nats://127.0.0.1:4222"
|
||||
s2Url := "nats://127.0.0.1:4223"
|
||||
s3Url := "nats://127.0.0.1:4224"
|
||||
|
||||
ch := make(chan bool, 1)
|
||||
chch := make(chan bool, 1)
|
||||
connHandler := func(_ *nats.Conn) {
|
||||
chch <- true
|
||||
}
|
||||
nc, err := nats.Connect(s1Url,
|
||||
nats.ReconnectHandler(connHandler),
|
||||
nats.DiscoveredServersHandler(func(_ *nats.Conn) {
|
||||
ch <- true
|
||||
}))
|
||||
if err != nil {
|
||||
t.Fatalf("Error on connect")
|
||||
}
|
||||
|
||||
s2Opts := test.DefaultTestOptions
|
||||
s2Opts.Host = "127.0.0.1"
|
||||
s2Opts.Port = s1Opts.Port + 1
|
||||
s2Opts.Cluster.Host = "127.0.0.1"
|
||||
s2Opts.Cluster.Port = 6223
|
||||
s2Opts.Routes = server.RoutesFromStr("nats://127.0.0.1:6222,nats://127.0.0.1:6224")
|
||||
s2 := test.RunServer(&s2Opts)
|
||||
defer s2.Shutdown()
|
||||
|
||||
// Wait to be notified
|
||||
if err := Wait(ch); err != nil {
|
||||
t.Fatal("New server callback was not invoked")
|
||||
}
|
||||
|
||||
checkPool := func(expected []string) {
|
||||
// Don't use discovered here, but Servers to have the full list.
|
||||
// Also, there may be cases where the mesh is not formed yet,
|
||||
// so try again on failure.
|
||||
var (
|
||||
ds []string
|
||||
timeout = time.Now().Add(5 * time.Second)
|
||||
)
|
||||
for time.Now().Before(timeout) {
|
||||
ds = nc.Servers()
|
||||
if len(ds) == len(expected) {
|
||||
m := make(map[string]struct{}, len(ds))
|
||||
for _, url := range ds {
|
||||
m[url] = struct{}{}
|
||||
}
|
||||
ok := true
|
||||
for _, url := range expected {
|
||||
if _, present := m[url]; !present {
|
||||
ok = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if ok {
|
||||
return
|
||||
}
|
||||
}
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
}
|
||||
stackFatalf(t, "Expected %v, got %v", expected, ds)
|
||||
}
|
||||
// Verify that we now know about s2
|
||||
checkPool([]string{s1Url, s2Url})
|
||||
|
||||
s3Opts := test.DefaultTestOptions
|
||||
s3Opts.Host = "127.0.0.1"
|
||||
s3Opts.Port = s2Opts.Port + 1
|
||||
s3Opts.Cluster.Host = "127.0.0.1"
|
||||
s3Opts.Cluster.Port = 6224
|
||||
s3Opts.Routes = server.RoutesFromStr("nats://127.0.0.1:6222,nats://127.0.0.1:6223")
|
||||
s3 := test.RunServer(&s3Opts)
|
||||
defer s3.Shutdown()
|
||||
|
||||
// Wait to be notified
|
||||
if err := Wait(ch); err != nil {
|
||||
t.Fatal("New server callback was not invoked")
|
||||
}
|
||||
// Verify that we now know about s3
|
||||
checkPool([]string{s1Url, s2Url, s3Url})
|
||||
|
||||
// Stop s1. Since this was passed to the Connect() call, this one should
|
||||
// still be present.
|
||||
s1.Shutdown()
|
||||
// Wait for reconnect
|
||||
if err := Wait(chch); err != nil {
|
||||
t.Fatal("Reconnect handler not invoked")
|
||||
}
|
||||
checkPool([]string{s1Url, s2Url, s3Url})
|
||||
|
||||
// Check the server we reconnected to.
|
||||
reConnectedTo := nc.ConnectedUrl()
|
||||
expected := []string{s1Url}
|
||||
restartS2 := false
|
||||
if reConnectedTo == s2Url {
|
||||
restartS2 = true
|
||||
s2.Shutdown()
|
||||
expected = append(expected, s3Url)
|
||||
} else if reConnectedTo == s3Url {
|
||||
s3.Shutdown()
|
||||
expected = append(expected, s2Url)
|
||||
} else {
|
||||
t.Fatalf("Unexpected server client has reconnected to: %v", reConnectedTo)
|
||||
}
|
||||
// Wait for reconnect
|
||||
if err := Wait(chch); err != nil {
|
||||
t.Fatal("Reconnect handler not invoked")
|
||||
}
|
||||
// The implicit server that we just shutdown should have been removed from the pool
|
||||
checkPool(expected)
|
||||
|
||||
// Restart the one that was shutdown and check that it is now back in the pool
|
||||
if restartS2 {
|
||||
s2 = test.RunServer(&s2Opts)
|
||||
defer s2.Shutdown()
|
||||
expected = append(expected, s2Url)
|
||||
} else {
|
||||
s3 = test.RunServer(&s3Opts)
|
||||
defer s3.Shutdown()
|
||||
expected = append(expected, s3Url)
|
||||
}
|
||||
// Since this is not a "new" server, the DiscoveredServersCB won't be invoked.
|
||||
checkPool(expected)
|
||||
|
||||
nc.Close()
|
||||
|
||||
// Restart s1
|
||||
s1 = test.RunServer(&s1Opts)
|
||||
defer s1.Shutdown()
|
||||
|
||||
// We should have all 3 servers running now...
|
||||
|
||||
// Create a client connection with special dialer.
|
||||
d := &checkPoolUpdatedDialer{first: true}
|
||||
nc, err = nats.Connect(s1Url,
|
||||
nats.MaxReconnects(10),
|
||||
nats.ReconnectWait(15*time.Millisecond),
|
||||
nats.SetCustomDialer(d),
|
||||
nats.ReconnectHandler(connHandler),
|
||||
nats.ClosedHandler(connHandler))
|
||||
if err != nil {
|
||||
t.Fatalf("Error on connect")
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Make sure that we have all 3 servers in the pool (this will wait if required)
|
||||
checkPool(expected)
|
||||
|
||||
// Cause disconnection between client and server. We are going to reconnect
|
||||
// and we want to check that when we get the INFO again with the list of
|
||||
// servers, we don't lose the knowledge of how many times we tried to
|
||||
// reconnect.
|
||||
d.conn.Close()
|
||||
|
||||
// Wait for client to reconnect to a server
|
||||
if err := Wait(chch); err != nil {
|
||||
t.Fatal("Reconnect handler not invoked")
|
||||
}
|
||||
// At this point, we should have tried to reconnect 5 times to each server.
|
||||
// For the one we reconnected to, its max reconnect attempts should have been
|
||||
// cleared, not for the other ones.
|
||||
|
||||
// Cause a disconnect again and ensure we won't reconnect.
|
||||
d.final = true
|
||||
d.conn.Close()
|
||||
|
||||
// Wait for Close callback to be invoked.
|
||||
if err := Wait(chch); err != nil {
|
||||
t.Fatal("Close handler not invoked")
|
||||
}
|
||||
|
||||
// Since MaxReconnect is 10, after trying 5 more times on 2 of the servers,
|
||||
// these should have been removed. We have still 5 more tries for the server
|
||||
// we did previously reconnect to.
|
||||
// So total of reconnect attempt should be: 2*5+1*10=20
|
||||
if d.ra != 20 {
|
||||
t.Fatalf("Should have tried to reconnect 20 more times, got %v", d.ra)
|
||||
}
|
||||
|
||||
nc.Close()
|
||||
}
|
||||
|
1
gateway/vendor/github.com/nats-io/go-nats/test/configs/tls.conf
generated
vendored
1
gateway/vendor/github.com/nats-io/go-nats/test/configs/tls.conf
generated
vendored
@ -1,4 +1,3 @@
|
||||
|
||||
# Simple TLS config file
|
||||
|
||||
port: 4443
|
||||
|
3
gateway/vendor/github.com/nats-io/go-nats/test/configs/tlsverify.conf
generated
vendored
3
gateway/vendor/github.com/nats-io/go-nats/test/configs/tlsverify.conf
generated
vendored
@ -1,4 +1,3 @@
|
||||
|
||||
# Simple TLS config file
|
||||
|
||||
port: 4443
|
||||
@ -11,7 +10,7 @@ tls {
|
||||
|
||||
# Optional certificate authority for clients
|
||||
ca_file: "./configs/certs/ca.pem"
|
||||
|
||||
|
||||
# Require a client certificate
|
||||
verify: true
|
||||
}
|
||||
|
418
gateway/vendor/github.com/nats-io/go-nats/test/conn_test.go
generated
vendored
418
gateway/vendor/github.com/nats-io/go-nats/test/conn_test.go
generated
vendored
@ -1,3 +1,16 @@
|
||||
// Copyright 2012-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package test
|
||||
|
||||
import (
|
||||
@ -11,6 +24,7 @@ import (
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
@ -701,6 +715,7 @@ func TestCallbacksOrder(t *testing.T) {
|
||||
nats.ErrorHandler(ech),
|
||||
nats.ReconnectWait(50*time.Millisecond),
|
||||
nats.DontRandomize())
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to connect: %v\n", err)
|
||||
}
|
||||
@ -1476,12 +1491,16 @@ func TestCustomFlusherTimeout(t *testing.T) {
|
||||
|
||||
func TestNewServers(t *testing.T) {
|
||||
s1Opts := test.DefaultTestOptions
|
||||
s1Opts.Host = "127.0.0.1"
|
||||
s1Opts.Port = 4222
|
||||
s1Opts.Cluster.Host = "localhost"
|
||||
s1Opts.Cluster.Port = 6222
|
||||
s1 := test.RunServer(&s1Opts)
|
||||
defer s1.Shutdown()
|
||||
|
||||
s2Opts := test.DefaultTestOptions
|
||||
s2Opts.Host = "127.0.0.1"
|
||||
s2Opts.Port = 4223
|
||||
s2Opts.Port = s1Opts.Port + 1
|
||||
s2Opts.Cluster.Host = "localhost"
|
||||
s2Opts.Cluster.Port = 6223
|
||||
@ -1525,6 +1544,8 @@ func TestNewServers(t *testing.T) {
|
||||
|
||||
// Start a new server.
|
||||
s3Opts := test.DefaultTestOptions
|
||||
s1Opts.Host = "127.0.0.1"
|
||||
s1Opts.Port = 4224
|
||||
s3Opts.Port = s2Opts.Port + 1
|
||||
s3Opts.Cluster.Host = "localhost"
|
||||
s3Opts.Cluster.Port = 6224
|
||||
@ -1543,3 +1564,400 @@ func TestNewServers(t *testing.T) {
|
||||
t.Fatal("Did not get our callback")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBarrier(t *testing.T) {
|
||||
s := RunDefaultServer()
|
||||
defer s.Shutdown()
|
||||
|
||||
nc := NewDefaultConnection(t)
|
||||
defer nc.Close()
|
||||
|
||||
pubMsgs := int32(0)
|
||||
ch := make(chan bool, 1)
|
||||
|
||||
sub1, err := nc.Subscribe("pub", func(_ *nats.Msg) {
|
||||
atomic.AddInt32(&pubMsgs, 1)
|
||||
time.Sleep(250 * time.Millisecond)
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error on subscribe: %v", err)
|
||||
}
|
||||
|
||||
sub2, err := nc.Subscribe("close", func(_ *nats.Msg) {
|
||||
// The "close" message was sent/received lat, but
|
||||
// because we are dealing with different subscriptions,
|
||||
// which are dispatched by different dispatchers, and
|
||||
// because the "pub" subscription is delayed, this
|
||||
// callback is likely to be invoked before the sub1's
|
||||
// second callback is invoked. Using the Barrier call
|
||||
// here will ensure that the given function will be invoked
|
||||
// after the preceding messages have been dispatched.
|
||||
nc.Barrier(func() {
|
||||
res := atomic.LoadInt32(&pubMsgs) == 2
|
||||
ch <- res
|
||||
})
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error on subscribe: %v", err)
|
||||
}
|
||||
|
||||
// Send 2 "pub" messages followed by a "close" message
|
||||
for i := 0; i < 2; i++ {
|
||||
if err := nc.Publish("pub", []byte("pub msg")); err != nil {
|
||||
t.Fatalf("Error on publish: %v", err)
|
||||
}
|
||||
}
|
||||
if err := nc.Publish("close", []byte("closing")); err != nil {
|
||||
t.Fatalf("Error on publish: %v", err)
|
||||
}
|
||||
|
||||
select {
|
||||
case ok := <-ch:
|
||||
if !ok {
|
||||
t.Fatal("The barrier function was invoked before the second message")
|
||||
}
|
||||
case <-time.After(2 * time.Second):
|
||||
t.Fatal("Waited for too long...")
|
||||
}
|
||||
|
||||
// Remove all subs
|
||||
sub1.Unsubscribe()
|
||||
sub2.Unsubscribe()
|
||||
|
||||
// Barrier should be invoked in place. Since we use buffered channel
|
||||
// we are ok.
|
||||
nc.Barrier(func() { ch <- true })
|
||||
if err := Wait(ch); err != nil {
|
||||
t.Fatal("Barrier function was not invoked")
|
||||
}
|
||||
|
||||
if _, err := nc.Subscribe("foo", func(m *nats.Msg) {
|
||||
// To check that the Barrier() function works if the subscription
|
||||
// is unsubscribed after the call was made, sleep a bit here.
|
||||
time.Sleep(250 * time.Millisecond)
|
||||
m.Sub.Unsubscribe()
|
||||
}); err != nil {
|
||||
t.Fatalf("Error on subscribe: %v", err)
|
||||
}
|
||||
if err := nc.Publish("foo", []byte("hello")); err != nil {
|
||||
t.Fatalf("Error on publish: %v", err)
|
||||
}
|
||||
// We need to Flush here to make sure that message has been received
|
||||
// and posted to subscription's internal queue before calling Barrier.
|
||||
if err := nc.Flush(); err != nil {
|
||||
t.Fatalf("Error on flush: %v", err)
|
||||
}
|
||||
nc.Barrier(func() { ch <- true })
|
||||
if err := Wait(ch); err != nil {
|
||||
t.Fatal("Barrier function was not invoked")
|
||||
}
|
||||
|
||||
// Test with AutoUnsubscribe now...
|
||||
sub1, err = nc.Subscribe("foo", func(m *nats.Msg) {
|
||||
// Since we auto-unsubscribe with 1, there should not be another
|
||||
// invocation of this callback, but the Barrier should still be
|
||||
// invoked.
|
||||
nc.Barrier(func() { ch <- true })
|
||||
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error on subscribe: %v", err)
|
||||
}
|
||||
sub1.AutoUnsubscribe(1)
|
||||
// Send 2 messages and flush
|
||||
for i := 0; i < 2; i++ {
|
||||
if err := nc.Publish("foo", []byte("hello")); err != nil {
|
||||
t.Fatalf("Error on publish: %v", err)
|
||||
}
|
||||
}
|
||||
if err := nc.Flush(); err != nil {
|
||||
t.Fatalf("Error on flush: %v", err)
|
||||
}
|
||||
// Check barrier was invoked
|
||||
if err := Wait(ch); err != nil {
|
||||
t.Fatal("Barrier function was not invoked")
|
||||
}
|
||||
|
||||
// Check that Barrier only affects asynchronous subscriptions
|
||||
sub1, err = nc.Subscribe("foo", func(m *nats.Msg) {
|
||||
nc.Barrier(func() { ch <- true })
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error on subscribe: %v", err)
|
||||
}
|
||||
syncSub, err := nc.SubscribeSync("foo")
|
||||
if err != nil {
|
||||
t.Fatalf("Error on subscribe: %v", err)
|
||||
}
|
||||
msgChan := make(chan *nats.Msg, 1)
|
||||
chanSub, err := nc.ChanSubscribe("foo", msgChan)
|
||||
if err != nil {
|
||||
t.Fatalf("Error on subscribe: %v", err)
|
||||
}
|
||||
if err := nc.Publish("foo", []byte("hello")); err != nil {
|
||||
t.Fatalf("Error on publish: %v", err)
|
||||
}
|
||||
if err := nc.Flush(); err != nil {
|
||||
t.Fatalf("Error on flush: %v", err)
|
||||
}
|
||||
// Check barrier was invoked even if we did not yet consume
|
||||
// from the 2 other type of subscriptions
|
||||
if err := Wait(ch); err != nil {
|
||||
t.Fatal("Barrier function was not invoked")
|
||||
}
|
||||
if _, err := syncSub.NextMsg(time.Second); err != nil {
|
||||
t.Fatalf("Sync sub did not receive the message")
|
||||
}
|
||||
select {
|
||||
case <-msgChan:
|
||||
case <-time.After(time.Second):
|
||||
t.Fatal("Chan sub did not receive the message")
|
||||
}
|
||||
chanSub.Unsubscribe()
|
||||
syncSub.Unsubscribe()
|
||||
sub1.Unsubscribe()
|
||||
|
||||
atomic.StoreInt32(&pubMsgs, 0)
|
||||
// Check barrier does not prevent new messages to be delivered.
|
||||
sub1, err = nc.Subscribe("foo", func(_ *nats.Msg) {
|
||||
if pm := atomic.AddInt32(&pubMsgs, 1); pm == 1 {
|
||||
nc.Barrier(func() {
|
||||
nc.Publish("foo", []byte("second"))
|
||||
nc.Flush()
|
||||
})
|
||||
} else if pm == 2 {
|
||||
ch <- true
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error on subscribe: %v", err)
|
||||
}
|
||||
if err := nc.Publish("foo", []byte("first")); err != nil {
|
||||
t.Fatalf("Error on publish: %v", err)
|
||||
}
|
||||
if err := Wait(ch); err != nil {
|
||||
t.Fatal("Barrier function was not invoked")
|
||||
}
|
||||
sub1.Unsubscribe()
|
||||
|
||||
// Check that barrier works if called before connection
|
||||
// is closed.
|
||||
if _, err := nc.Subscribe("bar", func(_ *nats.Msg) {
|
||||
nc.Barrier(func() { ch <- true })
|
||||
nc.Close()
|
||||
}); err != nil {
|
||||
t.Fatalf("Error on subscribe: %v", err)
|
||||
}
|
||||
if err := nc.Publish("bar", []byte("hello")); err != nil {
|
||||
t.Fatalf("Error on publish: %v", err)
|
||||
}
|
||||
if err := nc.Flush(); err != nil {
|
||||
t.Fatalf("Error on flush: %v", err)
|
||||
}
|
||||
if err := Wait(ch); err != nil {
|
||||
t.Fatal("Barrier function was not invoked")
|
||||
}
|
||||
|
||||
// Finally, check that if connection is closed, Barrier returns
|
||||
// an error.
|
||||
if err := nc.Barrier(func() { ch <- true }); err != nats.ErrConnectionClosed {
|
||||
t.Fatalf("Expected error %v, got %v", nats.ErrConnectionClosed, err)
|
||||
}
|
||||
|
||||
// Check that one can call connection methods from Barrier
|
||||
// when there is no async subscriptions
|
||||
nc = NewDefaultConnection(t)
|
||||
defer nc.Close()
|
||||
|
||||
if err := nc.Barrier(func() {
|
||||
ch <- nc.TLSRequired()
|
||||
}); err != nil {
|
||||
t.Fatalf("Error on Barrier: %v", err)
|
||||
}
|
||||
if err := Wait(ch); err != nil {
|
||||
t.Fatal("Barrier was blocked")
|
||||
}
|
||||
}
|
||||
|
||||
func TestReceiveInfoRightAfterFirstPong(t *testing.T) {
|
||||
l, err := net.Listen("tcp", "127.0.0.1:0")
|
||||
if err != nil {
|
||||
t.Fatalf("Error on listen: %v", err)
|
||||
}
|
||||
tl := l.(*net.TCPListener)
|
||||
defer tl.Close()
|
||||
addr := tl.Addr().(*net.TCPAddr)
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
||||
c, err := tl.Accept()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer c.Close()
|
||||
// Send the initial INFO
|
||||
c.Write([]byte("INFO {}\r\n"))
|
||||
buf := make([]byte, 0, 100)
|
||||
b := make([]byte, 100)
|
||||
for {
|
||||
n, err := c.Read(b)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
buf = append(buf, b[:n]...)
|
||||
if bytes.Contains(buf, []byte("PING\r\n")) {
|
||||
break
|
||||
}
|
||||
}
|
||||
// Send PONG and following INFO in one go (or at least try).
|
||||
// The processing of PONG in sendConnect() should leave the
|
||||
// rest for the readLoop to process.
|
||||
c.Write([]byte(fmt.Sprintf("PONG\r\nINFO {\"connect_urls\":[\"127.0.0.1:%d\", \"me:1\"]}\r\n", addr.Port)))
|
||||
// Wait for client to disconnect
|
||||
for {
|
||||
if _, err := c.Read(buf); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
nc, err := nats.Connect(fmt.Sprintf("nats://127.0.0.1:%d", addr.Port))
|
||||
if err != nil {
|
||||
t.Fatalf("Error on connect: %v", err)
|
||||
}
|
||||
defer nc.Close()
|
||||
var (
|
||||
ds []string
|
||||
timeout = time.Now().Add(2 * time.Second)
|
||||
ok = false
|
||||
)
|
||||
for time.Now().Before(timeout) {
|
||||
ds = nc.DiscoveredServers()
|
||||
if len(ds) == 1 && ds[0] == "nats://me:1" {
|
||||
ok = true
|
||||
break
|
||||
}
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
}
|
||||
nc.Close()
|
||||
wg.Wait()
|
||||
if !ok {
|
||||
t.Fatalf("Unexpected discovered servers: %v", ds)
|
||||
}
|
||||
}
|
||||
|
||||
func TestReceiveInfoWithEmptyConnectURLs(t *testing.T) {
|
||||
ready := make(chan bool, 2)
|
||||
ch := make(chan bool, 1)
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
||||
ports := []int{4222, 4223}
|
||||
for i := 0; i < 2; i++ {
|
||||
l, err := net.Listen("tcp", fmt.Sprintf("127.0.0.1:%d", ports[i]))
|
||||
if err != nil {
|
||||
t.Fatalf("Error on listen: %v", err)
|
||||
}
|
||||
tl := l.(*net.TCPListener)
|
||||
defer tl.Close()
|
||||
|
||||
ready <- true
|
||||
|
||||
c, err := tl.Accept()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer c.Close()
|
||||
|
||||
// Send the initial INFO
|
||||
c.Write([]byte(fmt.Sprintf("INFO {\"server_id\":\"server%d\"}\r\n", (i + 1))))
|
||||
buf := make([]byte, 0, 100)
|
||||
b := make([]byte, 100)
|
||||
for {
|
||||
n, err := c.Read(b)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
buf = append(buf, b[:n]...)
|
||||
if bytes.Contains(buf, []byte("PING\r\n")) {
|
||||
break
|
||||
}
|
||||
}
|
||||
if i == 0 {
|
||||
// Send PONG and following INFO in one go (or at least try).
|
||||
// The processing of PONG in sendConnect() should leave the
|
||||
// rest for the readLoop to process.
|
||||
c.Write([]byte("PONG\r\nINFO {\"server_id\":\"server1\",\"connect_urls\":[\"127.0.0.1:4222\", \"127.0.0.1:4223\", \"127.0.0.1:4224\"]}\r\n"))
|
||||
// Wait for the notication
|
||||
<-ch
|
||||
// Close the connection in our side and go back into accept
|
||||
c.Close()
|
||||
} else {
|
||||
// Send no connect ULRs (as if this was an older server that could in some cases
|
||||
// send an empty array)
|
||||
c.Write([]byte(fmt.Sprintf("PONG\r\nINFO {\"server_id\":\"server2\"}\r\n")))
|
||||
// Wait for client to disconnect
|
||||
for {
|
||||
if _, err := c.Read(buf); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
// Wait for listener to be up and running
|
||||
if err := Wait(ready); err != nil {
|
||||
t.Fatal("Listener not ready")
|
||||
}
|
||||
|
||||
rch := make(chan bool)
|
||||
nc, err := nats.Connect("nats://127.0.0.1:4222",
|
||||
nats.ReconnectWait(50*time.Millisecond),
|
||||
nats.ReconnectHandler(func(_ *nats.Conn) {
|
||||
rch <- true
|
||||
}))
|
||||
if err != nil {
|
||||
t.Fatalf("Error on connect: %v", err)
|
||||
}
|
||||
defer nc.Close()
|
||||
var (
|
||||
ds []string
|
||||
timeout = time.Now().Add(2 * time.Second)
|
||||
ok = false
|
||||
)
|
||||
for time.Now().Before(timeout) {
|
||||
ds = nc.DiscoveredServers()
|
||||
if len(ds) == 2 {
|
||||
if (ds[0] == "nats://127.0.0.1:4223" && ds[1] == "nats://127.0.0.1:4224") ||
|
||||
(ds[0] == "nats://127.0.0.1:4224" && ds[1] == "nats://127.0.0.1:4223") {
|
||||
ok = true
|
||||
break
|
||||
}
|
||||
}
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
}
|
||||
if !ok {
|
||||
t.Fatalf("Unexpected discovered servers: %v", ds)
|
||||
}
|
||||
// Make the server close our connection
|
||||
ch <- true
|
||||
// Wait for the reconnect
|
||||
if err := Wait(rch); err != nil {
|
||||
t.Fatal("Did not reconnect")
|
||||
}
|
||||
// Discovered servers should still contain nats://me:1
|
||||
ds = nc.DiscoveredServers()
|
||||
if len(ds) != 2 ||
|
||||
!((ds[0] == "nats://127.0.0.1:4223" && ds[1] == "nats://127.0.0.1:4224") ||
|
||||
(ds[0] == "nats://127.0.0.1:4224" && ds[1] == "nats://127.0.0.1:4223")) {
|
||||
t.Fatalf("Unexpected discovered servers list: %v", ds)
|
||||
}
|
||||
nc.Close()
|
||||
wg.Wait()
|
||||
}
|
||||
|
13
gateway/vendor/github.com/nats-io/go-nats/test/context_test.go
generated
vendored
13
gateway/vendor/github.com/nats-io/go-nats/test/context_test.go
generated
vendored
@ -1,4 +1,15 @@
|
||||
// Copyright 2012-2017 Apcera Inc. All rights reserved.
|
||||
// Copyright 2012-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// +build go1.7
|
||||
|
||||
|
13
gateway/vendor/github.com/nats-io/go-nats/test/enc_test.go
generated
vendored
13
gateway/vendor/github.com/nats-io/go-nats/test/enc_test.go
generated
vendored
@ -1,4 +1,15 @@
|
||||
// Copyright 2012-2017 Apcera Inc. All rights reserved.
|
||||
// Copyright 2012-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package test
|
||||
|
||||
|
13
gateway/vendor/github.com/nats-io/go-nats/test/gob_test.go
generated
vendored
13
gateway/vendor/github.com/nats-io/go-nats/test/gob_test.go
generated
vendored
@ -1,4 +1,15 @@
|
||||
// Copyright 2012-2017 Apcera Inc. All rights reserved.
|
||||
// Copyright 2012-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package test
|
||||
|
||||
|
32
gateway/vendor/github.com/nats-io/go-nats/test/helper_test.go
generated
vendored
32
gateway/vendor/github.com/nats-io/go-nats/test/helper_test.go
generated
vendored
@ -1,10 +1,23 @@
|
||||
// Copyright 2015 Apcera Inc. All rights reserved.
|
||||
// Copyright 2015-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package test
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/nats-io/gnatsd/server"
|
||||
@ -37,6 +50,23 @@ func WaitTime(ch chan bool, timeout time.Duration) error {
|
||||
return errors.New("timeout")
|
||||
}
|
||||
|
||||
func stackFatalf(t tLogger, f string, args ...interface{}) {
|
||||
lines := make([]string, 0, 32)
|
||||
msg := fmt.Sprintf(f, args...)
|
||||
lines = append(lines, msg)
|
||||
|
||||
// Generate the Stack of callers: Skip us and verify* frames.
|
||||
for i := 1; true; i++ {
|
||||
_, file, line, ok := runtime.Caller(i)
|
||||
if !ok {
|
||||
break
|
||||
}
|
||||
msg := fmt.Sprintf("%d - %s:%d", i, file, line)
|
||||
lines = append(lines, msg)
|
||||
}
|
||||
t.Fatalf("%s", strings.Join(lines, "\n"))
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Creating client connections
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
13
gateway/vendor/github.com/nats-io/go-nats/test/json_test.go
generated
vendored
13
gateway/vendor/github.com/nats-io/go-nats/test/json_test.go
generated
vendored
@ -1,4 +1,15 @@
|
||||
// Copyright 2012-2017 Apcera Inc. All rights reserved.
|
||||
// Copyright 2012-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package test
|
||||
|
||||
|
13
gateway/vendor/github.com/nats-io/go-nats/test/main.go
generated
vendored
13
gateway/vendor/github.com/nats-io/go-nats/test/main.go
generated
vendored
@ -1,4 +1,15 @@
|
||||
// Copyright 2017 Apcera Inc. All rights reserved.
|
||||
// Copyright 2017-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package test
|
||||
|
||||
|
13
gateway/vendor/github.com/nats-io/go-nats/test/netchan_test.go
generated
vendored
13
gateway/vendor/github.com/nats-io/go-nats/test/netchan_test.go
generated
vendored
@ -1,3 +1,16 @@
|
||||
// Copyright 2013-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package test
|
||||
|
||||
import (
|
||||
|
13
gateway/vendor/github.com/nats-io/go-nats/test/protobuf_test.go
generated
vendored
13
gateway/vendor/github.com/nats-io/go-nats/test/protobuf_test.go
generated
vendored
@ -1,3 +1,16 @@
|
||||
// Copyright 2015-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package test
|
||||
|
||||
import (
|
||||
|
28
gateway/vendor/github.com/nats-io/go-nats/test/reconnect_test.go
generated
vendored
28
gateway/vendor/github.com/nats-io/go-nats/test/reconnect_test.go
generated
vendored
@ -1,3 +1,16 @@
|
||||
// Copyright 2013-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package test
|
||||
|
||||
import (
|
||||
@ -576,6 +589,21 @@ func TestReconnectVerbose(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestReconnectBufSizeOption(t *testing.T) {
|
||||
s := RunDefaultServer()
|
||||
defer s.Shutdown()
|
||||
|
||||
nc, err := nats.Connect("nats://localhost:4222", nats.ReconnectBufSize(32))
|
||||
if err != nil {
|
||||
t.Fatalf("Should have connected ok: %v", err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
if nc.Opts.ReconnectBufSize != 32 {
|
||||
t.Fatalf("ReconnectBufSize should be 32 but it is %d", nc.Opts.ReconnectBufSize)
|
||||
}
|
||||
}
|
||||
|
||||
func TestReconnectBufSize(t *testing.T) {
|
||||
s := RunDefaultServer()
|
||||
defer s.Shutdown()
|
||||
|
13
gateway/vendor/github.com/nats-io/go-nats/test/sub_test.go
generated
vendored
13
gateway/vendor/github.com/nats-io/go-nats/test/sub_test.go
generated
vendored
@ -1,3 +1,16 @@
|
||||
// Copyright 2013-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package test
|
||||
|
||||
import (
|
||||
|
13
gateway/vendor/github.com/nats-io/go-nats/timer.go
generated
vendored
13
gateway/vendor/github.com/nats-io/go-nats/timer.go
generated
vendored
@ -1,3 +1,16 @@
|
||||
// Copyright 2017-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package nats
|
||||
|
||||
import (
|
||||
|
13
gateway/vendor/github.com/nats-io/go-nats/timer_test.go
generated
vendored
13
gateway/vendor/github.com/nats-io/go-nats/timer_test.go
generated
vendored
@ -1,3 +1,16 @@
|
||||
// Copyright 2017-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package nats
|
||||
|
||||
import (
|
||||
|
14
gateway/vendor/github.com/nats-io/go-nats/util/tls.go
generated
vendored
14
gateway/vendor/github.com/nats-io/go-nats/util/tls.go
generated
vendored
@ -1,4 +1,16 @@
|
||||
// Copyright 2017 Apcera Inc. All rights reserved.
|
||||
// Copyright 2017-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// +build go1.8
|
||||
|
||||
package util
|
||||
|
14
gateway/vendor/github.com/nats-io/go-nats/util/tls_go17.go
generated
vendored
14
gateway/vendor/github.com/nats-io/go-nats/util/tls_go17.go
generated
vendored
@ -1,4 +1,16 @@
|
||||
// Copyright 2016 Apcera Inc. All rights reserved.
|
||||
// Copyright 2016-2018 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// +build go1.7,!go1.8
|
||||
|
||||
package util
|
||||
|
Reference in New Issue
Block a user