Compare commits

...

3579 Commits

Author SHA1 Message Date
2067c9de6b util/buffer: add new seeker implementation
Some checks failed
coverage / build (push) Failing after 1m35s
test / test (push) Successful in 3m11s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2025-02-06 15:19:09 +03:00
3f82cb3ba4 Обновить README.md
All checks were successful
coverage / build (push) Successful in 1m31s
test / test (push) Successful in 2m34s
2025-01-18 15:35:52 +03:00
vtolstov
306b7a3962 Apply Code Coverage Badge 2025-01-17 12:58:03 +00:00
a8eda9d58d Merge pull request 'move set content-type in client publish' (#394) from devstigneev/micro:v3_publish_bug into v3
All checks were successful
coverage / build (push) Successful in 1m19s
test / test (push) Successful in 2m13s
Reviewed-on: #394
2025-01-17 15:57:30 +03:00
7e4477dcb4 move set content-type in client publish
Some checks failed
test / test (pull_request) Successful in 3m40s
lint / lint (pull_request) Successful in 45s
coverage / build (pull_request) Failing after 26s
2025-01-17 15:38:53 +03:00
vtolstov
d846044fc6 Apply Code Coverage Badge 2025-01-04 16:10:26 +00:00
29d956e74e fix readme
All checks were successful
coverage / build (push) Successful in 59s
test / test (push) Successful in 3m27s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2025-01-04 19:09:50 +03:00
fcc4faff8a fix godoc link
All checks were successful
coverage / build (push) Successful in 56s
test / test (push) Successful in 3m25s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2025-01-04 18:57:02 +03:00
5df8f83f45 badges (#392)
Some checks failed
coverage / build (push) Successful in 57s
test / test (push) Has been cancelled
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
Co-authored-by: vtolstov <vtolstov@users.noreply.github.com>
Reviewed-on: #392
Co-authored-by: Vasiliy Tolstov <v.tolstov@unistack.org>
Co-committed-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2025-01-04 18:53:57 +03:00
vtolstov
27fa6e9173 Apply Code Coverage Badge 2024-12-28 22:58:19 +00:00
bd55a35dc3 logger/slog: add delayed buffer test
All checks were successful
test / test (push) Successful in 3m33s
coverage / build (push) Successful in 8m22s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-29 01:57:41 +03:00
653bd386cc util/buffer: add DelayedBuffer
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-29 01:57:41 +03:00
vtolstov
558c6f4d7c Apply Code Coverage Badge 2024-12-28 11:56:07 +00:00
d7dd6fbeb2 register/memory: fix build
All checks were successful
test / test (push) Successful in 3m35s
coverage / build (push) Successful in 8m22s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-28 14:55:20 +03:00
a00cf2c8d9 register: watcher fixes
Some checks failed
coverage / build (push) Failing after 55s
test / test (push) Successful in 3m39s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-28 14:51:10 +03:00
vtolstov
a3e8ab2492 Apply Code Coverage Badge 2024-12-27 20:57:08 +00:00
06da500ef4 register: cleanup
All checks were successful
test / test (push) Successful in 3m33s
coverage / build (push) Successful in 9m11s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-27 23:56:27 +03:00
277f04ba19 register: add Codec option
All checks were successful
coverage / build (push) Successful in 1m3s
test / test (push) Successful in 3m31s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-27 19:33:50 +03:00
vtolstov
470263ff5f Apply Code Coverage Badge 2024-12-27 16:14:00 +00:00
b8232e02be register: add ListName option
All checks were successful
test / test (push) Successful in 3m50s
coverage / build (push) Successful in 8m15s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-27 19:12:57 +03:00
vtolstov
f8c5e10c1d Apply Code Coverage Badge 2024-12-26 22:21:35 +00:00
397e71f815 Merge pull request 'register: improvements' (#390) from register into v3
All checks were successful
test / test (push) Successful in 3m50s
coverage / build (push) Successful in 13m40s
Reviewed-on: #390
2024-12-27 01:20:49 +03:00
74e31d99f6 fixup
Some checks failed
lint / lint (pull_request) Successful in 1m10s
test / test (pull_request) Successful in 3m45s
coverage / build (pull_request) Failing after 12m5s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-27 01:16:22 +03:00
f39de15d93 fixup
Some checks failed
test / test (pull_request) Failing after 55s
coverage / build (pull_request) Failing after 1m1s
lint / lint (pull_request) Successful in 1m4s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-27 01:12:29 +03:00
d291102877 register: improvements
Some checks failed
coverage / build (pull_request) Failing after 1m33s
lint / lint (pull_request) Successful in 1m52s
test / test (pull_request) Successful in 4m11s
* change domain to namespace

* lower go.mod deps

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-27 01:08:00 +03:00
37ffbb18d8 lower go.deps
Some checks failed
coverage / build (push) Failing after 30s
test / test (push) Successful in 4m5s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-26 08:35:58 +03:00
9a85dead86 lower go.deps
Some checks failed
coverage / build (push) Failing after 23s
test / test (push) Has been cancelled
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-26 08:32:59 +03:00
a489aab1c3 Merge pull request 'logger/slog: fixed time len field' (#389) from logger-slog into v3
Some checks failed
coverage / build (push) Failing after 47s
test / test (push) Successful in 7m10s
Reviewed-on: #389
2024-12-24 20:51:47 +03:00
d160664ef1 fixup test
Some checks failed
lint / lint (pull_request) Successful in 1m25s
coverage / build (pull_request) Failing after 1m25s
test / test (pull_request) Successful in 5m30s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-24 20:45:53 +03:00
fa868edcaa logger/slog: fixed time len field
Some checks failed
lint / lint (pull_request) Successful in 1m22s
test / test (pull_request) Successful in 4m50s
coverage / build (pull_request) Failing after 29s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-24 20:36:32 +03:00
vtolstov
6ed0b0e090 Apply Code Coverage Badge 2024-12-23 18:18:20 +00:00
533b265d19 add codec.RawMessage support
All checks were successful
test / test (push) Successful in 3m41s
coverage / build (push) Successful in 8m22s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-23 21:17:32 +03:00
1ace2631a4 Merge pull request 'codec: add yaml support' (#388) from codec-yaml into v3
Some checks failed
test / test (push) Failing after 13m17s
coverage / build (push) Failing after 13m26s
Reviewed-on: #388
2024-12-23 19:08:47 +03:00
3dd5ca68d1 codec: add yaml support
Some checks failed
lint / lint (pull_request) Successful in 1m38s
test / test (pull_request) Successful in 4m17s
coverage / build (pull_request) Failing after 8m42s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-23 19:08:21 +03:00
66ccd6021f Merge pull request 'codec: add yaml support' (#387) from codec-yaml into v3
Some checks failed
test / test (push) Successful in 2m28s
coverage / build (push) Failing after 13m22s
Reviewed-on: #387
2024-12-23 18:39:03 +03:00
e5346f7e4f codec: add yaml support
All checks were successful
lint / lint (pull_request) Successful in 1m31s
coverage / build (pull_request) Successful in 3m10s
test / test (pull_request) Successful in 4m1s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-23 18:38:01 +03:00
vtolstov
daf19f031a Apply Code Coverage Badge 2024-12-23 08:01:49 +00:00
5989fd54ca Merge pull request 'util/id: add uuid helper func' (#385) from uuid into v3
Some checks failed
coverage / build (push) Successful in 9m9s
test / test (push) Failing after 12m2s
Reviewed-on: #385
2024-12-23 11:00:04 +03:00
ed30c26324 util/id: add uuid helper func
Some checks failed
lint / lint (pull_request) Successful in 1m26s
test / test (pull_request) Successful in 4m2s
coverage / build (pull_request) Failing after 9m29s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-23 10:59:29 +03:00
0f8f93d09a Обновить README.md
Some checks failed
coverage / build (push) Failing after 1m1s
test / test (push) Successful in 3m46s
2024-12-22 23:42:47 +03:00
vtolstov
f460e2f8dd Apply Code Coverage Badge 2024-12-22 20:39:05 +00:00
70d6a79274 add coverage badge (#383)
Some checks failed
test / test (push) Successful in 3m37s
coverage / build (push) Has been cancelled
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
Reviewed-on: #383
Co-authored-by: Vasiliy Tolstov <v.tolstov@unistack.org>
Co-committed-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-22 23:38:28 +03:00
664b1586af util/id: add uuid v8 (#382)
All checks were successful
test / test (push) Successful in 3m25s
* util/id: add ability to specify what kind of id generate (nanoid/uuid v8)
* logger/slog: write stacktrace always on fatal
* logger/slog: try to close Out and sleep 1s

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
Reviewed-on: #382
Co-authored-by: Vasiliy Tolstov <v.tolstov@unistack.org>
Co-committed-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-22 22:23:00 +03:00
8d747c64a8 Merge pull request 'tracer: minimize overhead on noop tracer usage' (#381) from tr into v3
All checks were successful
test / test (push) Successful in 4m20s
Reviewed-on: #381
2024-12-19 19:08:22 +03:00
94beb5ed3b tracer: minimize overhead on noop tracer usage
All checks were successful
lint / lint (pull_request) Successful in 1m5s
test / test (pull_request) Successful in 3m29s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-19 18:47:03 +03:00
98981ba86c Merge pull request 'metadata: add Copy method, fix old methods' (#379) from md into v3
All checks were successful
test / test (push) Successful in 3m23s
Reviewed-on: #379
2024-12-19 16:21:09 +03:00
1013f50d0e metadata: add Copy method, fix old methods
All checks were successful
lint / lint (pull_request) Successful in 1m7s
test / test (pull_request) Successful in 3m30s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-19 16:16:07 +03:00
0b190997b1 metadata: add Copy method, fix old methods
Some checks failed
lint / lint (pull_request) Failing after 55s
test / test (pull_request) Successful in 3m33s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-19 16:03:23 +03:00
69a44eb190 correcting hooks calling (#376)
All checks were successful
test / test (push) Successful in 3m30s
Reviewed-on: #376
Co-authored-by: Evstigneev Denis <danteevstigneev@yandex.ru>
Co-committed-by: Evstigneev Denis <danteevstigneev@yandex.ru>
2024-12-18 20:31:07 +03:00
0476028f69 Merge pull request 'add context Must methods' (#377) from context into v3
All checks were successful
test / test (push) Successful in 3m46s
Reviewed-on: #377
2024-12-18 01:38:25 +03:00
330d8b149a add context Must methods
All checks were successful
lint / lint (pull_request) Successful in 1m39s
test / test (pull_request) Successful in 4m12s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-18 01:31:21 +03:00
19b04fe070 metadata: add MustGet func
All checks were successful
test / test (push) Successful in 1h34m51s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-15 23:45:17 +03:00
4cd55875c6 add Must*Context methods
All checks were successful
test / test (push) Successful in 11m55s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-13 17:02:57 +03:00
a7896cc728 Merge pull request 'logger/slog: fix dedup keys' (#374) from loggerfix into v3
All checks were successful
test / test (push) Successful in 11m49s
Reviewed-on: #374
2024-12-13 01:05:22 +03:00
ff991bf49c logger/slog: fix dedup keys
All checks were successful
lint / lint (pull_request) Successful in 1m32s
test / test (pull_request) Successful in 12m16s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-13 01:04:55 +03:00
5a6551b703 Merge pull request 'logger: improvements' (#373) from logger-dedup into v3
All checks were successful
test / test (push) Successful in 12m27s
Reviewed-on: #373
2024-12-13 00:28:28 +03:00
9406a33d60 logger: improvements
All checks were successful
lint / lint (pull_request) Successful in 1m51s
test / test (pull_request) Successful in 12m57s
* logger: add WithDedupKeys option

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-13 00:24:11 +03:00
8f185abd9d Обновить README.md
All checks were successful
test / test (push) Successful in 1m49s
2024-12-11 00:25:16 +03:00
86492e0644 Обновить README.md
All checks were successful
test / test (push) Successful in 1m42s
2024-12-11 00:23:14 +03:00
b21972964a Merge pull request 'micro-tests' (#372) from micro-tests into v3
All checks were successful
test / test (push) Successful in 1m42s
Reviewed-on: #372
2024-12-10 23:45:54 +03:00
f5ee065d09 add micro-tests trigger
All checks were successful
lint / lint (pull_request) Successful in 1m7s
test / test (pull_request) Successful in 2m47s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-10 20:21:45 +03:00
8cb02f2b08 add micro-tests trigger
Some checks failed
lint / lint (pull_request) Successful in 51s
test / test (pull_request) Failing after 1m55s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-10 20:17:51 +03:00
bc926cd6bd add micro-tests trigger
All checks were successful
test / test (pull_request) Successful in 39s
lint / lint (pull_request) Successful in 43s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-10 20:15:40 +03:00
356abfd818 add micro-tests trigger
Some checks failed
lint / lint (pull_request) Successful in 48s
test / test (pull_request) Failing after 41s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-10 20:08:10 +03:00
18444d3f98 add micro-tests trigger
Some checks failed
lint / lint (pull_request) Successful in 43s
test / test (pull_request) Failing after 36s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-10 20:05:10 +03:00
d5f07922e8 add micro-tests trigger
All checks were successful
lint / lint (pull_request) Successful in 1m19s
test / test (pull_request) Successful in 1m16s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-10 19:57:27 +03:00
675e717410 add micro-tests trigger
All checks were successful
lint / lint (pull_request) Successful in 43s
test / test (pull_request) Successful in 40s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-10 18:06:17 +03:00
7b6aea235a add micro-tests trigger
All checks were successful
lint / lint (pull_request) Successful in 46s
test / test (pull_request) Successful in 43s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-10 17:39:36 +03:00
2cb7200467 add micro-tests trigger
All checks were successful
test / test (pull_request) Successful in 36s
lint / lint (pull_request) Successful in 44s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-10 17:36:23 +03:00
f430f97a97 add micro-tests trigger
All checks were successful
lint / lint (pull_request) Successful in 43s
test / test (pull_request) Successful in 41s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-10 17:30:03 +03:00
0060c4377a add micro-tests trigger
All checks were successful
test / test (pull_request) Successful in 39s
lint / lint (pull_request) Successful in 45s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-10 17:27:28 +03:00
e46579fe9a add micro-tests trigger
Some checks failed
lint / lint (pull_request) Successful in 44s
test / test (pull_request) Failing after 37s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-10 17:14:54 +03:00
ca52973194 add micro-tests trigger
All checks were successful
lint / lint (pull_request) Successful in 43s
test / test (pull_request) Successful in 41s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-10 17:08:14 +03:00
5bb33c7e1d add micro-tests trigger
Some checks failed
test / test (pull_request) Failing after 33s
lint / lint (pull_request) Successful in 44s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-10 16:52:15 +03:00
b71fc25328 add micro-tests trigger
All checks were successful
lint / lint (pull_request) Successful in 44s
test / test (pull_request) Successful in 41s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-10 16:46:40 +03:00
9345dd075a add micro-tests trigger
Some checks failed
lint / lint (pull_request) Successful in 46s
test / test (pull_request) Failing after 41s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-10 16:16:16 +03:00
1c1b9c0a28 add micro-tests trigger
Some checks failed
lint / lint (pull_request) Successful in 1m9s
test / test (pull_request) Failing after 1m38s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-10 16:02:43 +03:00
2969494c5a Merge branch 'v3' into micro-tests
Some checks failed
test / test (pull_request) Failing after 43s
lint / lint (pull_request) Failing after 14m11s
2024-12-10 15:59:30 +03:00
cbd3fa38ba add micro-tests trigger
Some checks failed
lint / lint (pull_request) Successful in 43s
test / test (pull_request) Failing after 58s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-10 15:58:29 +03:00
569a36383d workflow fix (#371)
All checks were successful
test / test (push) Successful in 30s
Reviewed-on: #371
Co-authored-by: Vasiliy Tolstov <v.tolstov@unistack.org>
Co-committed-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-10 01:40:56 +03:00
90bed77526 workflow improve
All checks were successful
test / test (pull_request) Successful in 33s
lint / lint (pull_request) Successful in 1m11s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-10 01:38:30 +03:00
ba4478a5e0 workflow improve
Some checks failed
lint / lint (pull_request) Failing after 18m59s
test / test (pull_request) Successful in 1m20s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-10 00:59:54 +03:00
6dc76cdfea workflow improve
Some checks failed
lint / lint (pull_request) Has been cancelled
test / test (pull_request) Has been cancelled
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-10 00:56:52 +03:00
e266683d96 Merge branch 'v3' of https://git.unistack.org/unistack-org/micro into v3 2024-12-10 00:51:37 +03:00
2b62ad04f2 metadata: fix for grpc case (#370)
All checks were successful
test / test (push) Successful in 42s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
Reviewed-on: #370
2024-12-09 19:06:49 +03:00
275b0a64e5 metadata: fix for grpc case
Some checks failed
test / test (pull_request) Successful in 46s
lint / lint (pull_request) Failing after 10m4s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-09 18:02:09 +03:00
38c5fe8b5a fixed struct alignment && refactor linter (#369)
All checks were successful
test / test (push) Successful in 42s
## Pull Request template
Please, go through these steps before clicking submit on this PR.

1. Give a descriptive title to your PR.
2. Provide a description of your changes.
3. Make sure you have some relevant tests.
4. Put `closes #XXXX` in your comment to auto-close the issue that your PR fixes (if applicable).

**PLEASE REMOVE THIS TEMPLATE BEFORE SUBMITTING**

Reviewed-on: #369
Co-authored-by: Evstigneev Denis <danteevstigneev@yandex.ru>
Co-committed-by: Evstigneev Denis <danteevstigneev@yandex.ru>
2024-12-09 16:23:25 +03:00
b6a0e4d983 add metrics for dns
All checks were successful
test / test (push) Successful in 46s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-09 00:41:08 +03:00
d9b822deff logger/slog: add ability to pass func that creates slog.Handler compatible interface
All checks were successful
test / test (push) Successful in 42s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-07 16:16:45 +03:00
0e66688f8f logger/slog: add option to pass slog.Handler
All checks were successful
test / test (push) Successful in 45s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-07 14:19:29 +03:00
9213fd212f Обновить .gitea/workflows/job_lint.yml
All checks were successful
test / test (push) Successful in 51s
2024-12-06 23:13:24 +03:00
aa360dcf51 Обновить .gitea/workflows/job_lint.yml
All checks were successful
test / test (push) Successful in 50s
2024-12-06 23:11:48 +03:00
2df259b5b8 Обновить .gitea/workflows/job_test.yml
Some checks failed
test / test (push) Has been cancelled
2024-12-06 23:11:32 +03:00
15e9310368 Merge pull request 'Update actions' (#368) from atolstikhin/micro:v3 into v3
All checks were successful
test / test (push) Successful in 1m1s
Reviewed-on: #368
2024-12-06 23:08:50 +03:00
Aleksandr Tolstikhin
16d8cf3434 Update actions
All checks were successful
test / test (pull_request) Successful in 1m4s
lint / lint (pull_request) Successful in 10m11s
2024-12-07 02:37:12 +07:00
9704ef2e5e fix pipeline (#365)
Co-authored-by: Aleksandr Tolstikhin <atolstikhin@mtsbank.ru>
Reviewed-on: #365
Co-authored-by: Vasiliy Tolstov <v.tolstov@unistack.org>
Co-committed-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-06 19:05:27 +03:00
94e8f90f00 Merge pull request 'removed create empty out/ingoing metadata' (#364) from devstigneev/micro:v3 into v3
Reviewed-on: #364
Reviewed-by: Василий Толстов <v.tolstov@unistack.org>
2024-12-06 12:49:25 +03:00
34d1587881 removed create empty out/ingoing metadata
Some checks failed
lint / lint (pull_request) Has been cancelled
pr / test (pull_request) Has been cancelled
2024-12-06 00:08:03 +03:00
bf4143cde5 replace default go resolver with caching resolver
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-03 01:11:08 +03:00
36b7b9f5fb add Live/Ready/Health methods
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-02 13:20:13 +03:00
ae97023092 store: updates for Watcher
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-01 19:54:38 +03:00
115ca6a018 logger: add WithAddFields option
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-11-29 15:34:02 +03:00
89cf4ef8af store: add missin LazyConnect option
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-11-26 17:48:09 +03:00
2a6ce6d4da add using lazy connect (#361)
#357

Co-authored-by: Василий Толстов <v.tolstov@unistack.org>
Reviewed-on: #361
Reviewed-by: Василий Толстов <v.tolstov@unistack.org>
Co-authored-by: Evstigneev Denis <danteevstigneev@yandex.ru>
Co-committed-by: Evstigneev Denis <danteevstigneev@yandex.ru>
2024-11-26 12:18:17 +03:00
ad19fe2b90 logger/slog: fix race condigtion with Enabled and Level
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-11-24 23:40:54 +03:00
49055a28ea logger/slog: wrap handler
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-11-24 23:28:15 +03:00
d1c6e121c1 logger/slog: fix Clone and Fields methods
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-11-24 15:31:40 +03:00
7cd7fb0c0a disable logging for automaxprocs
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-11-20 22:35:36 +03:00
77eb5b5264 add yaml support
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-11-01 11:23:29 +03:00
929e46c087 improve slog
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-11-01 00:56:40 +03:00
1fb5673d27 fixup graceful stop
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-10-25 17:21:54 +03:00
3bbb0cbc72 update slog/logger (#351)
Изменено (методы logger без форматирования):

- Добавлена подготовка и выравнивание аттрибутов для logger
- Выравнивание за счет добавления !BADKEY до процессинга log/slog
- Добавлено переиспользование метода Log
- Удалены методы [Logf, Infof, Debugf, Errorf, Warnf, Fatalf, Tracef]
- Обновлены юниттесты
- Удален wrapper в пакете logger
- Изменен интерфейс logger
- Отрефакторены вызовы logger'a в micro

Co-authored-by: Vasiliy Tolstov <v.tolstov@unistack.org>
Reviewed-on: #351
Co-authored-by: Evstigneev Denis <danteevstigneev@yandex.ru>
Co-committed-by: Evstigneev Denis <danteevstigneev@yandex.ru>
2024-10-12 12:37:43 +03:00
71fe0df73f use automaxproc and automemlimit
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-10-06 13:50:59 +03:00
f1b8ecbdb3 store: add new ErrNotConnected error
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-10-05 14:46:22 +03:00
fd2b2762e9 fixup missing xpool dep
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-09-30 09:57:07 +03:00
82d269cfb4 xpool: add metrics
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-09-29 22:58:53 +03:00
6641463eed util/reflect: add ability to merge maps
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-09-20 19:22:20 +03:00
faf2454f0a cleanup
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-09-20 17:54:17 +03:00
de9e4d73f5 change semconv metric names to include micro_ prefix
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-09-20 08:38:36 +03:00
4ae7277140 meter: remove prefix options
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-09-20 08:27:25 +03:00
a98618ed5b add codec.Flatten option
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-09-16 23:10:43 +03:00
3aaf1182cb add codec option
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-09-16 23:02:45 +03:00
eb1482d789 codec: simplify codec interface
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-09-16 22:41:47 +03:00
a305f7553f Merge pull request '#347 add test' (#349) from kgorbunov/micro:#347-v3 into v3
Reviewed-on: #349
2024-09-16 14:59:58 +03:00
Gorbunov Kirill Andreevich
d9b2f2a45d #347 add test
Some checks failed
pr / test (pull_request) Failing after 0s
lint / lint (pull_request) Failing after 1s
2024-09-16 14:48:47 +03:00
3ace7657dc codec: RawMessage Marshal fix
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-09-10 10:43:45 +03:00
53b40617e2 fixup util/xpool
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-09-04 23:06:40 +03:00
1a9236caad update meter options
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-09-04 22:41:10 +03:00
6c68d39081 errors: add RFC9457 problem type
closes #297

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-08-01 01:06:02 +03:00
35e62fbeb0 tracer: add default context attr funcs option
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-07-06 00:09:27 +03:00
00b3ceb468 smeconv: fix naming
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-07-04 14:56:48 +03:00
7dc8f088c9 Merge pull request 'fix impl interface' (#346) from devstigneev/micro:fix_impl_mevent into v3
Reviewed-on: #346
2024-07-01 12:26:53 +03:00
c65afcea1b fix impl interface
Some checks failed
lint / lint (pull_request) Has been cancelled
pr / test (pull_request) Has been cancelled
2024-07-01 09:47:51 +03:00
3eebfb5b11 Обновить options.go 2024-05-10 08:12:10 +03:00
fa1427014c close #343
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-05-09 19:16:12 +03:00
62074965ee close #329
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-05-09 16:41:22 +03:00
9c8fbb2202 broker: add Event Context() method
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-05-05 16:22:06 +03:00
7c0a5f5e2a add abilit to skip span recording
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-05-04 19:31:35 +03:00
b08f5321b0 tracer: allow to skip span recording
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-05-04 19:18:12 +03:00
cc0f24e012 add ability to skip endpoints for tracer and meter
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-05-04 19:05:07 +03:00
307a08f50c add more checks
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-05-04 15:31:08 +03:00
edc93e8c37 util/reflect: update StructFieldNameByTag
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-05-04 14:43:46 +03:00
391813c260 util/reflect: add StructFieldNameByTag
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-05-04 14:34:41 +03:00
1a1459dd0e util/reflect: fix StructFieldByTag
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-05-04 13:16:31 +03:00
4e99680c30 server: add missing hook definitions
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-04-23 07:39:08 +03:00
92a3a547b8 Merge pull request 'server/noop: cleanup' (#342) from server-noop into v3
Reviewed-on: #342
2024-04-23 07:30:20 +03:00
849c462037 server/noop: cleanup
All checks were successful
pr / test (pull_request) Successful in 1m38s
lint / lint (pull_request) Successful in 10m35s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-04-23 07:28:58 +03:00
54a55c83e2 Merge pull request 'add client tracing' (#341) from traceclient into v3
Reviewed-on: #341
2024-04-22 23:44:54 +03:00
781dee03db add client tracing
All checks were successful
pr / test (pull_request) Successful in 1m36s
lint / lint (pull_request) Successful in 10m37s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-04-22 23:39:21 +03:00
26dd2eb405 Merge pull request 'replace wrappers with hooks' (#339) from hooks into v3
Reviewed-on: #339
2024-04-22 08:50:53 +03:00
3a21069b86 remote stale test
All checks were successful
pr / test (pull_request) Successful in 2m55s
lint / lint (pull_request) Successful in 11m55s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-04-22 08:50:33 +03:00
add3ce478c replace wrappers with hooks
Some checks failed
pr / test (pull_request) Failing after 2m59s
lint / lint (pull_request) Successful in 11m36s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-04-22 08:47:50 +03:00
Кирилл Горбунов
c3de003e4a #335 caller skip count. (#337)
Co-authored-by: Gorbunov Kirill Andreevich <kgorbunov@mtsbank.ru>
Reviewed-on: #337
Co-authored-by: Кирилл Горбунов <kirya_gorbunov_2015@mail.ru>
Co-committed-by: Кирилл Горбунов <kirya_gorbunov_2015@mail.ru>
2024-04-15 13:30:48 +03:00
7b7cf18a65 semconv: add cache metric names
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-04-14 16:42:36 +03:00
1bcf71c189 util/xpool: package pool
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-04-14 00:16:55 +03:00
c320d8e518 store/options: extend options to holds name and timeout
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-04-13 12:52:06 +03:00
b5f8316b57 semconv: fix broker group lag metric name
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-04-13 02:38:58 +03:00
d7ddd912a8 Merge pull request 'semconv: add broker group lag' (#336) from brokerlag into v3
Reviewed-on: #336
2024-04-13 02:07:53 +03:00
c020d90cb4 semconv: add broker group lag
Some checks failed
pr / test (pull_request) Failing after 1m39s
lint / lint (pull_request) Successful in 10m49s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-04-13 02:06:51 +03:00
db47b62159 Merge pull request 'add options in broker' (#334) from devstigneev/micro:v3 into v3
Reviewed-on: #334
2024-04-08 23:12:59 +03:00
8254456c8b rename path to sync
Some checks failed
lint / lint (pull_request) Has been cancelled
pr / test (pull_request) Has been cancelled
2024-04-07 21:16:50 +03:00
c2808679c3 add options in broker
Some checks failed
lint / lint (pull_request) Has been cancelled
pr / test (pull_request) Has been cancelled
2024-04-07 20:53:01 +03:00
f418235c16 Merge pull request 'cluster: initial import' (#332) from cluster into v3
Reviewed-on: #332
2024-04-06 23:29:04 +03:00
67ba7b3753 cluster: initial import
Some checks failed
pr / test (pull_request) Failing after 1m36s
lint / lint (pull_request) Successful in 10m48s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-04-06 23:28:01 +03:00
e48d7cadf9 Merge pull request 'add semconv package' (#331) from semconv into v3
Reviewed-on: #331
2024-04-06 22:04:47 +03:00
c906186011 add semconv package
Some checks failed
pr / test (pull_request) Failing after 1m39s
lint / lint (pull_request) Successful in 10m24s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-04-06 22:03:56 +03:00
dc0ff91b83 Merge pull request 'util/reflect: detect json.Unmarshaler' (#328) from utilsort into v3
Reviewed-on: #328
2024-04-02 08:52:11 +03:00
e739c2d438 util/reflect: detect json.Unmarshaler
Some checks failed
lint / lint (pull_request) Has been cancelled
pr / test (pull_request) Failing after 2m3s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-04-02 08:51:06 +03:00
bf4a036652 Merge pull request 'move sort.Uniq to dedicated package' (#327) from utilsort into v3
Reviewed-on: #327
2024-03-27 11:25:50 +03:00
f83a29eb67 move sort.Uniq to dedicated package
Some checks failed
lint / lint (pull_request) Has been cancelled
pr / test (pull_request) Has been cancelled
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-03-27 11:24:28 +03:00
aef7f53d88 Merge pull request 'tracer: append labels' (#326) from tracerfix into v3
Reviewed-on: #326
2024-03-17 00:18:23 +03:00
02c8e4fb7f tracer: append labels
All checks were successful
pr / test (pull_request) Successful in 1m35s
lint / lint (pull_request) Successful in 10m38s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-03-17 00:17:10 +03:00
f5693bd940 Merge pull request 'v3 update WaitGroup Options' (#325) from devstigneev/micro:v3 into v3
Reviewed-on: #325
2024-03-13 11:03:29 +03:00
701afb7bea sort imports
Some checks failed
lint / lint (pull_request) Has been cancelled
pr / test (pull_request) Has been cancelled
2024-03-13 10:51:03 +03:00
019b407e74 update WaitOptions 2024-03-13 10:49:58 +03:00
f29a346434 Merge pull request 'tracer: add Context init to NewOptions' (#323) from tracerctx into v3
Reviewed-on: #323
2024-03-11 01:13:01 +03:00
27db1876c0 tracer: add Context init to NewOptions
All checks were successful
pr / test (pull_request) Successful in 1m30s
lint / lint (pull_request) Successful in 10m33s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-03-11 01:12:20 +03:00
f66ac9736b metadata: allow to exclude some keys in Copy func (#321)
Reviewed-on: #321
Co-authored-by: Vasiliy Tolstov <v.tolstov@unistack.org>
Co-committed-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-03-09 23:50:40 +03:00
ed7972a1fa Merge pull request 'sync/waitgroup: backport from master' (#320) from waitgroup into v3
Reviewed-on: #320
2024-03-09 23:37:39 +03:00
2cc004b01c sync/waitgroup: backport from master
All checks were successful
pr / test (pull_request) Successful in 1m40s
lint / lint (pull_request) Successful in 10m42s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-03-09 23:36:39 +03:00
df951e5daf Merge pull request 'logger/slog: fix slog' (#317) from slogfix2 into v3
Reviewed-on: #317
2024-03-07 08:22:37 +03:00
5bec0cef03 logger/slog: fix slog
All checks were successful
pr / test (pull_request) Successful in 1m24s
lint / lint (pull_request) Successful in 10m24s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-03-07 08:19:14 +03:00
34940b68d7 Merge pull request 'logger/slog: fix race condition' (#316) from slogfix into v3
Reviewed-on: #316
2024-03-07 07:45:07 +03:00
1c57127128 logger/slog: fix race condition
All checks were successful
pr / test (pull_request) Successful in 1m34s
lint / lint (pull_request) Successful in 10m36s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-03-07 07:43:52 +03:00
a4dd1a494c Merge pull request 'logger: add TimeFunc option' (#315) from logger-timefunc into v3
Reviewed-on: #315
2024-03-07 00:02:53 +03:00
60e5e42167 logger: add TimeFunc option
All checks were successful
pr / test (pull_request) Successful in 1m36s
lint / lint (pull_request) Successful in 10m45s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-03-07 00:02:00 +03:00
b519b61fff Merge pull request 'fixup interfaces' (#314) from iface-v3 into v3
Reviewed-on: #314
2024-03-06 18:49:03 +03:00
f62b26eda3 fixup interfaces
Some checks failed
pr / test (pull_request) Failing after 1m30s
lint / lint (pull_request) Successful in 10m37s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-03-06 18:45:32 +03:00
13eda451da Merge pull request 'fixup deps' (#313) from deps into v3
Reviewed-on: #313
2024-03-06 16:46:33 +03:00
89cad06121 fixup deps
Some checks failed
pr / test (pull_request) Failing after 1m35s
lint / lint (pull_request) Successful in 10m44s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-03-06 16:45:19 +03:00
0bebf3d59f Merge pull request 'tracer and logger improvements' (#312) from tracer-logger into v3
Reviewed-on: #312
2024-03-06 00:57:01 +03:00
01e05e8df6 tracer and logger improvements
Some checks failed
pr / test (pull_request) Failing after 1m27s
lint / lint (pull_request) Successful in 10m33s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-03-06 00:53:20 +03:00
2b69a4f51c Merge pull request 'logger/slog: backport default logger keys from master' (#311) from v3-logger into v3
Reviewed-on: #311
2024-03-05 01:54:17 +03:00
4af2b077dd logger/slog: backport default logger keys from master
All checks were successful
pr / test (pull_request) Successful in 1m45s
lint / lint (pull_request) Successful in 10m43s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-03-04 23:58:31 +03:00
de4418189d Merge pull request 'add missing option' (#309) from logger-stacktrace into v3
Reviewed-on: #309
2024-03-04 23:04:50 +03:00
2c44550897 add missing option
All checks were successful
pr / test (pull_request) Successful in 1m46s
lint / lint (pull_request) Successful in 10m49s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-03-04 23:03:55 +03:00
99b8a3c950 Merge pull request 'logger/slog: add stacktrace support' (#308) from logger-stacktrace into v3
Reviewed-on: #308
2024-03-04 23:00:35 +03:00
4c7e1607d4 logger/slog: add stacktrace support
Some checks failed
pr / test (pull_request) Failing after 1m28s
lint / lint (pull_request) Successful in 10m40s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-03-04 22:54:11 +03:00
897be419b4 Merge pull request 'broker noop implementation' (#307) from noops into v3
Reviewed-on: #307
2024-03-04 01:15:16 +03:00
81b9a4341f logger: extend interface, fix tests
All checks were successful
pr / test (pull_request) Successful in 1m35s
lint / lint (pull_request) Successful in 10m40s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-03-04 01:09:08 +03:00
d3bb2f7236 broker/noop: add initial implementation
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-03-04 01:05:40 +03:00
97fd62cb21 Merge pull request 'register/noop: add noop register' (#306) from register-noop into v3
Reviewed-on: #306
2024-03-01 21:40:01 +03:00
3cd8bc33d6 fixup test
Some checks failed
pr / test (pull_request) Failing after 1m31s
lint / lint (pull_request) Successful in 10m44s
2024-03-01 21:39:31 +03:00
f6f67af8d0 register/noop: add noop register
Some checks failed
pr / test (pull_request) Failing after 1m34s
lint / lint (pull_request) Successful in 11m0s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-02-29 23:58:11 +03:00
2d5acaca2f Merge pull request 'server: add GracefulTimeout option' (#304) from graceful into v3
Reviewed-on: #304
2024-02-29 23:24:43 +03:00
0674df3d9f update workflow
Some checks failed
pr / test (pull_request) Failing after 1m40s
lint / lint (pull_request) Successful in 11m5s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-02-29 23:23:51 +03:00
2c282825ce fixup
Some checks failed
pr / test (pull_request) Failing after 1m38s
lint / lint (pull_request) Failing after 1m47s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-02-29 23:17:36 +03:00
e87ff942bb bump gomod
Some checks failed
lint / lint (pull_request) Failing after 1m40s
pr / test (pull_request) Failing after 1m44s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-02-29 23:03:39 +03:00
0459ea0613 fixup
Some checks failed
lint / lint (pull_request) Failing after 1m38s
pr / test (pull_request) Failing after 1m38s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-02-29 22:40:05 +03:00
d44a75d074 add gracefultimeout in server 2024-02-29 22:35:55 +03:00
Кирилл Горбунов
ccf92eb84d As for interface casting
Co-authored-by: Gorbunov Kirill Andreevich <kgorbunov@mtsbank.ru>
Reviewed-on: #299
Co-authored-by: Кирилл Горбунов <kirya_gorbunov_2015@mail.ru>
Co-committed-by: Кирилл Горбунов <kirya_gorbunov_2015@mail.ru>
2024-02-27 23:35:49 +03:00
6baf1f2744 Merge pull request 'logger/slog: fixup race condition' (#292) from log into v3
Reviewed-on: #292
2024-02-22 08:58:40 +03:00
8e2eafde9c logger/slog: fixup race condition
Some checks failed
lint / lint (pull_request) Has been cancelled
pr / test (pull_request) Has been cancelled
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-02-22 08:57:21 +03:00
c2b97b0f20 fixup logger/slog
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-02-15 10:01:41 +03:00
1db017d966 Merge pull request 'logger/slog: fixup old format' (#291) from fixupslog into v3
Reviewed-on: #291
2024-02-08 08:44:23 +03:00
debf8cb03d logger/slog: fixup old format
Some checks failed
lint / lint (pull_request) Has been cancelled
pr / test (pull_request) Has been cancelled
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-02-08 08:43:53 +03:00
1dc9c1891f Merge pull request 'logger/slog: initial import' (#290) from slog into v3
Reviewed-on: #290
2024-02-08 08:18:57 +03:00
930859a537 logger/slog: initial import
Some checks failed
lint / lint (pull_request) Has been cancelled
pr / test (pull_request) Has been cancelled
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-02-08 08:17:53 +03:00
3141f1ed8b Merge pull request 'config: add conditions' (#286) from cond-config into v3
Reviewed-on: #286
2024-01-15 00:46:37 +03:00
47943cfb05 config: add conditions
Some checks failed
lint / lint (pull_request) Successful in 1m28s
pr / test (pull_request) Failing after 1m5s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-01-15 00:46:00 +03:00
ed4e9d54b1 Merge pull request 'client/noop: fixup md' (#285) from noopfix into v3
Reviewed-on: #285
2023-12-21 00:14:54 +03:00
b4b8583594 client/noop: fixup md
Some checks failed
lint / lint (pull_request) Failing after 1m28s
pr / test (pull_request) Failing after 2m45s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-12-21 00:13:08 +03:00
fb43e8c58c Merge pull request 'client/noop: fix metadata overwrite' (#284) from noopfix into v3
Reviewed-on: #284
2023-12-21 00:07:22 +03:00
8863c10ef4 client/noop: fix metadata overwrite
Some checks failed
lint / lint (pull_request) Failing after 1m29s
pr / test (pull_request) Failing after 2m36s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-12-21 00:06:56 +03:00
8058095bcc Merge pull request 'copy incoming content-type' (#283) from ct into v3
Reviewed-on: #283
2023-12-20 09:35:33 +03:00
092f5d96b1 copy incoming content-type
Some checks failed
lint / lint (pull_request) Failing after 1m28s
pr / test (pull_request) Failing after 2m33s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-12-20 09:35:01 +03:00
84552513f7 Merge pull request 'fixup multiple client handling' (#280) from multiple into v3
Reviewed-on: #280
2023-11-13 08:20:52 +03:00
80a2db264e fixup multiple client handling
Some checks failed
lint / lint (pull_request) Failing after 1m29s
pr / test (pull_request) Failing after 2m35s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-11-13 08:19:44 +03:00
0be09c8b3e Merge pull request 'database: add FormatDSN' (#278) from database-newv3 into v3
Reviewed-on: #278
2023-11-02 01:35:25 +03:00
047f479e1b database: add FormatDSN
Some checks failed
lint / lint (pull_request) Failing after 1m27s
pr / test (pull_request) Failing after 2m39s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-11-02 01:32:26 +03:00
8f757c953e Merge pull request 'database: initial import for dsn parsing' (#276) from databasev3 into v3
Reviewed-on: #276
2023-11-01 23:44:17 +03:00
5f1c673a24 database: initial import for dsn parsing
Some checks failed
lint / lint (pull_request) Failing after 1m28s
pr / test (pull_request) Failing after 2m36s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-11-01 23:42:48 +03:00
6794ea9871 Merge pull request 'client/noop: fix MessageMetadata option' (#274) from client-noop-metadata into v3
Reviewed-on: #274
2023-10-26 03:07:12 +03:00
089e7b6812 client/noop: fix MessageMetadata option
All checks were successful
lint / lint (pull_request) Successful in 1m18s
pr / test (pull_request) Successful in 1m1s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-10-26 03:06:39 +03:00
1c703f0f0c Merge pull request 'errors: add IsRetrayable func' (#273) from errors into v3
Reviewed-on: #273
2023-10-25 10:24:58 +03:00
d167c8c67c cleanup
All checks were successful
lint / lint (pull_request) Successful in 1m7s
pr / test (pull_request) Successful in 1m2s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-10-25 02:36:52 +03:00
df4f96a2d8 errors: add IsRetrayable func
All checks were successful
lint / lint (pull_request) Successful in 1m18s
pr / test (pull_request) Successful in 1m3s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-10-23 02:35:10 +03:00
fac3b20bd4 Merge pull request 'util/reflect: add Equal func with ability to skip some fields' (#244) from util-reflect into v3
Reviewed-on: #244
2023-09-12 11:45:26 +03:00
7c6bd98498 util/reflect: add Equal func with ability to skip some fields
All checks were successful
pr / test (pull_request) Successful in 1m4s
lint / lint (pull_request) Successful in 1m10s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-09-12 10:31:45 +03:00
23e1174f25 Merge pull request 'tracer: improve' (#241) from tracing into v3
Reviewed-on: #241
2023-09-08 13:40:51 +03:00
52bed214cf tracer: improve
Some checks failed
lint / lint (pull_request) Failing after 1m31s
pr / test (pull_request) Failing after 2m44s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-09-08 13:40:01 +03:00
64c4f5f47e Merge pull request 'tracer: tweaks for span tags and naming' (#239) from tracing into v3
Reviewed-on: #239
2023-09-01 14:58:15 +03:00
036c612137 tracer: tweaks for span tags and naming
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-09-01 14:58:15 +03:00
ca80e3ecf2 Merge pull request 'tracer: improve tracing info' (#238) from tracing into v3
Reviewed-on: #238
2023-09-01 08:41:46 +03:00
18e7bb41ca tracer: improve tracing info
Some checks failed
lint / lint (pull_request) Failing after 1m29s
pr / test (pull_request) Failing after 2m37s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-09-01 08:41:23 +03:00
8e72fb1c35 Merge pull request 'add util/test' (#235) from util-test into v3
Reviewed-on: #235
2023-08-07 18:35:31 +03:00
17f21a03f4 add util/test
Some checks failed
lint / lint (pull_request) Failing after 1m28s
pr / test (pull_request) Failing after 2m35s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-08-07 18:33:23 +03:00
a076d43a26 add util/test
Some checks failed
lint / lint (pull_request) Failing after 1m31s
pr / test (pull_request) Failing after 2m33s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-08-07 18:32:29 +03:00
de6efaee0b Merge pull request 'config/default: add micro:generate uuid/id' (#232) from config-default-gen into v3
Reviewed-on: #232
2023-07-13 20:27:13 +03:00
9e0e657003 config/default: add micro:generate uuid/id
Some checks failed
lint / lint (pull_request) Failing after 1m28s
pr / test (pull_request) Failing after 2m35s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-07-13 20:26:47 +03:00
be5f9ab77f Merge pull request 'tracer: add Flush method' (#225) from traceimp into v3
Reviewed-on: #225
2023-07-04 00:26:33 +03:00
144dca0cae tracer: add Flush method
Some checks failed
pr / test (pull_request) Failing after 2m42s
lint / lint (pull_request) Failing after 1m29s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-07-04 00:25:41 +03:00
75173560e3 Merge pull request 'util/time: ParseDuration fix' (#222) from timefix into v3
Reviewed-on: #222
2023-05-29 14:04:41 +03:00
9b3bccd1f1 util/time: ParseDuration fix
All checks were successful
lint / lint (pull_request) Successful in 1m0s
pr / test (pull_request) Successful in 58s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-05-29 14:02:06 +03:00
ce125b77c1 Merge pull request 'util/time: fix duration parsing' (#219) from timefeature into v3
Reviewed-on: #219
2023-05-27 23:55:51 +03:00
2ee8d4ed46 util/time: fix duration parsing
Some checks failed
lint / lint (pull_request) Successful in 59s
pr / test (pull_request) Failing after 1m0s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-05-27 23:55:08 +03:00
f58781d076 Merge pull request 'server/noop: fix graceful unsubscribe' (#218) from unsubfix into v3
Reviewed-on: #218
2023-05-25 23:19:26 +03:00
e1af4aa3a4 server/noop: fix graceful unsubscribe
All checks were successful
pr / test (pull_request) Successful in 1m2s
lint / lint (pull_request) Successful in 59s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-05-25 23:18:47 +03:00
1d5e795443 Merge pull request 'move RawMessage to codec package' (#208) from rawmsg into v3
Reviewed-on: #208
2023-04-02 14:15:02 +03:00
a3a434d923 move RawMessage to codec package
All checks were successful
lint
test
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-04-02 14:10:57 +03:00
bcc06054f1 Merge pull request 'updates' (#207) from updates into v3
Reviewed-on: #207
2023-03-24 00:29:33 +03:00
270d26f1ae test
All checks were successful
lint
test
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-03-24 00:25:47 +03:00
646212cc08 retest
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-03-19 17:09:40 +03:00
00c2c749db retest
Some checks failed
lint
test
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-03-19 16:46:41 +03:00
2dbada0e94 retest
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-03-19 16:43:33 +03:00
7b8f4410fb retest
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-03-19 16:36:38 +03:00
45ebef5544 retest
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-03-19 16:31:42 +03:00
cf4cac0733 retest
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-03-19 16:29:58 +03:00
50d60b5825 retest
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-03-19 16:24:47 +03:00
46ef491764 retest
Some checks failed
lint
test
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-03-19 16:17:44 +03:00
a51b8b8102 retest
Some checks failed
lint
test
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-03-19 16:11:52 +03:00
15aac48f1e retest
Some checks failed
lint
test
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-03-19 16:08:51 +03:00
078069b2d7 retest
Some checks failed
lint
test
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-03-19 16:01:27 +03:00
258812304a retest
Some checks failed
autoapprove
automerge
test
lint
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-03-19 15:12:32 +03:00
da5d50db5b retest
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-03-19 14:48:27 +03:00
384e4d113d retest
All checks were successful
test
lint
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-03-19 14:43:23 +03:00
dfd1da7f0d retest
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-03-19 14:26:03 +03:00
8e5015e580 retest
Some checks failed
lint
test
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-03-19 13:41:59 +03:00
bd0c309b71 retest
Some checks failed
lint
test
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-03-19 13:38:39 +03:00
b4f0c3e29a retest
Some checks failed
lint
test
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-03-19 13:29:21 +03:00
8fddaa0455 retest
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-03-19 13:26:42 +03:00
2710c269a8 actions
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-03-19 13:21:59 +03:00
70ea93e466 actions
Some checks failed
automerge
lint
test
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-03-19 13:12:10 +03:00
a87d0ab1c1 update deps
Some checks failed
autoapprove
automerge
lint
test
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-03-19 00:43:15 +03:00
2e5e102719 Merge pull request 'config: another fix for Default funcs' (#193) from defaults-fix into v3
Reviewed-on: #193
2023-03-16 07:14:41 +03:00
36e492314d config: another fix for Default funcs
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-03-16 07:14:21 +03:00
0c78873277 Merge pull request 'config: fix Default funcs' (#192) from config-fix into v3
Reviewed-on: #192
2023-03-15 22:53:21 +03:00
7f57dc09d3 config: fix Default funcs
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-03-15 22:51:40 +03:00
447206d256 Merge pull request 'config: proper handle AllowFail option' (#191) from config-fix into v3
Reviewed-on: #191
2023-03-14 13:24:37 +03:00
33a7feb970 config: proper handle AllowFail option
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-03-14 13:23:41 +03:00
3950f2ed86 Merge pull request 'config: add Before/After Init funcs' (#190) from config-improve into v3
Reviewed-on: #190
2023-03-14 10:40:12 +03:00
68c1048a7d config: add Before/After Init funcs
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-03-14 10:38:24 +03:00
bff40bd317 Merge pull request #189 from unistack-org/meter-handler
meter/handler: move to go.unistack.org/micro-meter-handler/v3
2023-02-26 13:48:09 +03:00
2878d0a4ea server/health: move to go.unistack.org/micro-server-health/v3
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-02-26 13:46:10 +03:00
3138a9fded meter/handler: move to go.unistack.org/micro-meter-handler/v3
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-02-26 13:42:04 +03:00
742b99636a fix and regen
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-02-22 00:09:52 +03:00
34387f129d Merge pull request #188 from unistack-org/proto
fix service names in proto
2023-02-21 13:28:13 +03:00
47075acb06 fix service names in proto
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-02-21 13:26:01 +03:00
09cb998ba4 fix service names in proto
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-02-21 13:18:03 +03:00
b9dbfb1cfc Merge pull request #187 from unistack-org/api-REMOVE
api: remove and regen
2023-02-21 02:12:47 +03:00
56efccc4cf api: remove and regen
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-02-21 02:10:24 +03:00
ce9f896287 Merge pull request #186 from unistack-org/structfs
util/structfs: import https://github.com/unistack-org/go-structfs
2023-02-19 23:38:31 +03:00
83d87a40e4 util/structfs: import https://github.com/unistack-org/go-structfs
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-02-19 23:35:39 +03:00
75fd1e43b9 Merge pull request #185 from unistack-org/server
server: add server.SetHandlerOption helper
2023-02-13 23:33:57 +03:00
395a3eed3d server: add server.SetHandlerOption helper
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-02-13 23:31:38 +03:00
3ba8cb7f9e Merge pull request #184 from unistack-org/duration
util/time: add Marshal/Unmarshal to own Duration
2023-02-13 14:05:16 +03:00
b07806b9a1 tmp
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-02-13 14:03:02 +03:00
0f583218d4 tmp
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-02-13 14:02:08 +03:00
f4d0237785 Merge pull request #183 from unistack-org/logger/unwrap
logger/unwrap: fix for nested tagged/untagged
2023-02-08 14:56:51 +03:00
0f343dad0b logger/unwrap: fix for nested tagged/untagged
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-02-08 14:54:37 +03:00
7c29afba0b Merge pull request #182 from unistack-org/timeDuration
config/default: handle time.Duration
2023-02-07 06:50:42 +03:00
8159b9d233 config/default: handle time.Duration
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-02-07 06:48:36 +03:00
45cdac5c29 config/default: handle time.Duration
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-02-07 06:48:12 +03:00
98db0dc8bc config/default: handle time.Duration
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-02-07 06:47:46 +03:00
453d2232bd Merge pull request #181 from unistack-org/unwrap
logger/unwrap: check nested in case of Tagged
2023-02-06 22:38:42 +03:00
9b387312da logger/unwrap: check nested in case of Tagged
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-02-06 22:36:24 +03:00
84024f7713 Merge pull request #180 from unistack-org/logger-wrapper
logger/unwrap: support sql and proto wrapper types
2023-02-06 18:55:39 +03:00
5a554f9f0c fixup
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-02-06 18:53:27 +03:00
9c33cbc8e2 logger/unwrap: support sql and proto wrapper types
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-02-06 18:50:00 +03:00
848fe1c0d4 Merge pull request #179 from unistack-org/logger-unwrap
logger/unwrap: fix unwrap format
2023-02-03 23:36:47 +03:00
6cbf23fec5 logger/unwrap: fix unwrap format
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-02-03 23:33:24 +03:00
7462b0b53c Merge pull request #178 from unistack-org/fsm
fsm: improve and convert to interface
2023-01-30 00:31:50 +03:00
cb743cee3f logger: remove wrappers support and OmitLogger
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-01-30 00:29:49 +03:00
d18952951c fsm: improve and convert to interface
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-01-30 00:17:29 +03:00
dependabot[bot]
f6b7f1b4bc chore(deps): bump dependabot/fetch-metadata from 1.3.5 to 1.3.6 (#172)
Bumps [dependabot/fetch-metadata](https://github.com/dependabot/fetch-metadata) from 1.3.5 to 1.3.6.
- [Release notes](https://github.com/dependabot/fetch-metadata/releases)
- [Commits](https://github.com/dependabot/fetch-metadata/compare/v1.3.5...v1.3.6)

---
updated-dependencies:
- dependency-name: dependabot/fetch-metadata
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-24 10:07:13 +03:00
dependabot[bot]
33fa702104 chore(deps): bump golangci/golangci-lint-action from 3.3.1 to 3.4.0 (#173)
Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 3.3.1 to 3.4.0.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](https://github.com/golangci/golangci-lint-action/compare/v3.3.1...v3.4.0)

---
updated-dependencies:
- dependency-name: golangci/golangci-lint-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-24 09:54:07 +03:00
4debc392d1 Merge pull request #171 from unistack-org/fixspan
add span status method
2023-01-18 09:51:39 +03:00
7137d99102 add span status method
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-01-18 09:48:58 +03:00
f76b3171d9 Merge pull request #170 from unistack-org/tracer
tracer: add span kind
2023-01-18 00:28:02 +03:00
db3fc42204 tracer: add span kind
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-01-18 00:25:15 +03:00
f59023d741 tracer: add span kind
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-01-18 00:21:18 +03:00
6f17fd891a Merge pull request #169 from unistack-org/tracer
tracer/wrapper: fix observers
2023-01-17 23:39:49 +03:00
fd93308e8e tracer/wrapper: fix observers
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-01-17 23:37:25 +03:00
2aaa0a74d8 tracer/wrapper: fix observers
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-01-17 23:31:27 +03:00
ccbf23688b Merge pull request #168 from unistack-org/tracer
tracer: add context to Options
2023-01-17 08:33:35 +03:00
3bd6db79cb tracer: add context to Options
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-01-17 08:30:57 +03:00
9347bb0651 use no default content-type (#165)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-01-07 23:38:53 +03:00
0d63723ed3 Merge pull request #164 from unistack-org/logger-clone-fix
logger: fix Clone
2023-01-06 22:44:26 +03:00
a7f84e0baa logger: fix Clone
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-01-06 22:41:57 +03:00
c209892ce8 Merge pull request #163 from unistack-org/logger_unwrap
logger/unwrap: fix Tagged option
2022-12-29 23:19:57 +03:00
421842315f logger/unwrap: fix Tagged option
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-12-29 23:16:58 +03:00
25350a6531 Merge pull request #162 from unistack-org/util_http_method_not_allowed
util/http: trie support method not allowed
2022-12-27 23:49:36 +03:00
5e47cc7e8c util/http: trie support method not allowed
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-12-27 23:47:11 +03:00
1687b98b11 Merge pull request #161 from unistack-org/tracer
tracer: add labels method
2022-12-24 19:22:48 +03:00
a81649d2a2 tracer: add labels method
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-12-24 19:20:22 +03:00
b48faa3b2b Merge pull request #160 from unistack-org/tracer
tracer: fix span options
2022-12-24 18:20:59 +03:00
0be584ef0d fix wrapper
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-12-24 18:18:42 +03:00
26a2d18766 tracer: fix span options
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-12-24 18:09:48 +03:00
25a796fe4f Merge pull request #158 from unistack-org/meter
meter/wrapper: fix naming
2022-11-28 14:39:45 +03:00
d23de14769 meter/wrapper: fix naming
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-11-28 14:36:54 +03:00
2fb108519c Merge pull request #157 from unistack-org/fixups
fix wrappers
2022-11-27 00:45:44 +03:00
c7ce238da3 fix wrappers
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-11-27 00:43:30 +03:00
dependabot[bot]
67aa79f18a chore(deps): bump hmarr/auto-approve-action from 2 to 3 (#155)
Bumps [hmarr/auto-approve-action](https://github.com/hmarr/auto-approve-action) from 2 to 3.
- [Release notes](https://github.com/hmarr/auto-approve-action/releases)
- [Commits](https://github.com/hmarr/auto-approve-action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: hmarr/auto-approve-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-19 21:45:49 +03:00
e6c3d734a3 Merge pull request #156 from unistack-org/take_unwrap
logger/unwrap: add tagged option
2022-11-19 15:23:22 +03:00
1374e27531 logger/unwrap: add tagged option
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-11-19 15:20:42 +03:00
1060f6a4c3 Merge pull request #154 from unistack-org/client_metadata
client: fix WithResponseMetadata CallOption
2022-11-14 16:13:22 +03:00
7d72ab05c6 client: fix WithResponseMetadata CallOption
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-11-14 16:10:54 +03:00
42864ff1c6 Merge pull request #153 from unistack-org/client_metadata
client: add req/rsp metadata to CallOptions
2022-11-14 15:31:58 +03:00
49978b75c0 client: add req/rsp metadata to CallOptions
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-11-14 15:29:45 +03:00
dependabot[bot]
20770b6e30 chore(deps): bump golangci/golangci-lint-action from 3.3.0 to 3.3.1 (#151)
Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 3.3.0 to 3.3.1.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](https://github.com/golangci/golangci-lint-action/compare/v3.3.0...v3.3.1)

---
updated-dependencies:
- dependency-name: golangci/golangci-lint-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-14 13:43:44 +03:00
b38c6106b2 Merge pull request #152 from unistack-org/dependabot/go_modules/go.unistack.org/micro-proto/v3-3.3.1
chore(deps): bump go.unistack.org/micro-proto/v3 from 3.2.7 to 3.3.1
2022-11-14 09:05:23 +03:00
dependabot[bot]
138c4a0888 chore(deps): bump go.unistack.org/micro-proto/v3 from 3.2.7 to 3.3.1
Bumps [go.unistack.org/micro-proto/v3](https://github.com/unistack-org/micro-proto) from 3.2.7 to 3.3.1.
- [Release notes](https://github.com/unistack-org/micro-proto/releases)
- [Commits](https://github.com/unistack-org/micro-proto/compare/v3.2.7...v3.3.1)

---
updated-dependencies:
- dependency-name: go.unistack.org/micro-proto/v3
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-14 06:03:28 +00:00
dependabot[bot]
22f66fc258 chore(deps): bump dependabot/fetch-metadata from 1.3.4 to 1.3.5 (#148)
Bumps [dependabot/fetch-metadata](https://github.com/dependabot/fetch-metadata) from 1.3.4 to 1.3.5.
- [Release notes](https://github.com/dependabot/fetch-metadata/releases)
- [Commits](https://github.com/dependabot/fetch-metadata/compare/v1.3.4...v1.3.5)

---
updated-dependencies:
- dependency-name: dependabot/fetch-metadata
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-12 18:22:11 +03:00
18fafbbbab Merge pull request #150 from unistack-org/unwrap
logger/unwrap: intergate omit functionality
2022-11-07 16:00:45 +03:00
59c08c1d9a logger/unwrap: intergate omit functionality
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-11-07 15:56:09 +03:00
5fbb1a923e Merge pull request #149 from unistack-org/improvements
minor improvements
2022-11-07 14:56:24 +03:00
396387d1e8 minor improvements
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-11-07 14:53:58 +03:00
dependabot[bot]
4c2f12a419 chore(deps): bump golangci/golangci-lint-action from 3.2.0 to 3.3.0 (#144)
Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 3.2.0 to 3.3.0.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](https://github.com/golangci/golangci-lint-action/compare/v3.2.0...v3.3.0)

---
updated-dependencies:
- dependency-name: golangci/golangci-lint-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-26 19:34:23 +03:00
b2abb86971 Merge pull request #147 from unistack-org/client_context_dialer
client: add ContextDialer/WithContextDialer option
2022-10-26 19:23:01 +03:00
e546eef96c client: add ContextDialer/WithContextDialer option
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-10-26 19:20:37 +03:00
91701e7a45 Merge pull request #146 from unistack-org/codec_noop_fix
codec: fix noop
2022-10-26 13:39:52 +03:00
817bf1f4d0 codec: fix noop
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-10-26 13:37:30 +03:00
4120f79b55 Merge pull request #145 from unistack-org/codec_fix
codec: add []byte support to noop codec
2022-10-26 08:28:36 +03:00
d659db69ff codec: add []byte support to noop codec
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-10-26 08:26:10 +03:00
416bb313fc Merge pull request #143 from unistack-org/logger_unwrap
WIP: logger/unwrap: add unwrap method
2022-10-11 00:33:25 +03:00
ec43cfea6b logger/unwrap: add unwrap method
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-10-11 00:30:42 +03:00
dependabot[bot]
60194fb42e chore(deps): bump codecov/codecov-action from 3.1.0 to 3.1.1 (#141)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 3.1.0 to 3.1.1.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/master/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v3.1.0...v3.1.1)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-06 17:34:40 +03:00
dependabot[bot]
945d9d16a5 chore(deps): bump dependabot/fetch-metadata from 1.3.3 to 1.3.4 (#142)
Bumps [dependabot/fetch-metadata](https://github.com/dependabot/fetch-metadata) from 1.3.3 to 1.3.4.
- [Release notes](https://github.com/dependabot/fetch-metadata/releases)
- [Commits](https://github.com/dependabot/fetch-metadata/compare/v1.3.3...v1.3.4)

---
updated-dependencies:
- dependency-name: dependabot/fetch-metadata
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-06 17:34:25 +03:00
1c0e5e1a85 Merge pull request #139 from unistack-org/store
store: add Timeout option
2022-07-08 22:41:47 +03:00
33591e0bc9 fixup
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-07-08 22:39:51 +03:00
dependabot[bot]
75cbaf2612 chore(deps): bump dependabot/fetch-metadata from 1.3.1 to 1.3.3 (#137)
Bumps [dependabot/fetch-metadata](https://github.com/dependabot/fetch-metadata) from 1.3.1 to 1.3.3.
- [Release notes](https://github.com/dependabot/fetch-metadata/releases)
- [Commits](https://github.com/dependabot/fetch-metadata/compare/v1.3.1...v1.3.3)

---
updated-dependencies:
- dependency-name: dependabot/fetch-metadata
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-08 22:33:05 +03:00
f4aee3414b store: add Timeout option
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-07-08 22:16:33 +03:00
9f7b61eb17 add test
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-06-29 23:04:01 +03:00
5953b5aae6 Merge pull request #133 from unistack-org/mtls
WIP: initial mtls package
2022-06-27 00:22:10 +03:00
4a8f490e0c fixup
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-06-27 00:20:04 +03:00
eb8c1332f0 fix test
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-06-27 00:18:14 +03:00
c1c27b6d1d Merge branch 'v3' into mtls 2022-06-27 00:17:56 +03:00
dependabot[bot]
bb22b203cc chore(deps): bump github.com/imdario/mergo from 0.3.12 to 0.3.13 (#134)
Bumps [github.com/imdario/mergo](https://github.com/imdario/mergo) from 0.3.12 to 0.3.13.
- [Release notes](https://github.com/imdario/mergo/releases)
- [Commits](https://github.com/imdario/mergo/compare/0.3.12...v0.3.13)

---
updated-dependencies:
- dependency-name: github.com/imdario/mergo
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-25 23:28:02 +03:00
dependabot[bot]
4df2f3a5a1 chore(deps): bump github.com/golang-jwt/jwt/v4 from 4.4.1 to 4.4.2 (#135)
Bumps [github.com/golang-jwt/jwt/v4](https://github.com/golang-jwt/jwt) from 4.4.1 to 4.4.2.
- [Release notes](https://github.com/golang-jwt/jwt/releases)
- [Changelog](https://github.com/golang-jwt/jwt/blob/main/VERSION_HISTORY.md)
- [Commits](https://github.com/golang-jwt/jwt/compare/v4.4.1...v4.4.2)

---
updated-dependencies:
- dependency-name: github.com/golang-jwt/jwt/v4
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-25 22:39:53 +03:00
b8ad19a5a2 WIP: initial mtls package
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-05-12 15:11:31 +03:00
dependabot[bot]
d32a97c846 chore(deps): bump golangci/golangci-lint-action from 3.1.0 to 3.2.0 (#132)
Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 3.1.0 to 3.2.0.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](https://github.com/golangci/golangci-lint-action/compare/v3.1.0...v3.2.0)

---
updated-dependencies:
- dependency-name: golangci/golangci-lint-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-11 11:28:38 +03:00
cfe0473ae0 Merge pull request #130 from unistack-org/improvements
Improvements
2022-05-03 16:08:50 +03:00
c26ad51e25 config: improve coverage
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-05-03 16:05:56 +03:00
aefc398b71 flow: improve coverage
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-05-03 16:05:51 +03:00
9af23e3e74 metadata: improve coverage
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-05-03 16:05:42 +03:00
4ab7f19ef0 logger: improve coverage
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-05-03 16:05:36 +03:00
d26e9d642b meter: improve coverage
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-05-03 16:05:28 +03:00
f9ecb9b056 register: improve coverage
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-05-03 16:05:18 +03:00
dbfcfcd288 router: improve coverage
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-05-03 16:05:12 +03:00
8b6bdb857b store: improve coverage
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-05-03 16:05:03 +03:00
1181e9dc5e tracer: improve coverage
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-05-03 16:04:57 +03:00
6ac7b53d75 server: improve coverage
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-05-03 16:04:48 +03:00
80d342a72a client: improve coverage
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-05-03 15:59:38 +03:00
8ff312e71d broker: improve coverage
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-05-03 15:51:08 +03:00
20e40ccdfd api: improve coverage
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-05-03 15:41:30 +03:00
d4efbb9b22 metadata: allow to Set/Del multiple items
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-05-03 15:19:10 +03:00
b433cbcbb6 Merge pull request #129 from unistack-org/api_cleanup
api: cleanup
2022-05-03 14:48:23 +03:00
dae3c1170b api: cleanup
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-05-03 14:46:03 +03:00
a10dd3d08a Merge pull request #128 from unistack-org/big_remove
global cleanup
2022-05-03 14:40:55 +03:00
b075230ae5 global cleanup
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-05-03 14:38:44 +03:00
289aadb28e Merge pull request #127 from unistack-org/cover
add more cover stuff
2022-05-03 00:26:13 +03:00
9640cdae1a add more cover stuff
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-05-03 00:23:43 +03:00
dependabot[bot]
fb35e73731 chore(deps): bump github/codeql-action from 1 to 2 (#126)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 1 to 2.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/v1...v2)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-26 23:42:38 +03:00
f416cb3e0e Merge pull request #125 from unistack-org/cover
add tests
2022-04-24 11:11:32 +03:00
57d06d5d27 add tests
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-04-24 11:08:38 +03:00
0628408c27 Merge pull request #124 from unistack-org/cover
util/reflect: improve test coverage
2022-04-22 09:27:03 +03:00
206cd8c3c9 util/reflect: improve test coverage
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-04-22 09:24:34 +03:00
dependabot[bot]
b38db00ee5 chore(deps): bump codecov/codecov-action from 3.0.0 to 3.1.0 (#123)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 3.0.0 to 3.1.0.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/master/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v3.0.0...v3.1.0)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-22 06:14:04 +00:00
dependabot[bot]
0ca39a1477 chore(deps): bump dependabot/fetch-metadata from 1.3.0 to 1.3.1 (#122)
Bumps [dependabot/fetch-metadata](https://github.com/dependabot/fetch-metadata) from 1.3.0 to 1.3.1.
- [Release notes](https://github.com/dependabot/fetch-metadata/releases)
- [Commits](https://github.com/dependabot/fetch-metadata/compare/v1.3.0...v1.3.1)

---
updated-dependencies:
- dependency-name: dependabot/fetch-metadata
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-21 12:47:39 +03:00
d9be99cfde Merge pull request #121 from unistack-org/fsm
fsm: add state execution options
2022-04-19 18:45:14 +03:00
b37c6006c4 fsm: add state execution options
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-04-19 18:42:30 +03:00
12f188e3ad Merge pull request #120 from unistack-org/fsm
fsm: run steps in order
2022-04-19 17:36:05 +03:00
08aaf14a79 fsm: run steps in order
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-04-19 17:33:33 +03:00
2ce1e94596 Merge pull request #119 from unistack-org/errors
errors: add CodeIn helper func
2022-04-19 17:15:03 +03:00
c5aeaf6db7 errors: add CodeIn helper func
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-04-19 17:12:25 +03:00
1db505decd Merge pull request #118 from unistack-org/cover
improve coverage
2022-04-17 16:28:59 +03:00
8b1a579c9d add context tests
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-04-17 16:25:42 +03:00
11b614f2df client: add retry func tests
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-04-17 13:11:36 +03:00
fb4d747197 server: fix race
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-04-17 11:41:49 +03:00
00439e23f3 add client call options tests
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-04-16 16:36:43 +03:00
955953b519 client: fix lint
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-04-16 16:36:34 +03:00
aa2b5ddaad client: add backoff tests
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-04-16 16:36:15 +03:00
46da092899 client: implement Call and Stream methods for noop
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-04-16 16:35:52 +03:00
b871f64ba6 Merge pull request #117 from unistack-org/race
server: fix race in noop server
2022-04-15 15:53:18 +03:00
74db004f51 server: fix race in noop server
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-04-15 15:50:45 +03:00
f93ba9d977 Merge pull request #116 from unistack-org/fsm
fsm: initial import
2022-04-15 15:22:55 +03:00
c7da7d5bc8 fsm: initial import
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-04-15 15:20:17 +03:00
ed27647be5 Merge pull request #115 from unistack-org/dependabot/github_actions/actions/setup-go-3
chore(deps): bump actions/setup-go from 2 to 3
2022-04-11 23:01:22 +03:00
dependabot[bot]
db3b67267e chore(deps): bump actions/setup-go from 2 to 3
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 2 to 3.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-11 06:17:56 +00:00
9ee9cc2a4a Merge pull request #114 from unistack-org/cover
fix coverage
2022-04-07 19:18:34 +03:00
0b41b4f9c5 fix 2022-04-07 19:15:55 +03:00
8d14753931 Merge branch 'v3' into cover 2022-04-07 19:13:56 +03:00
93fc17bad3 fix coverage
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-04-07 19:12:49 +03:00
5a1cd12d3d Merge pull request #113 from unistack-org/vtolstov-patch-1
Update README.md
2022-04-07 19:11:22 +03:00
5c00e6763f Update README.md
fix link to godoc
2022-04-07 19:08:45 +03:00
497b82ac6c Merge pull request #112 from unistack-org/codecov
add codecov
2022-04-07 19:07:17 +03:00
a8c6690af7 add codecov
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-04-07 19:04:04 +03:00
98d2264c2a add codecov
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-04-07 19:00:08 +03:00
63641b9840 add codecov
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-04-07 18:57:30 +03:00
2b28057918 add codecov
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-04-07 18:56:10 +03:00
25c551411b Merge pull request #111 from unistack-org/config
service: fix ordering
2022-03-30 15:51:27 +03:00
35162a82a4 service: fix ordering
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-03-30 15:48:43 +03:00
0ce0855b6a Merge pull request #109 from unistack-org/dependabot/go_modules/github.com/golang-jwt/jwt/v4-4.4.1
chore(deps): bump github.com/golang-jwt/jwt/v4 from 4.4.0 to 4.4.1
2022-03-30 15:42:23 +03:00
226ec43ecf Merge pull request #110 from unistack-org/config
service: config load only on start, not init phase
2022-03-30 15:39:51 +03:00
575af66ddc service: config load only on start, not init phase
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-03-30 15:37:02 +03:00
dependabot[bot]
afb9e8c240 chore(deps): bump github.com/golang-jwt/jwt/v4 from 4.4.0 to 4.4.1
Bumps [github.com/golang-jwt/jwt/v4](https://github.com/golang-jwt/jwt) from 4.4.0 to 4.4.1.
- [Release notes](https://github.com/golang-jwt/jwt/releases)
- [Changelog](https://github.com/golang-jwt/jwt/blob/main/VERSION_HISTORY.md)
- [Commits](https://github.com/golang-jwt/jwt/compare/v4.4.0...v4.4.1)

---
updated-dependencies:
- dependency-name: github.com/golang-jwt/jwt/v4
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-28 06:11:57 +00:00
c10f29ee74 Merge pull request #108 from unistack-org/improve
small improve
2022-03-27 01:39:33 +03:00
03410c4ab1 small improve
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-03-27 01:37:21 +03:00
3805d0f067 Merge pull request #107 from unistack-org/retries
client: determenistic retry backoff
2022-03-27 00:19:06 +03:00
680ac11ef9 client: determenistic retry backoff
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-03-27 00:16:22 +03:00
35ab6ae84e Merge pull request #106 from unistack-org/jitter
jitter: add NewTickerContext
2022-03-26 18:01:31 +03:00
c6c2b0884e jitter: add NewTickerContext
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-03-26 17:59:19 +03:00
297a80da84 Merge pull request #105 from unistack-org/improve
small fixes
2022-03-25 14:27:29 +03:00
2d292db7bd small fixes
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-03-25 14:24:20 +03:00
54c4287fab Update README.md 2022-03-22 15:00:01 +03:00
9c074e5741 Merge pull request #103 from unistack-org/dependabot/github_actions/actions/cache-3
chore(deps): bump actions/cache from 2 to 3
2022-03-22 14:57:20 +03:00
290975eaf5 Merge pull request #104 from unistack-org/small_changes
config: add Validate func, small lint fixes
2022-03-22 14:57:03 +03:00
c64218d52c config: add Validate func, small lint fixes
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-03-22 14:54:43 +03:00
dependabot[bot]
46c266a4a9 chore(deps): bump actions/cache from 2 to 3
Bumps [actions/cache](https://github.com/actions/cache) from 2 to 3.
- [Release notes](https://github.com/actions/cache/releases)
- [Commits](https://github.com/actions/cache/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-22 06:14:47 +00:00
5527b16cd8 Merge pull request #102 from unistack-org/cleanup
server: remove unparsed body from request and message
2022-03-21 15:26:20 +03:00
4904cad8ef server: remove unparsed body from request and message
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-03-21 15:23:41 +03:00
74633f4290 Merge pull request #101 from unistack-org/dependabot/go_modules/github.com/golang-jwt/jwt/v4-4.4.0
chore(deps): bump github.com/golang-jwt/jwt/v4 from 4.3.0 to 4.4.0
2022-03-18 16:29:26 +03:00
dependabot[bot]
c8ad4d772b chore(deps): bump github.com/golang-jwt/jwt/v4 from 4.3.0 to 4.4.0
Bumps [github.com/golang-jwt/jwt/v4](https://github.com/golang-jwt/jwt) from 4.3.0 to 4.4.0.
- [Release notes](https://github.com/golang-jwt/jwt/releases)
- [Changelog](https://github.com/golang-jwt/jwt/blob/main/VERSION_HISTORY.md)
- [Commits](https://github.com/golang-jwt/jwt/compare/v4.3.0...v4.4.0)

---
updated-dependencies:
- dependency-name: github.com/golang-jwt/jwt/v4
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-17 08:24:50 +00:00
91bd0f7efe Merge branch 'master' into v3 2022-03-17 11:23:08 +03:00
00dc7e1bb5 update go version
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-03-07 13:44:18 +03:00
5a5165a003 Merge pull request #99 from unistack-org/dependabot/go_modules/github.com/golang-jwt/jwt/v4-4.3.0
chore(deps): bump github.com/golang-jwt/jwt/v4 from 4.2.0 to 4.3.0
2022-03-07 13:16:48 +03:00
382e3d554b Merge pull request #98 from unistack-org/dependabot/github_actions/golangci/golangci-lint-action-3.1.0
chore(deps): bump golangci/golangci-lint-action from 2 to 3.1.0
2022-03-07 13:16:37 +03:00
05a0c97fc6 Merge pull request #100 from unistack-org/dependabot/go_modules/go.unistack.org/micro-proto/v3-3.2.7
chore(deps): bump go.unistack.org/micro-proto/v3 from 3.2.1 to 3.2.7
2022-03-07 13:14:31 +03:00
dependabot[bot]
5e06ae1a42 chore(deps): bump go.unistack.org/micro-proto/v3 from 3.2.1 to 3.2.7
Bumps [go.unistack.org/micro-proto/v3](https://github.com/unistack-org/micro-proto) from 3.2.1 to 3.2.7.
- [Release notes](https://github.com/unistack-org/micro-proto/releases)
- [Commits](https://github.com/unistack-org/micro-proto/compare/v3.2.1...v3.2.7)

---
updated-dependencies:
- dependency-name: go.unistack.org/micro-proto/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-07 10:11:59 +00:00
dependabot[bot]
7ac4ad4efa chore(deps): bump github.com/golang-jwt/jwt/v4 from 4.2.0 to 4.3.0
Bumps [github.com/golang-jwt/jwt/v4](https://github.com/golang-jwt/jwt) from 4.2.0 to 4.3.0.
- [Release notes](https://github.com/golang-jwt/jwt/releases)
- [Changelog](https://github.com/golang-jwt/jwt/blob/main/VERSION_HISTORY.md)
- [Commits](https://github.com/golang-jwt/jwt/compare/v4.2.0...v4.3.0)

---
updated-dependencies:
- dependency-name: github.com/golang-jwt/jwt/v4
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-07 10:11:54 +00:00
dependabot[bot]
01348bd9b2 chore(deps): bump golangci/golangci-lint-action from 2 to 3.1.0
Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 2 to 3.1.0.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](https://github.com/golangci/golangci-lint-action/compare/v2...v3.1.0)

---
updated-dependencies:
- dependency-name: golangci/golangci-lint-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-07 10:11:45 +00:00
2287c65118 update workflows
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-03-05 19:07:51 +03:00
b34bc7ffff Merge pull request #97 from unistack-org/dependabot/go_modules/go.unistack.org/micro-proto/v3-3.2.7
chore(deps): bump go.unistack.org/micro-proto/v3 from 3.2.5 to 3.2.7
2022-03-02 09:42:24 +03:00
dependabot[bot]
2a0bf03d0a chore(deps): bump go.unistack.org/micro-proto/v3 from 3.2.5 to 3.2.7
Bumps [go.unistack.org/micro-proto/v3](https://github.com/unistack-org/micro-proto) from 3.2.5 to 3.2.7.
- [Release notes](https://github.com/unistack-org/micro-proto/releases)
- [Commits](https://github.com/unistack-org/micro-proto/compare/v3.2.5...v3.2.7)

---
updated-dependencies:
- dependency-name: go.unistack.org/micro-proto/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-02 06:42:04 +00:00
89114c291c Merge pull request #94 from unistack-org/dependabot/go_modules/go.unistack.org/micro-proto/v3-3.2.5
chore(deps): bump go.unistack.org/micro-proto/v3 from 3.2.3 to 3.2.5
2022-02-28 09:12:18 +03:00
dependabot[bot]
b4b4320fac chore(deps): bump go.unistack.org/micro-proto/v3 from 3.2.3 to 3.2.5
Bumps [go.unistack.org/micro-proto/v3](https://github.com/unistack-org/micro-proto) from 3.2.3 to 3.2.5.
- [Release notes](https://github.com/unistack-org/micro-proto/releases)
- [Commits](https://github.com/unistack-org/micro-proto/compare/v3.2.3...v3.2.5)

---
updated-dependencies:
- dependency-name: go.unistack.org/micro-proto/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-02-28 06:12:01 +00:00
7b0d69115c Merge pull request #90 from unistack-org/dependabot/go_modules/github.com/golang-jwt/jwt/v4-4.3.0
chore(deps): bump github.com/golang-jwt/jwt/v4 from 4.2.0 to 4.3.0
2022-02-25 10:00:00 +03:00
f054beb6e8 Merge pull request #92 from unistack-org/dependabot/github_actions/dependabot/fetch-metadata-1.2.1
chore(deps): bump dependabot/fetch-metadata from 1.1.1 to 1.2.1
2022-02-25 09:44:23 +03:00
9fb346594e Merge pull request #93 from unistack-org/dependabot/github_actions/golangci/golangci-lint-action-3
chore(deps): bump golangci/golangci-lint-action from 2 to 3
2022-02-25 09:33:47 +03:00
dependabot[bot]
cbf6fbd780 chore(deps): bump golangci/golangci-lint-action from 2 to 3
Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 2 to 3.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](https://github.com/golangci/golangci-lint-action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: golangci/golangci-lint-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-02-25 06:18:58 +00:00
dependabot[bot]
0392bff282 chore(deps): bump dependabot/fetch-metadata from 1.1.1 to 1.2.1
Bumps [dependabot/fetch-metadata](https://github.com/dependabot/fetch-metadata) from 1.1.1 to 1.2.1.
- [Release notes](https://github.com/dependabot/fetch-metadata/releases)
- [Commits](https://github.com/dependabot/fetch-metadata/compare/v1.1.1...v1.2.1)

---
updated-dependencies:
- dependency-name: dependabot/fetch-metadata
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-02-23 06:14:10 +00:00
dependabot[bot]
75b1fe5dc6 chore(deps): bump github.com/golang-jwt/jwt/v4 from 4.2.0 to 4.3.0
Bumps [github.com/golang-jwt/jwt/v4](https://github.com/golang-jwt/jwt) from 4.2.0 to 4.3.0.
- [Release notes](https://github.com/golang-jwt/jwt/releases)
- [Changelog](https://github.com/golang-jwt/jwt/blob/main/VERSION_HISTORY.md)
- [Commits](https://github.com/golang-jwt/jwt/compare/v4.2.0...v4.3.0)

---
updated-dependencies:
- dependency-name: github.com/golang-jwt/jwt/v4
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-02-10 06:31:09 +00:00
1f232ffba8 Merge pull request #89 from unistack-org/dependabot/go_modules/go.unistack.org/micro-proto/v3-3.2.3
chore(deps): bump go.unistack.org/micro-proto/v3 from 3.2.1 to 3.2.3
2022-02-02 09:15:27 +03:00
dependabot[bot]
7f43b64fc2 chore(deps): bump go.unistack.org/micro-proto/v3 from 3.2.1 to 3.2.3
Bumps [go.unistack.org/micro-proto/v3](https://github.com/unistack-org/micro-proto) from 3.2.1 to 3.2.3.
- [Release notes](https://github.com/unistack-org/micro-proto/releases)
- [Commits](https://github.com/unistack-org/micro-proto/compare/v3.2.1...v3.2.3)

---
updated-dependencies:
- dependency-name: go.unistack.org/micro-proto/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-02-02 06:15:10 +00:00
d0d04a840a Merge pull request #88 from unistack-org/master
merge master
2022-01-30 17:05:41 +03:00
1dda3f0dcc Merge pull request #87 from unistack-org/register
register: DefaultDomain as var not as const
2022-01-30 17:05:19 +03:00
1abf5e7647 register: DefaultDomain as var not as const
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-01-30 17:04:52 +03:00
f06610c9c2 Merge pull request #86 from unistack-org/master
update micro-proto
2022-01-26 00:48:11 +03:00
df8560bb6f update micro-proto
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-01-26 00:47:22 +03:00
0257eae936 Merge pull request #85 from unistack-org/master
merge master
2022-01-25 00:41:46 +03:00
58f03d05e7 Merge pull request #84 from unistack-org/errors_marshal
errors: fix MarshalJSON func
2022-01-25 00:41:10 +03:00
60340a749b errors: fix MarshalJSON func
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-01-25 00:40:50 +03:00
56b0df5b7a Merge pull request #83 from unistack-org/dependabot/go_modules/go.unistack.org/micro-proto/v3-3.2.0
chore(deps): bump go.unistack.org/micro-proto/v3 from 3.1.1 to 3.2.0
2022-01-24 09:15:46 +03:00
dependabot[bot]
bb59d5a2fd chore(deps): bump go.unistack.org/micro-proto/v3 from 3.1.1 to 3.2.0
Bumps [go.unistack.org/micro-proto/v3](https://github.com/unistack-org/micro-proto) from 3.1.1 to 3.2.0.
- [Release notes](https://github.com/unistack-org/micro-proto/releases)
- [Commits](https://github.com/unistack-org/micro-proto/compare/v3.1.1...v3.2.0)

---
updated-dependencies:
- dependency-name: go.unistack.org/micro-proto/v3
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-01-24 06:14:48 +00:00
67d5dc7e28 Merge pull request #82 from unistack-org/master
errors: fix parsing
2022-01-21 19:14:08 +03:00
797c0f822d Merge pull request #81 from unistack-org/errors
errors: fix parsing
2022-01-21 19:13:39 +03:00
8546140e22 errors: fix parsing
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-01-21 19:13:21 +03:00
92b125c1ce Merge pull request #80 from unistack-org/master
merge master
2022-01-21 18:21:47 +03:00
8f7eebc24f Merge pull request #79 from unistack-org/errors
errors: fix FromError and errors.Unmarshal
2022-01-21 18:21:13 +03:00
b0def96d14 errors: fix FromError and errors.Unmarshal
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-01-21 18:20:56 +03:00
927ca879b2 Merge pull request #78 from unistack-org/master
merge master
2022-01-21 00:51:14 +03:00
00450c9cc7 Merge pull request #77 from unistack-org/errors
errors: add proto
2022-01-21 00:50:32 +03:00
534bce2d20 errors: add proto
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-01-21 00:50:16 +03:00
53949be0cc Merge pull request #76 from unistack-org/logger_test
add logger context test
2022-01-20 15:29:44 +03:00
d8fe2ff8b4 add logger context test
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-01-20 15:29:21 +03:00
53b5ee2c6f Merge pull request #75 from unistack-org/logger_test
logger: add logger Fields test
2022-01-20 00:31:23 +03:00
dfd85cd871 logger: add logger Fields test
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-01-20 00:28:09 +03:00
52182261af Merge pull request #74 from unistack-org/master
logger: fix Fields
2022-01-19 19:55:21 +03:00
1f3834e187 Merge pull request #73 from unistack-org/logger
logger: fix fields
2022-01-19 19:54:50 +03:00
0354873c3a logger: fix fields
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-01-19 19:54:33 +03:00
8e5e2167cd Merge pull request #72 from unistack-org/master
lint fixes
2022-01-10 16:48:27 +03:00
c26a7db47c Merge pull request #71 from unistack-org/lint
many lint fixes
2022-01-10 16:47:56 +03:00
74765b4c5f many lint fixes
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-01-10 16:47:37 +03:00
8bd7323af1 Merge pull request #70 from unistack-org/dependabot/go_modules/go.unistack.org/micro-proto/v3-3.1.1
chore(deps): bump go.unistack.org/micro-proto/v3 from 3.1.0 to 3.1.1
2021-12-31 09:11:36 +03:00
dependabot[bot]
899dc8b3bc chore(deps): bump go.unistack.org/micro-proto/v3 from 3.1.0 to 3.1.1
Bumps [go.unistack.org/micro-proto/v3](https://github.com/unistack-org/micro-proto) from 3.1.0 to 3.1.1.
- [Release notes](https://github.com/unistack-org/micro-proto/releases)
- [Commits](https://github.com/unistack-org/micro-proto/compare/v3.1.0...v3.1.1)

---
updated-dependencies:
- dependency-name: go.unistack.org/micro-proto/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-12-31 06:11:19 +00:00
6e6c31b5dd Merge pull request #69 from unistack-org/master
merge master
2021-12-28 09:30:34 +03:00
94929878fe Merge pull request #68 from unistack-org/improvements
improvements
2021-12-28 09:23:45 +03:00
8ce469a09e tracer: fixes
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-12-28 09:18:52 +03:00
88788776d2 Merge branch 'master' into v3 2021-12-16 15:04:08 +03:00
e143e2b547 client: allow to set metadata for message
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-12-16 15:03:42 +03:00
a36f99e30b Merge pull request #66 from unistack-org/minor_changes
config: add new error type
2021-11-30 07:35:27 +03:00
326ee53333 config: add new error type
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-11-30 07:34:49 +03:00
1244c5bb4d Merge pull request #65 from unistack-org/master
merge changes from master
2021-11-24 00:59:00 +03:00
4ccc8a9c85 Merge pull request #64 from unistack-org/minor_changes
minor changes
2021-11-24 00:58:21 +03:00
8a2e84d489 minor changes
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-11-24 00:57:59 +03:00
d29363b78d codec: add NewFrame helper
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-11-19 09:22:13 +03:00
734f751055 Merge pull request #63 from unistack-org/master
util/http: add type alias
2021-11-19 03:04:55 +03:00
55d8a9ee20 util/http: add type alias
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-11-19 03:04:08 +03:00
07c93042ba Merge pull request #62 from unistack-org/master
merge stable
2021-11-18 16:01:10 +03:00
b9bbfdf159 config: add watch option helper
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-11-18 15:57:14 +03:00
fbad257acc config: add helpers to load/save options (#60) 2021-11-18 15:46:30 +03:00
1829febb6e util/http: fix lint issues
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-11-09 17:07:52 +03:00
7838fa62a8 util/trie: import some code from chi router
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-11-09 16:34:05 +03:00
332803d8de update workflows
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-27 22:52:48 +03:00
11c868d476 Merge branch 'v3' 2021-10-27 22:51:58 +03:00
38d6e482d7 util/reflect: fix StructFields
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-27 22:51:35 +03:00
07d4085201 util/reflect: fix reflect methods
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-27 12:55:48 +03:00
45f30c0be3 util/reflect: ZeroFieldByPath and SetFieldByPath
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-26 14:12:37 +03:00
bcaea675a7 util/reflect: add method to zero struct field
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-25 14:41:19 +03:00
3087ba1d73 regen
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-23 23:45:53 +03:00
3f5b19497c meter: add Clone method
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-09 23:50:57 +03:00
37d937d7ae meter: add missing options
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-09 19:16:45 +03:00
7d68f2396e tracer: dont return noop from context
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-07 22:46:47 +03:00
0854a7ea72 micro: add simple test
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-07 20:59:27 +03:00
5eb0e56373 move all imports to own domain
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-02 19:55:07 +03:00
6af837fd25 fixup workflows
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-02 18:42:20 +03:00
ada59119cc util/http: add test case
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-02 18:34:22 +03:00
8abc913b28 codec: add MarshalAppend func
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-01 01:08:24 +03:00
3247d144a8 lint fixes
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-09-30 21:13:13 +03:00
7b2e3cc8aa lint fixes
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-09-30 21:00:02 +03:00
8688179acd lint fixes
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-09-30 20:32:59 +03:00
3e40bac5f4 config: add helper funcs
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-09-30 01:24:16 +03:00
e3fee6f8a6 util/http: add trie case insesitive matching
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-09-29 13:41:47 +03:00
15c020fac5 fix lint
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-09-29 13:19:07 +03:00
3bc046e5d4 broker/memory: simplify code
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-09-29 13:10:11 +03:00
542f36cfa5 util/reflect: fix tests, lint fixes
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-09-29 13:09:48 +03:00
8237e6a08e util/router: drop google copy of pattern matcher in favour of util/http trie
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-09-29 13:09:22 +03:00
ecb60e4dc5 fix lint
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-09-28 23:43:43 +03:00
a1999ff81c util/http: trie add more tests
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-09-28 01:02:28 +03:00
d0f2bc8346 util/http: add trie matching func
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-09-27 23:30:53 +03:00
dependabot[bot]
dd29bf457e chore(deps): bump actions/github-script from 4 to 5 (#58)
Bumps [actions/github-script](https://github.com/actions/github-script) from 4 to 5.
- [Release notes](https://github.com/actions/github-script/releases)
- [Commits](https://github.com/actions/github-script/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/github-script
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-09-27 09:33:25 +03:00
d062c248e3 codec: fieldaligment
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-09-22 17:09:26 +03:00
875f66d36e codec: implement proto v1 message for Frame
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-09-22 16:59:52 +03:00
818a0e6356 codec: add context helper funcs
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-09-22 01:07:27 +03:00
56e02ec463 codec: add ability to pass codec options
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-09-22 00:57:10 +03:00
6ca851401d update workflow
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-09-21 21:46:23 +03:00
bd8216b397 update workflows
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-09-17 07:47:23 +03:00
2b13b3f128 Revert "update workflows"
This reverts commit 9957380b6d.
2021-09-17 07:42:46 +03:00
9957380b6d update workflows
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-09-17 07:41:17 +03:00
e10f8c0fa0 util/id: move tests to micro-tests repo
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-09-16 15:31:01 +03:00
45252fe4a6 enable automerge
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-09-16 10:30:59 +03:00
faad082efe util/rand: add Shuffle func
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-09-15 17:51:25 +03:00
8ab35cbd9b update dependabot
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-09-12 16:17:28 +03:00
ad58ab6943 fix codeql issue
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-09-06 10:51:13 +03:00
0e97049e1d Create SECURITY.md 2021-09-06 10:49:18 +03:00
edb0bbf9cf add codeql
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-09-06 10:30:21 +03:00
dependabot[bot]
1b01bd22a6 build(deps): bump github.com/unistack-org/micro-proto (#57) 2021-09-06 06:56:44 +00:00
2fbaa26f0f logger: add Clone method
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-08-30 16:21:01 +03:00
35d3e4b332 logger: breaking changes to log level parsing
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-08-30 16:21:01 +03:00
dependabot[bot]
e98a93d530 build(deps): bump github.com/unistack-org/micro-proto (#56)
Bumps [github.com/unistack-org/micro-proto](https://github.com/unistack-org/micro-proto) from 0.0.5 to 0.0.8.
- [Release notes](https://github.com/unistack-org/micro-proto/releases)
- [Commits](https://github.com/unistack-org/micro-proto/compare/v0.0.5...v0.0.8)

---
updated-dependencies:
- dependency-name: github.com/unistack-org/micro-proto
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-08-30 16:20:10 +03:00
e3545532e8 minor changes
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-08-21 01:00:10 +03:00
09653c2fb2 util/id: specify default size for uuid behaviour
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-08-20 22:48:03 +03:00
70adfeab0d fix flow
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-08-20 22:44:17 +03:00
a45b672c98 drop uuid and use modified nanoid
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-08-20 22:40:48 +03:00
4509323cae update and regen all
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-08-16 23:56:50 +03:00
b3f4c670d5 regen all
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-08-16 18:57:19 +03:00
778dd449e2 logger: add NewStdLogger and RedirectStdLogger
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-08-06 13:45:11 +03:00
1d16983b67 logger: add NewStdLogger that can be used as std *log.Logger
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-08-06 11:52:04 +03:00
f386bffd37 logger: change logger interface
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-08-06 02:15:57 +03:00
772bde7938 network/tunnel/broker: fix metadata compile issue
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-08-06 02:14:56 +03:00
ea16f5f825 config/default: not implement watcher as it cant change
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-08-04 16:04:58 +03:00
c2f34df493 config: minor changes to split config and watcher files
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-08-04 13:51:43 +03:00
efe215cd60 config/default: watcher send changes only on non nil
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-08-04 12:25:29 +03:00
b4f332bf0d config/default: return error on Next() call
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-08-04 01:15:50 +03:00
f47fbb1030 config: add jitter interval for watcher to avoid dos
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-08-04 00:37:56 +03:00
1e8e57a708 config/default: minor changes
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-08-03 00:49:21 +03:00
dependabot[bot]
5d0959b0a1 build(deps): bump github.com/golang-jwt/jwt (#54)
Bumps [github.com/golang-jwt/jwt](https://github.com/golang-jwt/jwt) from 3.2.1+incompatible to 3.2.2+incompatible.
- [Release notes](https://github.com/golang-jwt/jwt/releases)
- [Changelog](https://github.com/golang-jwt/jwt/blob/main/VERSION_HISTORY.md)
- [Commits](https://github.com/golang-jwt/jwt/compare/v3.2.1...v3.2.2)

---
updated-dependencies:
- dependency-name: github.com/golang-jwt/jwt
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-08-03 00:27:35 +03:00
fa8fb3aed7 fixes and improvements (#55)
* util/router: sync from github
* config: add watcher interface

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-08-03 00:24:40 +03:00
cfd2d53a79 config: cleanup tests
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-27 23:58:45 +03:00
d306f77ffc util/token/jwt: change library
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-27 23:58:29 +03:00
e5b0a7e20d server: add BatchSubscriber
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-27 23:58:06 +03:00
9a5b158b4d change jwt lib
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-27 12:43:56 +03:00
af8d81f3c6 logger: add DefaultCallerSkipCount
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-26 09:48:15 +03:00
5c9b3dae33 broker: improve option naming, move BatchBroker to Broker interface
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-24 16:16:18 +03:00
9f3957d101 client: improve option naming, add BatchPublish to noop client
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-24 16:14:42 +03:00
8fd8bdcb39 logger: fix default logger funcs
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-24 15:22:01 +03:00
80e3d239ab broker/memory: optimize
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-23 15:12:20 +03:00
419cd486cf broker/memory: cleanup
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-23 15:06:10 +03:00
e64269b2a8 broker: add BatchBroker interface to avoid breaking older brokers
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-23 12:55:36 +03:00
d18429e024 metadata: add HeaderAuthorization
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-23 12:17:00 +03:00
675e121049 metadata: add default headers
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-23 12:03:18 +03:00
d357fb1e0d WIP: broker batch processing
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-22 22:53:44 +03:00
e4673bcc50 remove old cruft
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-22 15:45:44 +03:00
a839f75a2f util/reflect: add new funcs
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-22 15:45:31 +03:00
a7e6d61b95 meter: fast path for only one label
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-21 14:29:13 +03:00
650d167313 meter: add BuildLabels func that sorts and deletes duplicates
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-21 14:10:20 +03:00
c6ba2a91e6 meter: BuildName func to combine metric name with labels into string
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-21 12:39:59 +03:00
7ece08896f server: use 127.0.0.1:0 if no address provided
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-17 01:57:39 +06:00
dependabot[bot]
57f6f23294 build(deps): bump github.com/google/uuid from 1.2.0 to 1.3.0 (#53)
Bumps [github.com/google/uuid](https://github.com/google/uuid) from 1.2.0 to 1.3.0.
- [Release notes](https://github.com/google/uuid/releases)
- [Commits](https://github.com/google/uuid/compare/v1.2.0...v1.3.0)

---
updated-dependencies:
- dependency-name: github.com/google/uuid
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-16 00:27:56 +03:00
09e6fa2fed flow: implement new methods, add Async ExecutionOption
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-16 00:17:16 +03:00
10a09a5c6f flow: improve store
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-15 22:56:34 +03:00
b4e5d9462a util/router: move some messages to Trace level
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-15 22:56:34 +03:00
96aa0b6906 store/memory: fix List
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-15 22:53:12 +03:00
f54658830d store/memory: fixup
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-15 12:11:55 +03:00
1e43122660 store/memory: small fixups for flow usage
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-15 11:59:35 +03:00
42800fa247 flow: improve steps handling
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-14 17:12:54 +03:00
5b9c810653 logger: add compile time test for interface compat
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-14 17:12:09 +03:00
c3def24bf4 store: add Wrappers support, create Namespace wrapper
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-14 17:11:37 +03:00
0d1ef31764 client: change AuthToken option signature
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-09 10:47:40 +03:00
d49afa230f logger: add omit logger
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-05 23:04:20 +03:00
e545eb4e13 logger: add wrapper support
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-05 22:32:47 +03:00
f28b107372 broker: fix RawMessage marshal
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-01 23:23:01 +03:00
c592fabe2a minor fixes
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-01 15:56:22 +03:00
eb107020c7 broker: replace Message.Body []byte slice to RawMessage
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-01 15:11:17 +03:00
bd4d4c363e flow improvements (#52)
* flow improvements

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-06-30 17:50:58 +03:00
2a548634fd config: add Save/Load options
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-06-20 23:57:13 +03:00
598dddc476 util/reflect: fix time.Time StructFields parsing
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-06-19 15:58:36 +03:00
887b48f1e7 util/reflect: improve StructFields func
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-06-17 12:53:23 +03:00
6e55d07636 client: allow to publish body only
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-06-13 12:20:35 +03:00
919520219c client: WithBodyOnly publish option
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-06-11 14:14:41 +03:00
60a5e737f8 util/reflect: return pointer from helper funcs
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-05-25 22:44:22 +03:00
34f0b209cc codec: add ability to control codec via struct tags
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-05-25 22:20:39 +03:00
ba8e1889fe dependabot
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-05-16 17:18:56 +03:00
dae5c57a60 Create dependabot.yml 2021-05-15 14:46:22 +03:00
ea590d57df meter/wrapper: add inflight request/message count (#47)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-05-10 17:59:40 +03:00
Renovate Bot
9aa6969836 fix(deps): update golang.org/x/net commit hash to 4163338 2021-05-10 14:29:32 +00:00
Renovate Bot
c00c705c24 fix(deps): update golang.org/x/net commit hash to 16afe75 2021-05-08 09:02:01 +00:00
Renovate Bot
0239f795d8 fix(deps): update golang.org/x/net commit hash to 7fd8e65 2021-05-03 10:07:41 +00:00
Renovate Bot
e69b43881d fix(deps): update golang.org/x/net commit hash to f8dd838 2021-05-01 23:20:59 +00:00
3a48a613fe not fail on lint now
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-04-27 08:36:11 +03:00
86626c5922 fieldalignment of all structs to save memory
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-04-27 08:32:47 +03:00
ee11f39a2f fieldaligment
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-04-27 00:03:18 +03:00
3bdfdd8fd2 meter: fix labels
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-04-27 00:03:18 +03:00
6dfdff7fd8 fieldaligment
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-04-27 00:03:18 +03:00
00a4785df3 fixup
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-04-27 00:03:18 +03:00
Renovate Bot
bae3b0ef94 fix(deps): update golang.org/x/net commit hash to 5f58ad6 2021-04-23 23:52:34 +00:00
Renovate Bot
89b0565062 fix(deps): update golang.org/x/net commit hash to 4e50805 2021-04-22 03:04:18 +00:00
1f8b0aeb61 store: remove unused Value type
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-04-22 00:57:06 +03:00
Renovate Bot
5b6f849e0a fix(deps): update golang.org/x/net commit hash to 798c215 2021-04-20 23:13:59 +00:00
Renovate Bot
3b416fffde fix(deps): update golang.org/x/net commit hash to d25e304 2021-04-20 15:04:17 +00:00
3a60103aed server: drop Internal option
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-04-20 12:45:14 +03:00
41837a67f8 register: drop verbose values export
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-04-20 12:39:21 +03:00
852f19598d util/reflect: fix protobuf field name detection
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-04-19 11:34:28 +03:00
6537b35773 util/reflect: add interface merging
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-04-19 01:19:37 +03:00
b733f1316f remove stale generate stuff
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-04-16 17:36:27 +03:00
Renovate Bot
840af5574c fix(deps): update golang.org/x/net commit hash to e915ea6 2021-04-16 00:56:52 +00:00
Renovate Bot
56e5b7001c fix(deps): update golang.org/x/net commit hash to 0645797 2021-04-14 21:41:15 +00:00
Renovate Bot
11dc6fd752 fix(deps): update golang.org/x/net commit hash to afb366f 2021-04-10 11:09:36 +00:00
a2695d8699 util/reflect: rewrite struct merging with map
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-04-10 01:22:40 +03:00
618421de05 client: allow to set content-type for call
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-04-09 23:09:12 +03:00
Renovate Bot
30baaabd9f fix(deps): update golang.org/x/net commit hash to a5a99cb 2021-04-05 19:46:46 +00:00
df5bce1191 util/reflect: fix StructURLValues
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-04-03 11:50:23 +03:00
Renovate Bot
089d0fe4df fix(deps): update golang.org/x/net commit hash to 0fccb6f 2021-03-31 22:50:38 +00:00
a06f535303 util/reflect: add StructURLValues func
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-04-01 00:30:26 +03:00
Renovate Bot
eba586a329 fix(deps): update golang.org/x/net commit hash to cb1fcc7 2021-03-31 09:19:27 +00:00
Renovate Bot
d74a8645e8 fix(deps): update golang.org/x/net commit hash to e572328 2021-03-31 00:52:53 +00:00
Renovate Bot
5a00786192 fix(deps): update golang.org/x/net commit hash to cd0ac97 2021-03-30 22:28:38 +00:00
Renovate Bot
b3e9941634 fix(deps): update golang.org/x/net commit hash to c8897c2 2021-03-30 16:02:28 +00:00
Renovate Bot
a5a5904302 fix(deps): update golang.org/x/net commit hash to 22f4162 2021-03-30 11:44:00 +00:00
Renovate Bot
a59832e57e fix(deps): update golang.org/x/net commit hash to df645c7 2021-03-30 05:11:12 +00:00
0e42033e7f meter/handler: more idiomatic option handling
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-03-29 17:51:44 +03:00
52d8255974 service init with own context
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-03-28 23:42:02 +03:00
9830cb48a9 fix compilation
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-03-28 19:31:03 +03:00
92d7ab2105 regen handlers
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-03-28 19:28:01 +03:00
d2935ef399 meter/handler: fix proto and generated code
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-03-28 19:18:11 +03:00
ce4c96ae0a server/health: add health check handler
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-03-28 19:18:11 +03:00
Renovate Bot
14026d15be fix(deps): update golang.org/x/net commit hash to 61e0566 2021-03-27 01:29:30 +00:00
Renovate Bot
2df0c7643e fix(deps): update golang.org/x/net commit hash to 6b15177 2021-03-26 19:17:30 +00:00
e13c2c48fd client: use router.DefaultRouter in NewOptions helper
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-03-26 17:45:55 +03:00
8db55d2e55 router: use dns as default router
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-03-26 17:43:39 +03:00
ed61cad961 meter/handler: regen
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-03-26 15:45:09 +03:00
040fc4548f client: add TLSConfig option
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-03-26 15:44:34 +03:00
6189a1b980 add SkipEndpoints for wrappers
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-03-25 23:30:38 +03:00
eb2a450a7b meter/handler: fix func signature
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-03-25 12:36:48 +03:00
Renovate Bot
d2a30a5da1 fix(deps): update golang.org/x/net commit hash to d1beb07 2021-03-24 23:28:38 +00:00
65889c66f6 meter/wrapper: add DefaultSkipEndpoints
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-03-25 00:06:38 +03:00
dcdf133d5b server: mask router
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-03-24 13:26:36 +03:00
8742b55305 auth: fix Init method
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-03-24 13:12:03 +03:00
4a64ee72f7 meter/handler: provide default metrics handler
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-03-23 17:26:29 +03:00
881d7afeea meter/handler: provide initial meter handler
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-03-23 17:12:13 +03:00
8c95448535 util/reflect: add IsZero helper
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-03-21 16:17:50 +03:00
c1dc041d8c client: fix NewOptions with CallOptions filling
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-03-16 19:09:49 +03:00
Renovate Bot
25be0ac0f0 fix(deps): update golang.org/x/net commit hash to d523dce 2021-03-16 13:12:17 +00:00
Renovate Bot
86f73cac4e fix(deps): update golang.org/x/net commit hash to 34ac3e1 2021-03-15 22:09:13 +00:00
485eda6ce9 meter/wrapper: fix wrapper build
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-03-15 00:49:26 +03:00
dbbdb24631 meter: rework labels
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-03-15 00:44:13 +03:00
723ceb4f32 regsiter: fix extractor
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-03-12 16:09:20 +03:00
bac9869bb3 register: support map in ExtractValue
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-03-12 15:48:05 +03:00
610427445f codec: provide proto for codec.Frame
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-03-11 07:42:42 +03:00
Renovate Bot
c84a66c713 fix(deps): update module github.com/imdario/mergo to v0.3.12 2021-03-10 00:35:57 +00:00
00eaae717b lint fixes
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-03-06 23:44:54 +03:00
a102e95433 spell fixes
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-03-06 23:33:37 +03:00
39f66cc86c add logger wrapper, fix default logger fields method
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-03-06 23:26:47 +03:00
bbbcb22565 fieldalignment of all structs to save memory
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-03-06 19:45:13 +03:00
cb70dfa664 meter/wrapper: use meter.DefaultMeter in NewOptions
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-03-05 17:40:03 +03:00
1f0482fbd5 tracer: finalize tracer implementation
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-03-04 01:12:16 +03:00
a862562284 fixup domain in ListServices
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-03-03 18:16:54 +03:00
c320c23913 metadata: minor fixup for NewXXXContext functions
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-03-01 13:00:53 +03:00
Renovate Bot
ae848ba8bb fix(deps): update golang.org/x/net commit hash to e18ecbb 2021-02-26 19:46:14 +00:00
Renovate Bot
8e264cbb3e fix(deps): update golang.org/x/net commit hash to 39120d0 2021-02-26 12:05:10 +00:00
Renovate Bot
54e523ab3f fix(deps): update golang.org/x/net commit hash to 3d97a24 2021-02-26 08:40:37 +00:00
09973af099 server: add error helper
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-22 00:52:18 +03:00
3247da3dd0 metadata: add Pairs helper func
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-22 00:08:05 +03:00
b505455f7c run go mod tidy in renovate update
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-21 23:55:19 +03:00
293949f081 metadata: add Append func to Incoming/Outgoing context
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-21 23:54:59 +03:00
8d7e442b3a server: add SubscriberBodyOnly option
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-20 18:12:13 +03:00
renovate[bot]
f7b5211af3 fix(deps): update golang.org/x/net commit hash to 5f55cee (#20)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-02-20 11:40:35 +03:00
7eb6d030dc meter: fix internal labels sorting
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-18 15:57:42 +03:00
47e75c31c7 meter: export labels len method
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-18 14:41:51 +03:00
20ff5eed22 meter: initial wrapper import (#19)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-18 14:35:10 +03:00
d23ca8db73 Merge pull request #18 from unistack-org/flow
flow: initial tests
2021-02-18 12:49:32 +03:00
4dd28ac720 go 1.15 => 1.16
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-18 12:49:02 +03:00
240b6016df flow: add initial flow dag
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-18 12:44:37 +03:00
cf2aa827e4 update to go 1.16
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-18 12:44:18 +03:00
5596345382 util/rand: replace all non crypto rand stuff with own rand package
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-18 12:44:18 +03:00
67748a2132 util/reflect: import own path based interface lookup
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-14 23:33:01 +03:00
c2333a9f35 gh actions not fail on lint errors
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-14 16:26:40 +03:00
4ec4c277b7 lint: fix all major issues
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-14 16:16:01 +03:00
a11dd00174 profiler: fix import
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-14 14:25:04 +03:00
cc7ebedf22 debug/profile: move to profiler interface
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-14 14:02:51 +03:00
e5bf1448f4 lint fixes
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-14 11:28:50 +03:00
f182bba6ff debug/log: remove stale files
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-13 20:01:57 +03:00
1f8810599b go.mod cleanup
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-13 15:37:33 +03:00
82248eb3b0 many lint fixes and optimizations (#17)
* util/kubernetes: drop stale files
* debug/log/kubernetes: drop stale files
* util/scope: remove stale files
* util/mdns: drop stale files
* lint fixes

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-13 15:35:56 +03:00
abb9937787 fix lint issues (#16)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-13 01:46:16 +03:00
fd5ed64729 metadata: fix nil metadata from FromIncoming/FromOutgoing context
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-12 17:10:35 +03:00
6751060d05 move memory implementations to core micro repo
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-12 16:33:16 +03:00
ef664607b4 automerge minor version updates
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-12 11:48:09 +03:00
62e482a14b move renovate
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-10 12:44:56 +03:00
a390ebf80f fix renovate.json
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-10 12:43:29 +03:00
9a44960be7 another fix
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-10 10:52:33 +03:00
c846c59b9b fix renovate.json
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-10 10:39:37 +03:00
renovate[bot]
902bf6326b chore(deps): update golangci/golangci-lint-action action to v2 (#14)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-02-10 00:35:56 +03:00
renovate[bot]
bddf3bf502 chore(deps): update actions/setup-go action to v2 (#13)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-02-09 23:04:23 +03:00
renovate[bot]
284131da98 Add renovate.json (#12)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-09 23:01:50 +03:00
927c7ea3c2 metadata: allow to modify metadata via SetXXX functions
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-09 12:46:14 +03:00
0e51a79bb6 metadata: split context to incoming and outgoing
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-09 01:08:45 +03:00
1de9911b73 util/reflect: add missing types for merge
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-06 18:13:43 +03:00
b4092c6619 util/reflect: improve merge for map
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-05 18:27:16 +03:00
024868bfd7 api: encode body param in endpoint
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-02 19:35:16 +03:00
a0bbfd6d02 provide compa options
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-02-02 15:37:12 +03:00
2cb6843773 codec: fix noop codec
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-29 23:18:12 +03:00
87e1480077 config: add name to each config imp
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-29 16:18:17 +03:00
bcd7f6a551 codec: fix noop codec to handle *broker.Message
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-29 16:07:21 +03:00
925b3af46b register: fix options
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-29 15:06:47 +03:00
ef4efa6a6b rename util
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-29 14:50:09 +03:00
125646d89b add Name func option
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-29 14:07:35 +03:00
7af7649448 store: add Name func
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-29 14:02:54 +03:00
827d467077 micro: rewrite options to support multiple building blocks
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-29 13:17:32 +03:00
ac8a3a12c4 meter: complete interface
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-27 00:54:19 +03:00
286785491c store: improve interface
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-26 02:09:26 +03:00
263ea8910d meter: use plan map and metadata
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-23 00:23:29 +03:00
202a942eef metadata: add Merge func
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-23 00:09:07 +03:00
c7bafecce3 add meter and tracer across all options
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-22 23:32:33 +03:00
c67fe6f330 meter: add option helper and provide default metric name and label prefix
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-22 19:18:28 +03:00
8c3f0d2c64 meter: remove wrapper
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-22 18:22:17 +03:00
8494178b0d meter: rework meter interface
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-22 18:21:40 +03:00
8a2c4c511e metadata: add iterator method
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-21 18:37:54 +03:00
dcca28944e util/reflect: add useful helpers
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-21 14:05:50 +03:00
92e6fd036e config: merge default not overwrite
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-21 02:20:06 +03:00
eab1a1dd40 api/server: move to dedicated repo
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-20 01:21:15 +03:00
188d9611c9 util/reflect: add struct field helper
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-20 00:47:13 +03:00
74a52eed9d rename metrics to meter
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-19 16:26:00 +03:00
770e8425bd config: move reflect stuff to util/reflect
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-19 01:40:34 +03:00
4783c6d9a3 client: add option helper
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-19 00:45:55 +03:00
2b2bcf4586 client: add call option helper
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-18 23:48:50 +03:00
77f517a9f6 metrics: add context option
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-15 22:47:28 +03:00
49d54f7fe6 logger: remove SetLevel from logger interface
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-12 09:26:14 +03:00
8b7380876e modify all code for never logger interface
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-10 19:24:03 +03:00
7b3a7a9448 logger: update logger interface
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-10 18:56:39 +03:00
270ad1b889 api: fix Decode method
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-10 03:55:04 +03:00
bcf7cf10d3 server: fix NewHandlerOptions
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-10 03:36:23 +03:00
8930c3fbb7 api/router: extend interface
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-10 01:54:21 +03:00
e6f870bda7 codec: fix interface
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-20 23:53:29 +03:00
8feab7cc48 config: init before load
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-20 23:08:40 +03:00
aa6afdf440 config: fix tests
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-20 01:07:48 +03:00
6b1ed63b48 guard agains not fully configured config sources
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-20 01:00:52 +03:00
b50855855b config: export method to init new empty struct
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-20 00:15:29 +03:00
150e8ad698 config: improve and export helper func
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-19 23:22:05 +03:00
035a84e696 config: fix tests
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-18 03:50:52 +03:00
565082f515 before/after config stuff handled by implementations
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-18 03:38:09 +03:00
8c504bd029 handle before/after inside config implementations
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-18 03:37:18 +03:00
f6c0728a59 fix context usage across codebase
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-17 22:52:00 +03:00
70a17dc10a client: allow to create new client with predefined call options
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-15 23:09:51 +03:00
f14efa64f0 server: add MaxConn and Listener options
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-15 11:52:05 +03:00
42f4d26fe4 server: add MaxConn option
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-15 11:46:30 +03:00
06c3cd6637 config: fix default config loader
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-13 19:28:29 +03:00
99738096ac fix configs options
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-13 18:56:54 +03:00
c6dfc8acaa load config on service init
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-13 14:36:31 +03:00
762f20d179 registry: adopt micro/micro 69b0ac2e9140fee1cde043f5ecdab438a41898ee
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-13 13:51:09 +03:00
92aec349c3 config: add missing codec error
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-13 13:26:44 +03:00
2dcd30b21c add defaut config parser
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-13 13:17:38 +03:00
a7a3c679d1 config: load defaults
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-13 13:10:04 +03:00
5c6eba20e7 codec: fix noop codec
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-11 00:32:29 +03:00
0a68a9c278 use default codec for store
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-11 00:21:53 +03:00
a13cb01005 store: create options helpers
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-10 22:37:40 +03:00
9fc0b5f88b store: remove unneded options
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-10 22:31:36 +03:00
6a7433ba2a store: refactor interface (#11)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-10 22:08:56 +03:00
a754ff7c0c more lint fixes
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-09 12:10:25 +03:00
e08276c2e2 gofmt
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-08 00:41:14 +03:00
b7b28f6b9a lint
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-08 00:38:37 +03:00
f63ff80d46 backport micro 820f59869617dee18c9a699c8e01d7a6b080f854
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-07 21:54:45 +03:00
8fd745eab0 config: add logger to options
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-07 19:27:08 +03:00
c7ed807129 default retries is always 0
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-07 19:26:22 +03:00
c6fd9c1c23 add context helpers
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-07 16:10:20 +03:00
b5d3b699cf fixup
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-04 02:34:20 +03:00
5279c2aa0f config package rework (#9)
* change config interface
* reuse codec
* allow to modify next config based on values in current config via BeforeLoad

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-04 02:28:45 +03:00
0ddc8de00b apply micro commit 2eb19c2e97d9316438bc66cd2cda896e8c99d026
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-30 22:48:00 +03:00
8d6eb34aee fix random selector
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-29 17:30:54 +03:00
0d93b2c31c add some defaults
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-26 01:13:05 +03:00
3f6852030f expose codec options
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-25 10:43:13 +03:00
458388359a add string support to noop codec
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-25 10:04:11 +03:00
2101e994d9 add Frame support in noop codec
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-25 09:59:28 +03:00
8a50a2d0b8 receives only body of the message
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-25 08:33:29 +03:00
71d82e9d5b add codec NewMessage helper
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-24 15:14:47 +03:00
c9049c3845 major codec upgrade
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-23 16:21:07 +03:00
daffa9e548 use metadata.Metadata (#8)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-18 16:50:41 +03:00
e0ef8b2953 merics: add Init func to interface
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-15 00:53:40 +03:00
f6c914c1e4 metrics: minor changes to interface and set default
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-15 00:38:38 +03:00
b38484d18e go mod tidy
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-13 15:06:12 +03:00
75222e07cb exttract protoc plugin to dedicated repo
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-13 14:59:14 +03:00
4233a4b673 init cmd and logger options on service init
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-13 14:52:19 +03:00
c44a82a8cb registry/noop: implement noop watcher
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-13 14:50:57 +03:00
37f7960f4a logger: add WithContext option
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-13 14:50:29 +03:00
6dc7e792c8 logger improvements
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-10 22:18:16 +03:00
81649d51e1 Merge branch 'master' of https://github.com/unistack-org/micro 2020-11-10 11:01:14 +03:00
23f5d10ccb server: remove unused code
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-10 11:00:37 +03:00
e3f235acc1 api/handler/rpc: fix corner cases
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-10 11:00:06 +03:00
fa9ef1c816 simplify service stop waiting
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-10 10:59:26 +03:00
77dab8ee15 server: remove unneded chan in noop server
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-10 10:58:32 +03:00
51fbff3e4a metadata: add checks for nil context
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-10 10:57:33 +03:00
bd6493327f Merge pull request #7 from itzmanish/protoc-gen-micro-fix
generate SendAndClose() and CloseAndRecv() on streams.
2020-11-07 15:53:00 +03:00
Manish
2141e9631c generate SendAndClose() and CloseAndRecv() on streams. 2020-11-07 14:55:33 +05:30
be8d09c663 network/transport: fix default dial timeout
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-06 11:18:12 +03:00
72bbbe3817 client: remove cache responses
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-06 00:25:09 +03:00
c92add984c allow to return all stuff from service opts
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-06 00:04:00 +03:00
3542d6c824 store: fix comment
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-06 00:03:40 +03:00
dc63d96e0b move store test to micro-tests repo
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-05 23:56:10 +03:00
7c9a7e84c7 not use selfsigned certs
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-05 23:55:53 +03:00
31180758b4 move avay grpc stuff to micro-server-grpc
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-05 23:46:11 +03:00
ce25a41fe1 remove cache as store can do the same thing
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-05 23:35:55 +03:00
8fa8afdfa4 fix namespace server issue
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-05 22:35:05 +03:00
e127547799 add registry helpers
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-05 21:18:05 +03:00
1fbf8b2e20 Merge pull request #6 from unistack-org/logger
rewrite logger
2020-11-05 00:49:03 +03:00
e41bb5ebc5 rewrite logger
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-05 00:23:05 +03:00
7c311aea19 api: extract routers to external repos
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-05 00:22:53 +03:00
8a2b122015 many fixes for lint and context.Context usage (#5)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-03 02:02:32 +03:00
40b0870cf8 fix linting (#4)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-03 01:08:23 +03:00
e6ab6d50eb remove unneeded Error field from broker.Message
close github.com/unistack-org/micro-roadmap/issues/26 (#3)

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-02 23:45:41 +03:00
a9eff06976 fix repocard issues (#2)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-11-02 13:25:29 +03:00
416fe5e4c8 run tests from micro-tests repo
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-10-30 23:52:05 +03:00
ddb53bf8e4 add slack badge
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-10-29 16:16:31 +03:00
0e6efda528 minor cleanup
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-10-28 17:48:39 +03:00
f2413a7789 disconnect from stuff on service stop
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-10-28 12:02:57 +03:00
9553f46cf4 connect to all stuff on start
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-10-28 10:51:09 +03:00
14c97d59c1 many improvements with options and noop stuff
* add many options helpers
* fix noop client to allow publish messages to topic in broker
* fix noop server to allow registering in registry
* fix noop server to allow subscribe to topic in broker
* fix new service initialization

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-10-16 09:38:57 +03:00
a59aae760f metadata: use new helper
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-10-12 17:20:52 +03:00
0a5b34a07b metadata: small optimization and export default metadata size
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-10-12 17:17:59 +03:00
62502ad720 always generate call with CamelCased name
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-10-12 16:19:30 +03:00
6e43ae7190 add client publish option func
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-10-12 12:09:09 +03:00
0e1f744fcc add helper for publish options
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-10-10 00:47:09 +03:00
2fc47782cf use metadata helper
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-10-09 16:51:58 +03:00
34d93306d6 new registry util func
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-10-09 16:49:29 +03:00
336868ed0d move helper to proper place
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-10-09 16:21:47 +03:00
2682f15b8e move helper to proper place
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-10-09 16:20:10 +03:00
4c12e38c01 move generic code from grpc server implementation
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-10-09 16:15:36 +03:00
62bfe9c06e allow to publish message via broker on noop client
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-10-09 13:43:04 +03:00
24be220f91 close micro-roadmap/issues/12
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-10-09 12:15:55 +03:00
cacd33e84f metadata: fix tests
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-10-01 16:05:05 +03:00
9475003059 fix concurrent map usage
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-10-01 16:00:01 +03:00
8532ccebba metadata: avoid allocations on delete
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-09-30 16:21:47 +03:00
9c55b1d06a fix metadata issues with uppercase letters
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-09-30 16:14:54 +03:00
efd9075d9b add error vars
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-09-28 13:08:53 +03:00
4c4fa00a5d add useful func
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-09-22 13:33:57 +03:00
21d5ca1cdd rename func
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-09-22 13:17:38 +03:00
ec3c1a02fc expose useful broker and server methods
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-09-22 13:15:05 +03:00
dc5dc6ab5b update
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-09-20 17:02:41 +03:00
1cbd1d2bad fix
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-09-20 16:57:54 +03:00
aa667728a1 move transport
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-09-20 16:52:26 +03:00
9b11ea527a add Wait option
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-09-20 15:48:07 +03:00
5787a1afb8 more useful router new options func
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-09-17 15:44:35 +03:00
74c10f1139 more idiomatic names inside generated protoc files
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-09-17 15:44:05 +03:00
7e3fac8937 fix store context issues
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-09-17 15:41:49 +03:00
6021edc855 add more context to store
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-09-17 15:18:01 +03:00
8817c110d0 add context to store
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-09-17 15:15:42 +03:00
d59db9df16 check for nil cmd
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-09-14 12:58:51 +03:00
2d1e6db9fd add context in server handler option
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-09-11 11:55:31 +03:00
5bfca99627 fix old proto
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-09-10 15:17:23 +03:00
9ea3149b60 fixup opts
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-09-10 00:25:33 +03:00
8f03480ed2 update go.mod
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-09-10 00:08:59 +03:00
caec730248 move out tracers
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-09-10 00:06:29 +03:00
f1fde75567 fix init
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-09-07 15:29:43 +03:00
5fe3a46732 init default stuff
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-09-07 13:38:52 +03:00
e7d418183b fixup logger usage (#33)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-09-05 02:43:16 +03:00
c576749b57 noop impl (#32)
* improve logger usage
* add noop client and server

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-09-05 02:11:29 +03:00
c062aab1a9 add noop broker and noop store (#30)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-09-03 15:11:05 +03:00
0252addf05 broker: resurrect DisableAutoAck
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-31 16:51:58 +03:00
b7338c12d7 broker: resurrect Queue option
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-31 16:48:29 +03:00
7c115823a7 Revert "fix protoc-gen-micro"
This reverts commit 47d007c0b6.
2020-08-31 11:51:30 +03:00
47d007c0b6 fix protoc-gen-micro
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-31 10:52:19 +03:00
c9b283be60 move out cache implementations
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-31 10:51:58 +03:00
112f21006c config: add default config
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-29 18:08:21 +03:00
53654185ba add logger to options
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-29 17:44:49 +03:00
2382446e10 registry: set noop as default registry
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-29 17:44:04 +03:00
24c20b6907 resolver/registry: small slice optimization
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-29 17:43:36 +03:00
622490fbf3 logger: refactor interface
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-29 17:43:06 +03:00
dd8894e673 registry: add noop registry
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-29 17:41:49 +03:00
eb1b14da8a model: split options, add logger
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-29 17:40:25 +03:00
0005f23585 errors: move grpc error def to grpc server
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-29 17:32:57 +03:00
fb233374a0 resolver/dns: support ipv6 addrs
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-29 16:53:53 +03:00
9c695ac343 split router implementations
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-28 12:19:47 +03:00
2c136b005e resurrect default for auth
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-28 11:55:18 +03:00
7cf42589b3 cleanup deps
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-28 11:52:51 +03:00
6aa857dfa1 fixup deps
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-28 11:27:45 +03:00
0f19355621 resurrect service stuff
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-28 10:58:08 +03:00
aa99378adc add check (#27)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-27 11:32:27 +03:00
b4ccde2228 resurrect broker event (#26)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-27 11:18:02 +03:00
36c53b4917 сleanup (#24)
* move out prometheus metrics
* not use gorilla wrappers

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-25 17:59:41 +03:00
ef773d8d49 remove util/log in favour of logger (#23)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-25 17:31:28 +03:00
fc3794f548 move runtime implementations (#22)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-25 15:55:30 +03:00
67ab44593b fix repocard issues (#21)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-25 15:41:48 +03:00
8076e410a9 fix repocard issues (#20)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-25 14:33:36 +03:00
dd78ae8658 cleanup (#18)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-25 14:16:08 +03:00
0f4b1435d9 move implementations to external repos (#17)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-25 13:44:41 +03:00
c4a303190a lint fixes (#14)
* lint fixes

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-21 14:53:21 +03:00
199ff66bd4 enable cache for build, closes #8 (#12)
* enable cache for build, closes #8
* goimports
* lint fixes

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-20 15:23:41 +03:00
98ba3b2788 grpc: avoid allocations for each message (#11)
* grpc: avoid allocations for each message
* fix tests for api/router

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-20 14:45:47 +03:00
5ea2590891 Merge pull request #10 from unistack-org/quic
update quic go package
2020-08-20 14:29:45 +03:00
0a42845a40 fix tests
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-20 14:20:27 +03:00
Asim Aslam
e6daa9a838 Update debug.go 2020-08-20 14:20:27 +03:00
ben-toogood
72621e0da4 events: update interface (#1954) 2020-08-20 14:20:27 +03:00
Dominic Wong
d5da9c0728 Unify the store tests (#1952)
Add more tests for store
2020-08-20 14:20:12 +03:00
Janos Dobronszki
eee5b98d78 Generic git checkout (#1951) 2020-08-20 14:18:53 +03:00
ben-toogood
cf084b410f util/file: allow context to be passed (#1950) 2020-08-20 14:18:52 +03:00
cf9bdd0f99 update quic go package
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-20 12:37:40 +03:00
06136312bb regen files with never protoc (#6)
* regen files with never protoc
* rewrite import path

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-19 17:47:17 +03:00
7a407d5792 setup lint (#3)
* setup lint

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-19 16:11:03 +03:00
ben-toogood
66df1bb361 events/nats: add support for TLS config (#1946)
* events/nats: add support for TLS config

* events/nats: improve error logging
2020-08-19 10:55:54 +01:00
Asim Aslam
7eaec450a1 support error handler in memory broker (#1947) 2020-08-19 10:20:43 +01:00
Asim Aslam
5d6b7b3d7d Move the network resolver out (#1944) 2020-08-18 21:38:29 +01:00
Dominic Wong
2eac8ed64f Fix cockroach store not respecting WriteTTL option (#1943)
* cockroach fixes for expiry

* cockroach should run in the background
2020-08-18 18:30:05 +01:00
Janos Dobronszki
2b2dc2f811 Support private repos in env 'local' (#1938) 2020-08-18 18:26:14 +02:00
ben-toogood
21cca297c0 events: implement package with memory & nats streams (#1942) 2020-08-18 16:19:53 +01:00
Asim Aslam
19ef225b2f Revert "grpc: avoid allocations for each message (#1939)" (#1941)
This reverts commit 2a23224d91.
2020-08-18 14:44:29 +01:00
2a23224d91 grpc: avoid allocations for each message (#1939)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-08-18 14:24:11 +01:00
Asim Aslam
dd2dc7a2b9 Update broker.go 2020-08-18 14:05:25 +01:00
Asim Aslam
4413372a3f Decruft the broker by removing Event interface (#1940) 2020-08-18 14:00:51 +01:00
Janos Dobronszki
a2a808f2d6 Baseurl, gitlab support, single word service names (#1933) 2020-08-18 11:31:49 +02:00
Asim Aslam
7a6669d199 Update reporter.go 2020-08-18 08:30:29 +01:00
Asim Aslam
09fdd3c121 Update reporter.go 2020-08-18 08:29:26 +01:00
Prawn
da4159513e Metrics interface and Prometheus implementation (#1929)
* Metrics interface

* Prometheus implementation

* NoOp implementation

Co-authored-by: chris <chris@Profanity.local>
2020-08-18 08:27:50 +01:00
Asim Aslam
e1248f90f4 update options 2020-08-17 23:09:41 +01:00
Asim Aslam
3011bad518 sort routes by metric 2020-08-17 23:09:24 +01:00
Asim Aslam
bb7fe21c46 unused variables 2020-08-17 23:00:27 +01:00
Asim Aslam
4fd4a116f2 allow setting registry router in client 2020-08-17 22:53:20 +01:00
Asim Aslam
50ec6c748f cleanup client/selector/lookup (#1937)
* cleanup client/selector/lookup

* add mdns router, remove registry from client

* fix roundtripper

* remove comment

* fix compile issue

* fix mucp test

* fix api router
2020-08-17 22:44:45 +01:00
Asim Aslam
7135787b78 Update README.md 2020-08-17 19:43:28 +01:00
Asim Aslam
870a1ebc07 dead code 2020-08-17 10:04:52 +01:00
zuoan
61899398b3 simplifies code (#1934)
Co-authored-by: 刘海洋 <haiyang@snqu.com>
2020-08-17 11:10:42 +03:00
Asim Aslam
55d62fc1a5 Strip Advertise/Process from router 2020-08-14 23:51:52 +01:00
Asim Aslam
5238a8a85f don't delete own routes 2020-08-14 23:04:55 +01:00
Asim Aslam
9fffd0419e Merge branch 'master' of ssh://github.com/micro/go-micro 2020-08-14 21:52:18 +01:00
Asim Aslam
58794df27c default to noop registry in network 2020-08-14 21:52:05 +01:00
ben-toogood
5a88ea7247 runtime: resource limits (kubernetes implementation) (#1931)
* runtime: add resource limit CreateOptions

* util/kubernetes/client: implement support for resource limits

* runtime/kubernetes: set resource limits for k8s deployments

* util/kubernetes: remove template check for ints

* util/kubernetes: fix incorrect yaml syntax

* runtime/kubernetes: fix incorrect units

* runtime: update create options to use Resources struct
2020-08-14 11:47:28 +01:00
Asim Aslam
374aae1490 Merge branch 'master' of ssh://github.com/micro/go-micro 2020-08-13 14:10:49 +01:00
Asim Aslam
ccf2f4efd6 fix windows 2020-08-13 14:10:41 +01:00
ben-toogood
9380b365de runtime/local: fix injection of secrets as env vars (#1930) 2020-08-13 09:22:25 +01:00
Asim Aslam
f0142febcf executable is now os 2020-08-13 07:57:57 +01:00
Asim Aslam
1fa3ac5599 write nil when expiry is zero 2020-08-12 12:52:14 +01:00
Asim Aslam
375b67ee16 simplify runtime logs 2020-08-11 22:57:30 +01:00
Dominic Wong
69a53e8070 expiry can be taken from options or record (#1928) 2020-08-11 18:11:18 +01:00
Asim Aslam
b6e1c7ac99 make source dir a variable 2020-08-11 17:25:43 +01:00
Asim Aslam
e83a808b05 make log dir a variable 2020-08-11 17:23:00 +01:00
ben-toogood
012ec6a998 router/registry: fix expiring routes bug (#1927) 2020-08-11 16:57:04 +01:00
Asim Aslam
fae4151027 Add a build package (#1926)
* Add a build package

* fix go mod

* package tar
2020-08-11 16:51:58 +01:00
ben-toogood
e162e6d505 router/registry: fix bug which impacts service registered in multiple domains (#1925)
* router/registry: fix bug which impacts service registered in multiple domains

* router/registry: bugfix
2020-08-11 12:42:22 +01:00
Asim Aslam
c51ef6fc29 move wrapper to client 2020-08-11 11:25:49 +01:00
Asim Aslam
28d6340f04 Merge branch 'master' of ssh://github.com/micro/go-micro 2020-08-11 10:32:25 +01:00
Asim Aslam
4fc193f95d Delete the cmd package 2020-08-11 10:24:55 +01:00
Asim Aslam
d072eb6ff2 Deprecate service (#1924) 2020-08-11 10:03:47 +01:00
ben-toogood
1263806a39 util/kubernetes: add readiness check to deployments (#1923) 2020-08-11 08:38:30 +01:00
Asim Aslam
959407bad9 support wrapper slice in api server options 2020-08-10 22:38:54 +01:00
Asim Aslam
61d12d3a39 fix etcd keys for services (#1922) 2020-08-10 21:58:35 +01:00
Asim Aslam
4db8ea8f6a Move tunnel to its own package (#1921) 2020-08-10 17:31:21 +01:00
Asim Aslam
13f495587e cleanup debug and transport (#1920) 2020-08-10 15:58:39 +01:00
ben-toogood
593b543230 runtime/kubernetes: fix streaming logs error handling (#1919) 2020-08-10 15:20:33 +01:00
ben-toogood
fdce953c15 runtime/kubernetes: fix update bug (#1918) 2020-08-10 15:08:04 +01:00
Janos Dobronszki
96836f2e43 Decrease log levels in router/registry package to not appear for CLI users (#1917) 2020-08-10 13:57:45 +01:00
Asim Aslam
65e6ee8566 use noop resolver in network by default 2020-08-09 22:11:57 +01:00
Asim Aslam
a7c70c66b1 return a micro error on lookup failure 2020-08-09 21:44:39 +01:00
Asim Aslam
b2582c0992 fix deadlock bug 2020-08-09 19:39:21 +01:00
Asim Aslam
6373cc91b7 remove print statement 2020-08-09 19:35:07 +01:00
Asim Aslam
ed704640aa getDomain should return the default domain 2020-08-09 19:08:25 +01:00
Asim Aslam
cd9e5a1e9e continue to allow endpoint routing 2020-08-09 16:57:34 +01:00
Asim Aslam
dcf040ec9f strip back the grpc proxy 2020-08-09 16:47:00 +01:00
Asim Aslam
f838c33008 noop.NewRegistry function 2020-08-09 16:26:51 +01:00
Asim Aslam
e8ea0f85e9 add a noop registry 2020-08-09 16:17:52 +01:00
Asim Aslam
51f8b4ae3d embed grpc server stream and client so they can be accessed (#1916) 2020-08-09 15:43:41 +01:00
Asim Aslam
69a2032dd7 lower log level to debug 2020-08-08 14:04:18 +01:00
Asim Aslam
64feb6dff2 Add subscriber naem 2020-08-08 09:21:13 +01:00
Asim Aslam
4c95c65d81 Return service name in error 2020-08-08 09:09:34 +01:00
Asim Aslam
4469a41ae7 use a totally different client for the watcher in etcd 2020-08-08 01:40:41 +01:00
Asim Aslam
fc67593ee4 cleanup router watcher logic 2020-08-08 01:04:38 +01:00
Asim Aslam
e7cc3c2210 protect etcd watcher stop against race condition 2020-08-08 00:57:57 +01:00
Asim Aslam
712fe39a62 initChan is never evaluated because watchRegistry is a blocking call 2020-08-07 23:44:43 +01:00
Asim Aslam
9b14eb8aec close the existing etcd client if it exists 2020-08-07 23:09:06 +01:00
Asim Aslam
124b1bd7b7 add https prefix when using tls config for etcd 2020-08-07 22:46:05 +01:00
ben-toogood
ac1aace214 route the API subdomain (#1910)
Co-authored-by: Asim Aslam <asim@aslam.me>
2020-08-07 20:54:55 +01:00
Asim Aslam
324c4e6886 Router refresh (#1912)
* checkpoint

* Refresh and prune routes periodically in the registry router

* remove comment
2020-08-07 20:53:38 +01:00
Asim Aslam
d69a4a30cd fix etcd bug that causes deregister to be skipped (#1911) 2020-08-07 19:58:25 +01:00
Asim Aslam
a6d7b1d710 Move api/router/util to util/router (#1909) 2020-08-07 13:30:29 +01:00
Asim Aslam
8ee31b94a1 remove handler/util package in favour of util/router (#1908) 2020-08-07 12:47:20 +01:00
Asim Aslam
37cc7fda92 Update pprof.go 2020-08-07 12:18:01 +01:00
Asim Aslam
d61cbd29db Update README.md 2020-08-07 11:22:57 +01:00
Asim Aslam
b6ab124d83 Update README.md 2020-08-07 11:21:59 +01:00
Dominic Wong
835343d6a5 logs should return for non existent services (#1906) 2020-08-06 22:56:05 +01:00
Maarten Bezemer
74907987d1 codec - Allow to Write() nil body (#1905)
* codec - Allow to Write() nil body

* Oops we are in v3 now
2020-08-06 18:51:00 +01:00
Asim Aslam
fb8533b74e Update tunnel 2020-08-06 18:50:35 +01:00
Z
dcf785677f Fix: file-watcher bugs (#1897)
* Fix: file-watcher bugs

* Update watcher_linux.go

Co-authored-by: 杨铭哲 <yangmz@weipaitang.com>
Co-authored-by: Asim Aslam <asim@aslam.me>
2020-08-06 18:21:09 +01:00
ben-toogood
991cdba91d registry/etcd: fix services combining (#1901) 2020-08-06 15:38:50 +01:00
Asim Aslam
aefd052dd7 Etcd router bug fixing etcd path prefix matching name (#1899)
* add logging and don't get nodes where they exist in router

* add more logging

* Fix the etcd bug for name matching of keys and prefixes matching names
2020-08-06 12:42:14 +01:00
Asim Aslam
2b79910ad9 add logging and don't get nodes where they exist in router (#1898)
* add logging and don't get nodes where they exist in router

* add more logging
2020-08-06 11:32:06 +01:00
Asim Aslam
8674dc8e62 Remove precache in favour of just pulling by default 2020-08-06 10:27:58 +01:00
Asim Aslam
b93cd0c964 dont process endpoint unless absolutely necessary 2020-08-05 18:09:04 +01:00
Asim Aslam
39bd6a6ced skip watching routes if client proxy is set, remove later 2020-08-05 18:05:25 +01:00
Asim Aslam
03d47afe47 Fix proxy selector memory leak 2020-08-05 17:38:41 +01:00
ben-toogood
38ec233350 proxy/mucp: don't lookup routes if client using proxy (#1896) 2020-08-05 12:45:56 +01:00
Dominic Wong
eee91ed976 Check chan not closed before sending updates for memory loader (#1894)
* dont send on closed chan
2020-08-04 16:21:03 +01:00
ben-toogood
07fef9fd33 router/registry: fix initialization bug (#1893) 2020-08-04 11:43:01 +01:00
Asim Aslam
1106f1d996 remove agent 2020-08-04 07:51:10 +01:00
Asim Aslam
8e126e4fc1 Remove go-micro/web 2020-08-04 07:47:20 +01:00
Asim Aslam
1439b101ec ensure register ttl and interval are set 2020-08-03 22:44:29 +01:00
Asim Aslam
24e5b2a034 Merge branch 'master' of ssh://github.com/micro/go-micro 2020-08-03 22:21:13 +01:00
Asim Aslam
971a962894 Fix typo 2020-08-03 22:20:30 +01:00
ben-toogood
31ed4aa0e8 registry/etcd: fix logging nil pointer dereference (#1889)
* registry/etcd: fix logging nil pointer dereference

* Fix stupid mistake

* Fix merge
2020-07-31 15:05:32 +01:00
ben-toogood
d2cea4b7b7 registry/etcd: fix logging nil pointer dereference (#1888) 2020-07-31 14:40:11 +01:00
ben-toogood
0b73d411ad client: rename WithServiceToken => WithAuthToken (#1887) 2020-07-31 11:36:33 +01:00
ben-toogood
83a64797fb Fix proxy being overriden by default addresses (#1886) 2020-07-31 08:55:08 +01:00
ben-toogood
e9fc5b1671 client: add proxy option (#1885)
* client: add proxy option

* client: add WithProxy CallOption

* use address option

* ProxyAddress => Proxy
2020-07-30 15:22:36 +01:00
ben-toogood
006bbefaf3 runtime: support for dynamic secrets (#1861)
* runtime: replace CreateCredentials with CreateSecret

* runtime/kubernetes: secrets support

* runtime: CreateSecret => WithSecret

* runtime: use map[string]string for secrets

* runtime/kubernetes: update to use kv secrets

* Fix merge conflict (missing import)

Co-authored-by: Asim Aslam <asim@aslam.me>
2020-07-29 13:41:50 +01:00
Lars Lehtonen
3d1ba914fc tunnel: remove unused test loop (#1878)
Co-authored-by: Asim Aslam <asim@aslam.me>
2020-07-29 12:51:09 +01:00
yu
d66803a136 fix bug https://github.com/micro/go-micro/issues/1883 (#1884)
* fix #1883

* fix #1883

Co-authored-by: 杨羽 <yangyu@doumi.com>
2020-07-29 12:45:25 +01:00
ben-toogood
9813f98c8b config: remove default config (#1882)
Co-authored-by: Asim Aslam <asim@aslam.me>
2020-07-28 13:54:58 +01:00
c6163bb22f fix qson parsing on invalid input, close #1874 (#1880)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-07-28 12:34:50 +01:00
ben-toogood
cb4a2864da router/registry: fix not started bug (#1877) 2020-07-28 09:01:08 +01:00
Asim Aslam
f17e4fdb44 Update README.md (#1876) 2020-07-27 16:42:50 +01:00
Asim Aslam
563768b58a v3 refactor (#1868)
* Move to v3

Co-authored-by: Ben Toogood <bentoogood@gmail.com>
2020-07-27 13:22:00 +01:00
Dominic Wong
9dfeb98111 cockroach typo in init (#1872) 2020-07-27 10:16:40 +01:00
Asim Aslam
5f4491bb86 change network resolver http to localhost:8080 2020-07-26 11:21:57 +01:00
Janos Dobronszki
fbdf1f2c1c Fixing micro logs being follow by default against k8s (#1866) 2020-07-23 09:50:38 +02:00
ben-toogood
a3a7434f2c client/grpc: fix error panic (#1860) 2020-07-20 10:04:51 +01:00
Asim Aslam
592179c0a2 Remove deprecations since next release is v3 2020-07-19 19:59:33 +01:00
Asim Aslam
9b74bc52d6 Move defaults to defaults.go 2020-07-19 19:48:11 +01:00
Asim Aslam
05f3e1a125 Add cmd.Run function 2020-07-19 18:43:33 +01:00
Asim Aslam
16c591d741 call cmd.Run 2020-07-19 18:20:17 +01:00
Asim Aslam
755b816086 Use Run instead of Init for cmd 2020-07-19 18:14:18 +01:00
Asim Aslam
7aa92fa8b5 add String method to command 2020-07-19 17:20:05 +01:00
ijayer
5077683b70 refactor(logger): fix the name of defaultLogger receiver (#1859)
Closes #1858

Co-authored-by: Asim Aslam <asim@aslam.me>
2020-07-19 16:55:50 +01:00
Asim Aslam
7f6cefd9c9 fix grpc test 2020-07-19 15:54:33 +01:00
Asim Aslam
647ce61dec some renaming of types in auth 2020-07-19 14:41:31 +01:00
Asim Aslam
d3326efd4b Move out the token package to util 2020-07-19 13:41:23 +01:00
Asim Aslam
6920677f1e Move rules.Verify to auth.VerifyAccess 2020-07-19 13:12:03 +01:00
Asim Aslam
1838e4a1ee remove auth provider 2020-07-19 11:37:40 +01:00
Asim Aslam
96233b2d9b auth jwt / service package comments 2020-07-19 10:53:38 +01:00
Asim Aslam
e082ac42a0 go fmt 2020-07-19 10:51:16 +01:00
Asim Aslam
d7ef224447 add selector package comment 2020-07-19 10:51:04 +01:00
Asim Aslam
8c6f4062ef Remove error proto in favour of go type 2020-07-19 09:29:48 +01:00
ben-toogood
0d860c53a6 runtime/kubernetes: ignore namespace already exists errors (#1852)
Co-authored-by: Asim Aslam <asim@aslam.me>
2020-07-18 11:12:05 +01:00
bcc890e47c router: pass node metadata to route instead of service metadata (#1855)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-07-17 16:45:22 +01:00
Di Wu
f9bf562393 fix typo in comments (#1840)
* remove global error tracking

* rpc_server: fix invalid register err

* fix typo

Co-authored-by: Asim Aslam <asim@aslam.me>
2020-07-16 16:33:11 +01:00
dfa50a888d make LookupRoute exported (#1850)
* make LookupRoute exported

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* add missing file

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-07-16 16:32:37 +01:00
Asim Aslam
e63b9015ae Add memcache implementation of cache (#1848) 2020-07-16 14:13:38 +01:00
3627e47f04 client/grpc: dont use codec for raw bytes payload (#1847)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-07-16 13:35:06 +01:00
Asim Aslam
7d41c2224e Don't close the stream (#1844) 2020-07-15 14:44:31 +01:00
ben-toogood
68927e875b store/service: use client passed in Init options (#1843) 2020-07-15 14:01:33 +01:00
ben-toogood
0c19a87c89 cmd/cmd: use service namespace as store database (#1842) 2020-07-15 11:31:42 +01:00
ben-toogood
f73ec65ac3 runtime/kubernetes: increase debugging (#1841) 2020-07-15 09:26:25 +01:00
Asim Aslam
b27e71ae64 rip out cmd.DefaultOptions 2020-07-14 22:23:54 +01:00
Asim Aslam
0299517f0d remove config readme 2020-07-14 21:55:05 +01:00
Asim Aslam
e1404a1100 remove secrets package 2020-07-14 21:53:43 +01:00
Asim Aslam
057d61063f Move back command 2020-07-14 20:57:13 +01:00
ben-toogood
73a3f596e8 util/kubernetes/client: set imagePullPolicy to always (#1838) 2020-07-14 15:17:23 +01:00
ben-toogood
0287ab8751 auth/service/proto: add Delete RPC (#1836)
Co-authored-by: Asim Aslam <asim@aslam.me>
2020-07-14 13:41:35 +01:00
Alex Unger
42c28f2b6d Fix Comments (#1833)
* update store url

* fix leftover copy paste
2020-07-14 13:13:32 +01:00
ben-toogood
a2bb0bea2d auth: add token issuer option (#1835) 2020-07-14 13:44:51 +02:00
ben-toogood
9f9c748f9b auth/service: fix account issuer bug (#1834) 2020-07-14 12:16:52 +01:00
ben-toogood
a5e9dc21ca util/wrapper: allow enforcing a specific namespace when verifying requests (#1832)
* auth/jwt: add debugging

* auth: more debugging

* auth: more debugging

* util/wrapper: don't use request context

* util/wrapper: AuthHandlerNamespace

* remove debugging
2020-07-14 10:27:15 +01:00
Janos Dobronszki
3f4b58b58c Let bolt do locking per each List Get etc op, instead of managing fil… (#1831) 2020-07-14 10:35:46 +02:00
Asim Aslam
0a79db498c do not compare snapshot unless non nil (#1830) 2020-07-14 07:52:45 +01:00
Dominic Wong
7c5e3b0f30 report errors from log streaming (#1828) 2020-07-13 17:35:23 +01:00
ben-toogood
07fbb06ed8 auth/service: fix jwt blank refresh bug (#1827) 2020-07-13 17:12:03 +01:00
ben-toogood
a4252ba69c router/registry: use warn error level (#1826) 2020-07-13 15:27:14 +01:00
ben-toogood
8fe4f1f2c3 config/cmd: don't fatally error if config can't be loaded (#1825)
* config/cmd: don't fatally error if config cannot be loaded

* config/cmd: fix log level typo
2020-07-13 15:08:53 +01:00
ben-toogood
2e04fcd718 config/cmd: don't fatally error if auth account cannot be generated (#1824) 2020-07-13 12:52:54 +01:00
ben-toogood
7355455020 auth/service: generate accounts client side if JWT credentials present (#1823) 2020-07-13 10:20:31 +01:00
Lars Lehtonen
040577fb74 transport/grpc: replace deprecated grpc.WithTimeout() (#1822) 2020-07-13 07:35:53 +01:00
ben-toogood
4e7621da18 config/cmd: standardise error handling (#1816)
* runtime/kubernetes: remove reference to runtime cells

* config/cmd: standardize error handling

Co-authored-by: Asim Aslam <asim@aslam.me>
2020-07-12 07:22:08 +01:00
Huan Huang
8e30ede8c7 track error (#1815)
* track error

* remove useless code

Co-authored-by: huanghuan.27@bytedance.com <huanghuan.27@bytedance.com>
Co-authored-by: Asim Aslam <asim@aslam.me>
2020-07-12 07:17:56 +01:00
Asim Aslam
630ceb5dad Update README.md (#1820) 2020-07-11 22:18:53 +01:00
Asim Aslam
85ae232936 Add model to service (#1819) 2020-07-11 21:15:59 +01:00
ben-toogood
13ea0eec02 :registry/mdns: fix nil pointer bug (#1818) 2020-07-10 17:47:07 +01:00
ben-toogood
09ec20fded runtime: provide credentials to services (#1817)
* runtime: inject credentials into service

* util/auth: self generate accounts (needed for jwt)

* runtime/kubernetes: add logging for creds

* runtime/kubernetes: serialize secret name

* runtime/kubernetes: remove unused code

* runtime/kubernetes: base64 encode secret

* runtime/kubernetes: remove metadata from secret

* util/kubernetes/client: omit empty secret metadata

* util/kubernetes/client: fix secret template

* util/kubernetes/client: fix secrets

* web: update auth util

* util/auth: fix missing arg

* extend token expiry

* extend token expiry
2020-07-10 16:25:46 +01:00
ben-toogood
3480e0a64e runtime/kubernetes: remove reference to runtime cells (#1814) 2020-07-09 20:21:34 +01:00
ben-toogood
318a80f824 config/cmd: improve cert loading for infra (#1813)
* config/cmd: improve cert loading for infra

* config/cmd: remove certificate_authorities flag

* config/cmd: fix caps

* config/cmd: fix bug with IsSet

* config/cmd: fix bool flags
2020-07-09 18:02:24 +01:00
ben-toogood
6d9a38a747 kubernetes: fixes for production (#1812)
* util/kubernetes/client: add secrets to deployments

* util/kubernetes/client: remove ServiceAccountName override

* debugging

* runtime/kubernetes: fix error

* runtime/kubernetes: remove test secret

* util/kubernetes/client: update default image

* util/kubernetes/client: remove default command for deployments

* runtime/kubernetes: pass source as arg

* runtime/kubernetes: remove debugging

* util/kubernetes/client: revert default image change
2020-07-09 16:29:01 +01:00
Asim Aslam
58d6726380 The start of mud - the micro data model (#1811)
* The start of mud - the micro data model

* add comments
2020-07-09 12:11:32 +01:00
Huan Huang
e5db6ea8a7 close r/w (#1810)
Co-authored-by: huanghuan.27@bytedance.com <huanghuan.27@bytedance.com>
2020-07-09 10:28:20 +01:00
Huan Huang
3468331506 feat: refactor register func (#1807)
Co-authored-by: huanghuan.27@bytedance.com <huanghuan.27@bytedance.com>
Co-authored-by: Asim Aslam <asim@aslam.me>
2020-07-08 18:38:01 +01:00
王旭
1bac08cc0e server.Init(Wait(nil)) update server options context (#1804)
Co-authored-by: wangxu <wangxu@oneniceapp.com>
Co-authored-by: Asim Aslam <asim@aslam.me>
2020-07-08 18:36:07 +01:00
ben-toogood
333320dcb8 config/cmd: secure broker (#1806)
* config/cmd: secure broker

* config/cmd: remove testing
2020-07-08 16:22:48 +01:00
Asim Aslam
ce12c040fa Model updates 2020-07-08 15:09:18 +01:00
Asim Aslam
ee36e26edc Add model interface (#1808) 2020-07-08 14:57:45 +01:00
Asim Aslam
3ffb899951 Fix cache options 2020-07-08 14:53:38 +01:00
Asim Aslam
00bd2bc65f cache interface (#1805) 2020-07-08 11:08:59 +01:00
ben-toogood
86f4235aaf config/cmd: custom certificate authorities & secure registry (#1803)
* config/cmd: add registry_secure option

* config/cmd: tmp load ca

* config/cmd: tmp load ca

* config/cmd: refactor certificate_authorities setup

* config/cmd: improve usage
2020-07-08 08:50:08 +01:00
Di Wu
b37f9c94b8 Fix invalid register check err in log (#1801)
* remove global error tracking

* rpc_server: fix invalid register err

Co-authored-by: Asim Aslam <asim@aslam.me>
2020-07-07 14:14:23 +01:00
Asim Aslam
0ed1c70d29 Update README.md 2020-07-07 13:34:42 +01:00
Asim Aslam
db8e10834b Update README.md (#1802) 2020-07-07 13:33:54 +01:00
ben-toogood
0a937745cd auth: pass namespace options in auth service requests (#1800)
* auth: pass namespace options in auth service requests

* auth/service/proto: update field index

Co-authored-by: Asim Aslam <asim@aslam.me>
2020-07-07 08:30:25 +01:00
ben-toogood
f5ed7e5833 config/source/service: change default namespace to micro (#1798)
Co-authored-by: Asim Aslam <asim@aslam.me>
2020-07-07 08:19:52 +01:00
Metauro
859b9e7786 feat(errors): add gateway, service error (#1797) 2020-07-06 20:14:59 +01:00
Lars Lehtonen
2b033b6495 store/cockroach: fix dropped errors (#1796)
Co-authored-by: Asim Aslam <asim@aslam.me>
2020-07-06 20:14:36 +01:00
Di Wu
51caf2a24e remove global error tracking (#1777)
Co-authored-by: Asim Aslam <asim@aslam.me>
2020-07-06 20:14:22 +01:00
Enix Yu
eaa46c2de7 Add recover in grpc service handler (#1727)
* 🐛 bug(grpc): add missing recover in grpc unkonwn service handler

* Add grpc handler recover testcases

* improve test case

Co-authored-by: ben-toogood <bentoogood@gmail.com>
Co-authored-by: Asim Aslam <asim@aslam.me>
2020-07-06 20:13:51 +01:00
Colin Hoglund
90dca65f55 make environment variable interpolation preprocessor optional (#1715) 2020-07-06 20:13:35 +01:00
97ae2979ad pass request context from request rpc endpoints (#1799)
http middleware can add additional metadata to context,
for example tracing wrappers, pass down it to underlining
services

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-07-06 13:55:17 +01:00
Asim Aslam
6f309dada3 fix typo (#1789) 2020-07-06 13:52:42 +01:00
Huan Huang
f99b436ec2 feat: fix register bug (#1791) 2020-07-03 14:38:25 +01:00
ben-toogood
c817f29d6e router/registry: fix registry not found bug (#1794) 2020-07-03 13:35:59 +01:00
ben-toogood
f744c6248f runtime/service: pass namespace option to service (#1792) 2020-07-03 11:37:14 +01:00
ben-toogood
4ff114e798 router/registry: fix rlock bug when registry errors (#1788)
* client: add select options

* router/registry: fix rlock bug when registry errors

* Revert "client: add select options"

This reverts commit 4d5283452e183f7387b604b51bde1deaf87ee391.

* router/registry: findRoutes under rlock

* add test

Co-authored-by: Dominic Wong <dom@micro.mu>
2020-07-02 18:29:11 +01:00
ben-toogood
c58ac35dfc broker/service: use wrapped micro client to authenticate requests (#1782) 2020-07-02 17:54:53 +01:00
ben-toogood
b5314829fa client/{grpc,rpc}: fix previous breaking change with CallFunc (router.Route vs registry.Node) (#1781) 2020-07-02 17:26:45 +01:00
ben-toogood
41c7688697 options: add router option (#1783)
* broker/service: use wrapped micro client to authenticate requests

* options: add router option

* Revert "broker/service: use wrapped micro client to authenticate requests"

This reverts commit f2383f37c86467b4ce534313a7f59993a904a712.
2020-07-02 17:17:07 +01:00
ben-toogood
b021546c09 client: add select options (#1786) 2020-07-02 17:03:08 +01:00
ben-toogood
6898a65508 selector: add filters to replace depricated client/selector filters (#1785) 2020-07-02 16:09:48 +01:00
ben-toogood
d577dd6abe config: add namespace support (#1780)
* config/cmd: use service namespace for config

* config/service: add namespace option to list
2020-07-02 14:07:58 +01:00
Janos Dobronszki
3c633e3577 Sparse checkout of repos, all repo downloads happen to different folders for concurrency support (#1779) 2020-07-02 14:40:40 +02:00
ben-toogood
174e44b846 Deprecate client/selector (#1767)
* client/{grpc,rpc}: depricate selector (wip)

* {client,cmd}: remove client/selector

* deprecate client/selector

* router/static: fix lookup

* config/cmd: add support for legacy static selector flag

* config/cmd: add support for legacy dns selector flag
2020-07-01 17:06:59 +01:00
Dominic Wong
a63480a81a router/registry: fix fallback fails if service has been seen already (#1776) 2020-07-01 15:20:30 +01:00
ben-toogood
6d9d94b105 api/router/registry: use resolved domain (#1774) 2020-07-01 12:23:55 +01:00
ben-toogood
64e9185386 router/registry: fix nil eventChan bug (#1773)
* router/registry: fix nil eventChan bug
2020-07-01 12:03:13 +01:00
ben-toogood
1b5c83f3cc registry/mdns: fix deregister bug (#1771)
* registry/mdns: fix deregister bug

* Update registry/mdns_registry.go

Co-authored-by: Dominic Wong <domwongemail@googlemail.com>
2020-07-01 11:09:20 +01:00
ben-toogood
979af853b9 proxy/mucp: use Micro-Namespace to filter networks (#1772) 2020-07-01 10:55:46 +01:00
ben-toogood
a64078b5c3 router/service: handle not found error (#1770) 2020-07-01 10:18:19 +01:00
Dominic Wong
58845d7012 only prewarm the route table if requested (#1765) 2020-07-01 10:05:21 +01:00
ben-toogood
dcf01ebbf0 router/registry: fix concurrent map iteration and map write (#1762) 2020-06-30 17:40:38 +01:00
Dominic Wong
355ad2a1af push tags to docker hub (#1766) 2020-06-30 17:26:59 +01:00
ben-toogood
b882ff3df9 selector: update selector.Select to accept a slice of structs (#1764) 2020-06-30 15:51:26 +01:00
ben-toogood
6337c92cd0 selector: new selector interface with random & roundrobin implementation (#1761)
* selector: implement new selector interface plus random & roundrobin implementations

* selector/roundrobin: remove unused consts

* router: add close method to interface

* selector/roundrobin: fix concurrent map iteration and map write

* selector: replace variadic argument on Select
2020-06-30 14:54:38 +01:00
ben-toogood
a95accad56 router: add metadata to routes (#1763)
* router: add metadata to route

* router/registry: set node metadata in route

* router/service: pass metadata to/from router service
2020-06-30 14:10:13 +01:00
Dominic Wong
6532b6208b MDNS registry fix for users on VPNs (#1759)
* filter out unsolicited responses
* send to local ip in case
* allow ip func to be passed in. add option for sending to 0.0.0.0
2020-06-30 11:12:52 +01:00
ben-toogood
0f5c53b6e4 selector: use custom domain (#1760)
* util/wrapper: improve auth errors

* client: add network call option

* client/selector: add domain select option

* client/grpc: pass network option to selector
2020-06-30 10:07:52 +01:00
ben-toogood
deea8fecf4 router/registry: add fallback if routes aren't found in the cache (#1758)
* router/registry: add fallback if routes aren't found in the cache

* router: fix rlock bug

* router/registry: pass fetchRoutes into the table, not the router
2020-06-30 09:53:49 +01:00
ben-toogood
df3e5364ca api/resolver: add resolve options (#1756)
* api/resolver: Resolve options

* router/registry: fix init bug

* router/registry: fix wildcard query bug

* web: fix registation domain bug

* registry/etcd: pass domain in service metadata

* api/resolver/subdomain: expose domain func

* Update api/resolver/subdomain/subdomain.go

Co-authored-by: Dominic Wong <domwongemail@googlemail.com>

Co-authored-by: Dominic Wong <domwongemail@googlemail.com>
2020-06-29 16:37:45 +01:00
Di Wu
132c1e35fe Fix invalid usage for sync.WaitGroup (#1752)
* Custom private blocks

* Fix invalid usage for sync.WaitGroup

Co-authored-by: Asim Aslam <asim@aslam.me>
2020-06-27 20:07:04 +01:00
Dominic Wong
5967a68e78 cached file store (#1739)
* cached file store
2020-06-26 16:13:53 +01:00
ben-toogood
104b7d8f8d api/resolver: update resolver to enable subdomain routing (#1747)
* api/resolver: update domain / service prefix usage

* api/resolver/subdomain: implement subdomain resolver for domain resolution

* api/handler: fix tests
2020-06-26 14:28:18 +01:00
ben-toogood
4f0f4326df router: improve router configuration (#1745)
* router: update default address to :8084

* service: add router to service options

* config/cmd: improve router setup
2020-06-26 10:38:11 +01:00
ben-toogood
ee02511658 proxy/mucp: add support for multi-tenancy (#1746) 2020-06-26 10:31:06 +01:00
ben-toogood
a8fc5590a8 client/selector: query across multiple domains (#1725)
* client/selector: query across multiple domains

* client/selector: check for nil services

* config/cmd: fix merge bug
2020-06-25 15:40:23 +01:00
ben-toogood
bc60f23ff6 config/cmd: setup registry before router (#1743) 2020-06-25 15:24:31 +01:00
ben-toogood
2000da6fd8 router/registry: add support for registry domains (#1744) 2020-06-25 12:35:00 +01:00
ben-toogood
5ab475636a server/{grpc,rpc}: fix deregister domain bug (#1742)
* server/{grpc,rpc}: fix deregister domain bug

* server/grpc: remove unnecessary slice
2020-06-25 11:25:43 +01:00
ben-toogood
51b4ab0abc registry/memory: watcher bug fixes (#1740)
* registry/memory: watcher bugfixes

* registry/memory: fix nil watcher bug

* registry/memory: fix watcher test
2020-06-25 11:02:35 +01:00
ben-toogood
687a5e2e58 util/wrapper: fix 401 error when requesting the default namespace (#1741) 2020-06-25 10:19:03 +01:00
Dominic Wong
fcd307d902 Build and test forked PRs properly (#1738)
* build forks on PRs properly
2020-06-24 23:41:27 +01:00
ben-toogood
00cd07a3a6 util/wrapper: set auth credentials on streams (#1735) 2020-06-24 16:45:34 +01:00
Dominic Wong
a2a1f4dfbd support mono repo deps (#1736)
* support mono repo deps

* add protoc
2020-06-24 16:27:22 +01:00
ben-toogood
2b506b1a2a auth/service: use address option since router may not be configured (#1734) 2020-06-24 13:47:43 +01:00
ben-toogood
a2550820d3 router: add to service options; add dns and static implementations (#1733)
* config/cmd: add router to service options

* router/service: use micro client
2020-06-24 11:46:51 +01:00
ben-toogood
c940961574 router: update interface (#1732)
* router: replace Start and Stop with Close

* router: update default network to micro

* router: update tests
2020-06-24 11:09:16 +01:00
Dominic Wong
695cc9d526 Build against micro and examples on pull requests (#1724)
* Build against micro and examples on pull requests
2020-06-19 17:19:58 +01:00
ben-toogood
87543b2c8a registry/etcd: add support for domain options (#1714) 2020-06-19 14:58:16 +01:00
ben-toogood
5f9c3a6efd registry/cache: add support for the domain option (#1722) 2020-06-19 13:16:44 +01:00
ben-toogood
2b889087bd config/cmd: fix selector setup bug (#1723) 2020-06-19 13:11:48 +01:00
ben-toogood
ece02a6d21 util/wrapper: fix noop auth nil account bug (#1721)
* util/wrapper: fix noop nil account

* util/wrapper: improve comments

* util/wrapper: update tests
2020-06-19 12:16:39 +01:00
ben-toogood
58c6bbbf6b registry/service: pass domain options via rpc (#1719)
* registry/service: regenerate proto

* registry/service: pass domain in proto request options

* registry/service: stop defaulting metadata

* registry: add default domain const; remove from implementations

* registry/memory: fix typo
2020-06-19 10:34:12 +01:00
ben-toogood
c16f4b741c server: register in the services namespace (#1718) 2020-06-19 09:24:32 +01:00
Colin Hoglund
83cecdb294 config: use configured reader by default (#1717) 2020-06-19 08:49:30 +01:00
ben-toogood
8c7c27c573 registry/memory: add support for domain options (#1713)
* registry/memory: add support for the domain options

* registry/memory: swap Fatal test cases with Error

* registry/memory: fix wildcard not found bug

* registry/memory: replace locks with rlocks

* registry/memory: fix deregistration bug
2020-06-18 12:39:19 +01:00
ben-toogood
5fd36d6cc0 config/cmd: remove package duplicate initialization (#1711) 2020-06-18 10:14:04 +01:00
ben-toogood
3b40fde68b registry/mdns: add domain support (#1708)
* registry: add domain options

* registry/mdns: implement domain options

* registry/mdns: return node domain in metadata when querying using wildcard

* Fix nil pointer exception

* registry/mdns: return error from deregister

* registy/mdns: rename tld => domain
2020-06-17 13:23:41 +01:00
ben-toogood
9d3365c4be auth: rename auth.Namespace to auth.Issuer (#1710) 2020-06-17 12:26:27 +01:00
sunfuze
2efb459c66 Fix config watch (#1670)
* add dirty overrite test case

* need version to figure out if config need update or not

* using nanosecond as version for two goroutine can run in same second

* config should check snapshot version when update

* set checksum of ChangeSet

Co-authored-by: Asim Aslam <asim@aslam.me>
2020-06-16 17:10:52 +01:00
Di Wu
6add74b4f6 Custom private blocks (#1705)
Co-authored-by: Asim Aslam <asim@aslam.me>
2020-06-16 17:05:42 +01:00
Dominic Wong
c67d78f1ef update PR template, not using gitflow anymore 2020-06-16 17:00:15 +01:00
Dominic Wong
a89610ffea Merge pull request #1706 from micro/develop
Develop -> Master. Abandoning gitflow model
2020-06-16 16:57:40 +01:00
Dominic Wong
da9bb11240 Merge branch 'master' into develop 2020-06-16 16:52:24 +01:00
Dmitry Kozlov
a3a1a84172 Split long discord output message into the chunks by 2000 characters (#1704)
Signed-off-by: Dmitry Kozlov <dmitry.f.kozlov@gmail.com>
2020-06-15 22:22:00 +01:00
ben-toogood
1179d7e89a registry/mdns: fix nil host bug (#1703) 2020-06-15 16:13:45 +01:00
Asim Aslam
a5df913926 Update README.md (#1695) 2020-06-12 15:07:19 +01:00
Asim Aslam
9ce706191b Update FUNDING.yml (#1692) 2020-06-12 15:07:19 +01:00
Dominic Wong
0327f30e3c Fix regex detection. Fixes #1663 (#1696) 2020-06-12 10:42:52 +01:00
Dominic Wong
0ce132eb8f Fix race condition when updating process being waited on (#1694) 2020-06-12 10:42:52 +01:00
Janos Dobronszki
00b76e0a64 Initialize selector before we make an auth.Generate call (#1693) 2020-06-12 10:42:52 +01:00
Dominic Wong
aec27be9b4 Fix race when opening DB for first time (#1691) 2020-06-12 10:42:52 +01:00
Dominic Wong
86dfcb819b Ignore "no such process" error (#1686)
* Cleanup how status is updated for service. Ignore "no such process" error as it could be that the pid died

* add nice error log to record process error exit
2020-06-12 10:42:52 +01:00
Janos Dobronszki
d613804b0a Sigterm instead of Sigkill (#1687)
Co-authored-by: Dominic Wong <domwongemail@googlemail.com>
Co-authored-by: Asim Aslam <asim@aslam.me>
2020-06-12 10:42:52 +01:00
92e9d05432 api/handler/rpc: dont log error on normal websocket error code (#1688)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-06-12 10:42:52 +01:00
ben-toogood
8dfd93e915 util/wrapper: Add Static Client wrapper (#1685)
* util/wrapper: Add Static Client wrapper

* util/wrapper/static: pass address to stream too

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* add static client wrapper tests

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* server: fix error message spaces between words

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* server/{rpc,grpc}: replace log.Error with log.Errorf

* server/grpc: fix log typo

* server/rpc: fix log typo

Co-authored-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-06-12 10:42:52 +01:00
Dominic Wong
e5136332e3 Add build and test of micro to pre-release testing (#1684)
* fix up example test build

* build and test micro when cutting a new release
2020-06-12 10:42:52 +01:00
Dominic Wong
f10fd4b479 Build all micro/examples for release-X.X.X branches (#1683)
* Build all the examples on push to any release branch
2020-06-12 10:42:52 +01:00
ben-toogood
74368026a5 Fix incorrect namespace variable name (merge conflict) (#1677) 2020-06-12 10:42:52 +01:00
ben-toogood
fde1aa9d6a Move auth account creation to config/cmd (#1676) 2020-06-12 10:42:52 +01:00
ben-toogood
f45cdba9ba Apply wrappers to gRPC streams (#1675)
* Add wrappers to grpc streams

* Fix typo
2020-06-12 10:42:52 +01:00
Dominic Wong
73c2f25935 Fix regex detection. Fixes #1663 (#1696) 2020-06-10 11:18:03 +01:00
Asim Aslam
b270860b79 Update README.md (#1695) 2020-06-10 10:22:53 +01:00
Dominic Wong
8e81cea96f Fix race condition when updating process being waited on (#1694) 2020-06-10 09:36:41 +01:00
Janos Dobronszki
cdd8f9fd82 Initialize selector before we make an auth.Generate call (#1693) 2020-06-09 12:47:31 +02:00
Asim Aslam
e7ba930236 Update FUNDING.yml (#1692) 2020-06-08 18:12:19 +01:00
Dominic Wong
a346064eaf Fix race when opening DB for first time (#1691) 2020-06-08 16:19:22 +01:00
Dominic Wong
47bdd5c993 Ignore "no such process" error (#1686)
* Cleanup how status is updated for service. Ignore "no such process" error as it could be that the pid died

* add nice error log to record process error exit
2020-06-08 10:47:25 +01:00
Janos Dobronszki
9af12ff9df Sigterm instead of Sigkill (#1687)
Co-authored-by: Dominic Wong <domwongemail@googlemail.com>
Co-authored-by: Asim Aslam <asim@aslam.me>
2020-06-06 14:04:14 +01:00
6c7bcf3883 api/handler/rpc: dont log error on normal websocket error code (#1688)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-06-06 00:03:43 +03:00
ben-toogood
bbc3b7040b util/wrapper: Add Static Client wrapper (#1685)
* util/wrapper: Add Static Client wrapper

* util/wrapper/static: pass address to stream too

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* add static client wrapper tests

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* server: fix error message spaces between words

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* server/{rpc,grpc}: replace log.Error with log.Errorf

* server/grpc: fix log typo

* server/rpc: fix log typo

Co-authored-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-06-05 10:18:35 +01:00
Dominic Wong
582f2e8b94 Add build and test of micro to pre-release testing (#1684)
* fix up example test build

* build and test micro when cutting a new release
2020-06-04 13:46:22 +01:00
Dominic Wong
bd3ef67328 Build all micro/examples for release-X.X.X branches (#1683)
* Build all the examples on push to any release branch
2020-06-04 09:32:17 +01:00
Dominic Wong
1ccd4cd940 Merge branch 'master' into develop 2020-06-03 10:41:39 +01:00
Dominic Wong
aa679f7a73 Create PULL_REQUEST_TEMPLATE.md 2020-06-03 10:32:28 +01:00
ben-toogood
003731ace9 Fix incorrect namespace variable name (merge conflict) (#1677) 2020-06-03 09:48:19 +01:00
Asim Aslam
7b379bf1f1 WIP: Add metadata to store record (#1604)
* Add metadata to store record

* Add metadata to cockroach store

* add metadata to store service implementation

* fix breaking cache test

* Test/fix cockroach metadata usage

* fix store memory metadata bug
2020-06-03 09:45:08 +01:00
ben-toogood
b6f3e8b715 Move auth account creation to config/cmd (#1676) 2020-06-03 09:43:20 +01:00
ben-toogood
8f6ec21b91 Apply wrappers to gRPC streams (#1675)
* Add wrappers to grpc streams

* Fix typo
2020-06-02 17:56:26 +01:00
Dominic Wong
e4e56b0f3f Merge pull request #1671 from sadwxqezc/fix-jwt
Fix jwt revoke
2020-06-02 09:27:14 +01:00
huanghuan.27@bytedance.com
219d29f664 fix jwt revoke 2020-06-02 10:26:33 +08:00
Asim Aslam
8fb138af06 Update README.md 2020-05-31 11:56:55 +01:00
Asim Aslam
a39e6515da Update README.md 2020-05-31 11:35:09 +01:00
Asim Aslam
2c7fd286de Update README.md 2020-05-31 11:34:49 +01:00
Asim Aslam
8aa2712b4d Delete README.zh-cn.md 2020-05-31 11:33:31 +01:00
Asim Aslam
b5c2121cef Update README.md 2020-05-31 11:31:41 +01:00
Asim Aslam
ca9b877646 Update README.md 2020-05-31 11:28:32 +01:00
Asim Aslam
ff49b4fc71 Update README.md 2020-05-31 11:27:54 +01:00
Asim Aslam
222431b57a Update README.md 2020-05-31 11:26:46 +01:00
Asim Aslam
ddb51529a7 Update README.md 2020-05-31 11:26:18 +01:00
Asim Aslam
7c048f331a Update README.md 2020-05-31 11:21:55 +01:00
Asim Aslam
8475183bbb Update README.md 2020-05-31 11:19:26 +01:00
Asim Aslam
10f35db3ed Update README.md 2020-05-31 11:16:20 +01:00
Asim Aslam
b68af8ab63 run go fmt 2020-05-30 11:00:43 +01:00
Asim Aslam
266602a3d6 Update README.md 2020-05-30 10:59:59 +01:00
mlboy
15d5142d9b fix: misspell (#1667) 2020-05-29 17:49:22 +01:00
Máximo Cuadros
0d88650511 go modules cleanup and remove wrong self import to v1 (#1658)
* Runtime local git, simply go-git code
* go modules cleanup and remove wrong self import to v1
* pin mergo v0.3.8 to avoid panics

Signed-off-by: Máximo Cuadros <mcuadros@gmail.com>
Co-authored-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-05-29 14:32:11 +03:00
Dominic Wong
8660370dc9 Merge pull request #1657 from xpunch/master
logger caller not trim in windows
2020-05-29 10:35:03 +01:00
Dominic Wong
73339dde85 Merge branch 'master' into master 2020-05-29 10:27:20 +01:00
Dominic Wong
3f354f3c30 Merge pull request #1661 from micro/bugfix/sock_pool_threads
fix locking of socket pool
2020-05-28 08:31:47 +01:00
potato
c08eb5f892 Merge branch 'master' into master 2020-05-28 10:19:53 +08:00
Dominic Wong
27e41c4ad5 fix locking of socket pool 2020-05-27 20:18:26 +01:00
Dominic Wong
1da8a640da Merge pull request #1660 from micro/bugfix/mdns_nil_host
Check ipv4 or ipv6 address is valid before assigning
2020-05-27 15:53:27 +01:00
Dominic Wong
e7ad031eb8 Check ipv4 or ipv6 address is valid before assigning 2020-05-27 15:47:12 +01:00
ben-toogood
192f548c83 Merge pull request #1659 from micro/config-srv-not-found
Handle config service not found errors
2020-05-27 12:24:33 +01:00
Ben Toogood
d85b4197b4 Return nil changeset and not blank 2020-05-27 12:20:31 +01:00
Ben Toogood
bb5f2e5525 Handle config service not found errors 2020-05-27 12:12:34 +01:00
ben-toogood
f00b696282 Merge pull request #1654 from micro/auth-scopes
Auth Improvements
2020-05-27 10:52:07 +01:00
Ben Toogood
e2d662608c Fix tests 2020-05-27 09:14:16 +01:00
Ben Toogood
9e9773c9c7 Only use namespace for cache key 2020-05-27 09:07:59 +01:00
potato
2f8e2487f7 Merge branch 'master' into master 2020-05-27 09:32:27 +08:00
Ben Toogood
d6c1fbf841 Fix web service auth name 2020-05-26 17:43:45 +01:00
Ben Toogood
c3b404bab0 Fix server calling across namespace 2020-05-26 17:35:06 +01:00
Ben Toogood
cd283654eb Cache Rules 2020-05-26 15:53:28 +01:00
Ben Toogood
5712cc9c62 Merge master 2020-05-26 15:52:21 +01:00
ben-toogood
be5a10a4d4 Merge pull request #1656 from micro/client-cache
Client Cache
2020-05-26 15:38:30 +01:00
Ben Toogood
b53a2c67f1 Merge branch 'master' of https://github.com/micro/go-micro into auth-scopes 2020-05-26 15:37:31 +01:00
johnson
cc79692d68 make caller filepath package/file style
this code is from zap
9a9fa7d4b5/zapcore/entry.go (L101)
2020-05-26 14:33:56 +08:00
potato
796a598b37 Merge pull request #7 from micro/master
go micro v2
2020-05-26 14:18:25 +08:00
Ben Toogood
73b4423682 Merge branch 'master' of https://github.com/micro/go-micro into client-cache 2020-05-24 20:36:22 +01:00
Ben Toogood
198e942889 Remove redundant test 2020-05-24 20:32:22 +01:00
Ben Toogood
95703e4565 Fixes and improved test coverage 2020-05-24 20:26:37 +01:00
Ben Toogood
2729569f66 Add Debug.Cache method 2020-05-24 18:45:57 +01:00
Ben Toogood
67146ecdc2 Client Cache tests 2020-05-24 18:05:23 +01:00
Asim Aslam
bd049a51e6 Update README.md 2020-05-23 16:47:23 +01:00
Asim Aslam
ffd89599a0 Update README.md 2020-05-23 16:46:50 +01:00
Ben Toogood
496293afa1 Use hash/fnv, add tests, fix request bug 2020-05-23 11:34:44 +01:00
Ben Toogood
7d7f4046e8 Client Cache 2020-05-22 16:52:24 +01:00
Ben Toogood
c800070477 Check for error before loading rules 2020-05-22 14:03:12 +01:00
Ben Toogood
877fe5fb0a Update web wildcard to enable /foo/bar/baz/* to verify /foo/bar/baz 2020-05-22 14:02:02 +01:00
Ben Toogood
dad011cab4 Fix noop issuer bug 2020-05-22 12:40:34 +01:00
Ben Toogood
f939200b34 Improve service auth log 2020-05-22 12:24:37 +01:00
Ben Toogood
9c072a372c Add auth scope constants 2020-05-22 11:37:12 +01:00
Ben Toogood
fbb91c6cb7 Auth wrapper tests 2020-05-22 10:44:18 +01:00
Ben Toogood
b2cf501952 Auth Rules tests & bug fixes 2020-05-22 09:31:15 +01:00
Ben Toogood
1fce0f02b6 Verify Namespace 2020-05-21 18:11:35 +01:00
Ben Toogood
12061bd006 Add account issuers 2020-05-21 16:41:55 +01:00
Ben Toogood
856c73b341 Remove roles (replaced with scope) 2020-05-21 14:56:17 +01:00
Ben Toogood
4de19805ba Remove redundant test 2020-05-21 12:33:58 +01:00
Ben Toogood
c09b871a6b Merge branch 'master' of https://github.com/micro/go-micro into auth-scopes 2020-05-21 12:32:52 +01:00
Ben Toogood
e876cb917d auth/service support for micro clients (rules from mutltiple namespaces 2020-05-21 12:25:47 +01:00
Ben Toogood
8f5ef012ff Update Rules.Delete proto 2020-05-21 12:07:22 +01:00
Ben Toogood
287992cef3 Fix service => service namespace bug 2020-05-21 11:35:07 +01:00
Ben Toogood
344ce061ce Verify Options 2020-05-20 16:49:52 +01:00
Ben Toogood
5d14970a55 Fix nil account bug 2020-05-20 16:11:34 +01:00
Janos Dobronszki
0615fe825f Auth invalid token fix (#1650) 2020-05-20 16:18:05 +02:00
Asim Aslam
6a661fd08c check if the db conn is nil before doing anything (#1652) 2020-05-20 14:03:38 +01:00
Ben Toogood
f6d9416a9e Add Rule to Auth interface 2020-05-20 11:59:01 +01:00
Asim Aslam
a29676b86a Registration Retry / Interval (#1651)
* Change the default ttl to 90 seconds

* add retries to registration

* Add retry to web register
2020-05-20 11:49:09 +01:00
Ben Toogood
dc10f88c12 Replace auth account.Namespace with account.Scopes 2020-05-19 18:17:17 +01:00
ben-toogood
e61edf6280 Merge pull request #1645 from micro/runtime-multitenancy
Runtime multi-tenancy
2020-05-19 17:06:11 +01:00
ben-toogood
3410a0949b Merge branch 'master' into runtime-multitenancy 2020-05-19 17:00:51 +01:00
Jake Sanders
9216a47724 fix client race (#1647) 2020-05-19 14:44:46 +01:00
ben-toogood
cf37d64819 Merge branch 'master' into runtime-multitenancy 2020-05-19 13:24:35 +01:00
Patrik Lindahl
f0c0f3d4c4 Fixes for #1560 (#1644)
close #1560

This fixes one of the reported data races and also allows for
having a different name on the micro.Service and web.Service.
This makes it possible to discover the two service variants separately.

Co-authored-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-05-19 14:11:26 +03:00
Ben Toogood
c4e3f8c336 Merge branch 'master' of https://github.com/micro/go-micro into runtime-multitenancy 2020-05-19 11:02:40 +01:00
Ben Toogood
8875719619 Default Runtime multi-tenancy 2020-05-19 11:01:06 +01:00
Ben Toogood
c19b349e96 Update runtime.Event struct 2020-05-19 10:14:07 +01:00
Ben Toogood
14155c7e02 Add runtime ErrNotFound 2020-05-19 09:28:00 +01:00
Maarten Bezemer
3d36398818 Fix client RPC stream close mutex (#1643) 2020-05-18 17:22:33 +01:00
Asim Aslam
56a7897c91 update readme 2020-05-17 12:39:20 +01:00
ben-toogood
5efb386224 Merge pull request #1640 from micro/auth/public-rule
Auth: setup a public rule
2020-05-15 10:28:52 +01:00
Ben Toogood
4d2de923cd Auth: setup a public rule 2020-05-15 10:24:30 +01:00
ben-toogood
f64b1468a5 Merge pull request #1639 from micro/registy-not-found
Registry service: return not found error
2020-05-14 19:43:19 +01:00
ben-toogood
56f281002b Merge branch 'master' into registy-not-found 2020-05-14 19:39:43 +01:00
Ben Toogood
0d7250352f Registry service: return not found error 2020-05-14 19:38:56 +01:00
ben-toogood
ef43f01da4 Merge pull request #1638 from micro/registry-addrs-fix
Fix registry address option unused
2020-05-14 18:07:14 +01:00
ben-toogood
c9e5ae6a2b Merge branch 'master' into registry-addrs-fix 2020-05-14 18:03:46 +01:00
Ben Toogood
8a802d8f7a Fix registry address option unused 2020-05-14 18:00:13 +01:00
ben-toogood
331ab3715c Merge pull request #1636 from micro/auth-util
Refactor auth setup to util/auth
2020-05-14 16:15:47 +01:00
Ben Toogood
6b451a2197 Refactor auth setup to util/auth 2020-05-14 16:10:14 +01:00
ben-toogood
b4c0224746 Merge pull request #1635 from micro/auth-fixes
Auth: Move token generation logic out the client wrappers
2020-05-14 14:00:55 +01:00
Ben Toogood
500d793fc4 Merge branch 'auth-fixes' of https://github.com/micro/go-micro into auth-fixes 2020-05-14 13:57:00 +01:00
Ben Toogood
16af265e8b Seperate JWT refresh / access tokens 2020-05-14 13:56:51 +01:00
ben-toogood
b222cf8e13 Merge branch 'master' into auth-fixes 2020-05-14 13:47:26 +01:00
Ben Toogood
f549e20fa2 tidy go mdo 2020-05-14 13:33:11 +01:00
Ben Toogood
83e9c1fad2 Remove unnecessary change 2020-05-14 13:32:42 +01:00
Ben Toogood
c220686c29 Fix token bug 2020-05-14 13:30:21 +01:00
Ben Toogood
1b18730d54 Custom micro client 2020-05-14 11:25:19 +01:00
Ben Toogood
5764519f5b Refactor auth to load token outside wrappers 2020-05-14 11:06:22 +01:00
ben-toogood
957001f8ad Merge pull request #1634 from micro/disable-clients
Disable Clients
2020-05-13 18:54:34 +01:00
Ben Toogood
0955671e45 Merge branch 'disable-clients' of https://github.com/micro/go-micro into disable-clients 2020-05-13 18:49:47 +01:00
Ben Toogood
57b060bac5 Disable Addresses 2020-05-13 18:49:36 +01:00
ben-toogood
3136e1409e Merge branch 'master' into disable-clients 2020-05-13 18:48:24 +01:00
Ben Toogood
ca791d7e8d Disable Clients 2020-05-13 18:47:53 +01:00
Dominic Wong
05858b746c kill all processes correctly for micro kill command (#1633) 2020-05-13 18:36:45 +01:00
ben-toogood
09d1450d7d Merge pull request #1632 from micro/fix-auth-bug
Auth: Fix recursive bug
2020-05-13 18:18:39 +01:00
Ben Toogood
1ca1fd411a Auth: Fix recursive bug 2020-05-13 18:17:04 +01:00
ben-toogood
a2d4d62f1c Merge pull request #1631 from micro/auth-address
Auth: Set address
2020-05-13 18:02:10 +01:00
Ben Toogood
8ab20f501c Fix merge conflicts 2020-05-13 17:58:03 +01:00
Ben Toogood
366fb228e5 Auth: Set address 2020-05-13 17:54:47 +01:00
Asim Aslam
bba8c254d7 fix auth initialisation (#1630) 2020-05-13 17:35:57 +01:00
ben-toogood
ebd53794af Merge pull request #1629 from micro/auth/rules-fix
Auth: Load rules if not present
2020-05-13 17:27:53 +01:00
Ben Toogood
2299244332 Auth: Load rules if not present 2020-05-13 17:07:46 +01:00
ben-toogood
cf61d98635 Merge pull request #1628 from micro/registry
Misc Muti-Tenancy / Auth Fixes
2020-05-13 16:53:39 +01:00
ben-toogood
15d1967aaf Merge branch 'master' into registry 2020-05-13 16:50:12 +01:00
Ben Toogood
410fec8ee4 Fix auth bug 2020-05-13 16:49:17 +01:00
Ben Toogood
c831b6c03a Fix 2020-05-13 16:35:57 +01:00
Asim Aslam
290595f88e Strip down router code (#1627) 2020-05-13 16:13:36 +01:00
ben-toogood
ba64518ebd Merge pull request #1626 from PieterVoorwinden/master
Check if auth is nil to prevent nilpointer
2020-05-13 15:18:58 +01:00
Pieter Voorwinden
b14d63b4a1 Check if auth is nil to prevent nilpointer 2020-05-13 16:13:23 +02:00
x1nchen
af2db0a0d9 fix: update dependency certmagic (#1625)
module github.com/mholt/certmagic has been renamed github.com/caddyserver/certmagic,
so upgrade on this module will fail.

fix: micro/micro#835

caddyserver/certmagic@v0.10.6 is Maximum upgradeable version with go version 1.13

Higher version use *tls.ClientHelloInfo.SupportsCertificate which only supported in go 1.14
2020-05-13 15:00:13 +01:00
ben-toogood
fb255a7e5a Merge pull request #1622 from micro/registry-multi-tenancy
Registry mutli-tenancy
2020-05-13 13:54:39 +01:00
Ben Toogood
47c1cb433e Store account credentials 2020-05-13 13:48:25 +01:00
Ben Toogood
3fac7d79ab Remove service type role 2020-05-13 13:42:56 +01:00
Ben Toogood
25c937fd0e Naming changes 2020-05-13 13:38:13 +01:00
Ben Toogood
e5c1fbc591 Merge branch 'master' of https://github.com/micro/go-micro into registry-multi-tenancy 2020-05-13 13:35:47 +01:00
Ben Toogood
d781c9ae2d Remove namespace specific logic 2020-05-13 13:35:34 +01:00
Ben Toogood
54951740bf Authenticate on service start 2020-05-13 13:13:11 +01:00
Janos Dobronszki
0fb4734e67 Upload local source code to micro server (#1613) 2020-05-13 12:07:53 +02:00
Ben Toogood
346e034d0a Add mutli-tenancy support to the registry 2020-05-13 10:40:08 +01:00
Asim Aslam
116cc1e9ee Stop parsing proxy address (#1619) 2020-05-12 17:38:22 +01:00
ben-toogood
762a5bc9e8 Merge pull request #1618 from micro/auth-namespace-flag
Auth Namespace Flag
2020-05-12 16:45:42 +01:00
Ben Toogood
d39b723511 Auth Namespace Flag 2020-05-12 16:41:29 +01:00
ben-toogood
5494e935f4 Merge pull request #1617 from micro/k8s/secret-type
K8s: Add Secret Type to yaml template
2020-05-12 14:21:30 +01:00
Ben Toogood
e0863bb7eb K8s: Add Secret Type to yaml template 2020-05-12 14:10:39 +01:00
ben-toogood
89f86167ad Merge pull request #1616 from micro/k8s/secret-template-fix
Fix k8s secret template (yaml)
2020-05-12 11:45:12 +01:00
ben-toogood
dfec1ad6b1 Merge branch 'master' into k8s/secret-template-fix 2020-05-12 11:41:41 +01:00
Ben Toogood
66d3e4a595 Fix k8s secret template (yaml) 2020-05-12 11:40:54 +01:00
Asim Aslam
19a03babc4 Update server.go 2020-05-12 11:32:01 +01:00
ben-toogood
ee24b4f083 Merge pull request #1615 from micro/disable-auth-client
Disable auth service client
2020-05-11 20:38:49 +01:00
Ben Toogood
937ecc8d2f Disable auth service client 2020-05-11 20:38:05 +01:00
ben-toogood
6078adb8bc Merge pull request #1614 from micro/runtime-clients
Runtime Options: Replace client.DefaultClient
2020-05-11 20:05:00 +01:00
ben-toogood
39f18b0b70 Merge branch 'master' into runtime-clients 2020-05-11 18:03:11 +01:00
Ben Toogood
efb64b7dbb Pass client to more of the runtime 2020-05-11 17:57:39 +01:00
Ben Toogood
f892b41299 Add runtime to service.Options() 2020-05-11 17:09:28 +01:00
Janos Dobronszki
1eb63635b5 Adding file upload and download capabilities (#1610) 2020-05-11 14:08:27 +02:00
ben-toogood
688228377b Merge pull request #1612 from micro/auth-options
Auth: pass options in service RPC
2020-05-11 11:53:38 +01:00
Ben Toogood
506006f0fa Auth Options 2020-05-11 11:47:59 +01:00
ben-toogood
22de001a80 Merge pull request #1611 from micro/auth-has-role
Auth account.HasRole
2020-05-11 11:40:20 +01:00
ben-toogood
d90cc8bf2f Merge branch 'master' into auth-has-role 2020-05-11 11:36:06 +01:00
Ben Toogood
5a8f19589b Auth account.HasRole 2020-05-11 11:34:22 +01:00
gggwvg
d61df6363b web: fix advertise address (#1608)
* web: fix advertise address
* web: fix test

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
Co-authored-by: Asim Aslam <asim@aslam.me>
Co-authored-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-05-08 12:31:03 +03:00
ben-toogood
f062013a7b Merge pull request #1607 from micro/k8s-debug
Log k8s Requests
2020-05-07 11:41:43 +01:00
Ben Toogood
fea93a5b7a Log k8s Requests 2020-05-07 11:35:56 +01:00
fztcjjl
30dc29e17f fix ring buffer (#1606) 2020-05-07 10:45:48 +01:00
ben-toogood
5387f73b5d Handle cockroach createDB error (#1603) 2020-05-06 10:58:14 +01:00
90dd1f63c8 api/handler/rpc: fix encoding of inner message (#1601)
* api/handler/rpc: fix encoding of inner message

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-05-04 15:50:53 +03:00
Asim Aslam
38cdb9cc2f Set table name in store 2020-05-01 18:24:35 +01:00
Asim Aslam
b3915b6020 Add store to options (#1600) 2020-05-01 18:05:09 +01:00
Asim Aslam
08a2de1ef5 Account for missing options database/table in cockroach store 2020-05-01 15:31:55 +01:00
Asim Aslam
7a2dea6cc2 Set database/table from init first 2020-05-01 15:22:44 +01:00
Asim Aslam
2a14feed93 force codec on call not on dial (#1599) 2020-05-01 14:59:50 +01:00
Asim Aslam
e8105d22ad cruft 2020-05-01 00:25:17 +01:00
Asim Aslam
c76a5e608d sql fixes 2020-04-30 23:53:54 +01:00
Asim Aslam
359b8bc503 Add opts to service proto (#1517)
* Add opts to service proto

* Support database/table opts
2020-04-30 22:51:25 +01:00
Janos Dobronszki
fccab8ad27 Runtime name should be base folder outside repos (#1598) 2020-04-30 18:20:51 +02:00
Socket
46d09ec2bc unsubscribe can async (#1596)
Co-authored-by: huangshaojie <huangshaojie@corp.netease.com>
Co-authored-by: Asim Aslam <asim@aslam.me>
2020-04-30 10:42:13 +01:00
Asim Aslam
7792dbc34d Update FUNDING.yml 2020-04-29 18:45:55 +01:00
ben-toogood
1d29f126f9 Merge pull request #1595 from micro/auth-client-wrapper
Auth Client Wrapper
2020-04-29 15:43:30 +01:00
Ben Toogood
bcddb98867 Fix Tests 2020-04-29 15:37:02 +01:00
Ben Toogood
f48dec1fb0 Use Server ID in account name 2020-04-29 15:27:18 +01:00
Ben Toogood
ef9f65c78b Improve Comments 2020-04-29 15:15:38 +01:00
Ben Toogood
99f8be5b3d Auth Client Wrapper 2020-04-29 15:11:06 +01:00
ben-toogood
9d2fdb84be Merge pull request #1592 from micro/jwt-auth
JWT auth implementation
2020-04-29 14:10:05 +01:00
ben-toogood
8b004feb9a Merge branch 'master' into jwt-auth 2020-04-29 13:33:47 +01:00
Ben Toogood
70736e24c0 Set RefreshToken 2020-04-29 13:33:22 +01:00
d44adafca5 api/router: avoid unneeded loops and fix path match (#1594)
* api/router: avoid unneeded loops and fix path match

* if match found in google api path syntax, not try pcre loop
* if path is not ending via $ sign, append it to pcre to avoid matching other strings like
  /api/account/register can be matched to /api/account
* api: add tests and validations

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-04-29 15:23:10 +03:00
ben-toogood
e57b20c1f8 Merge branch 'master' into jwt-auth 2020-04-29 13:22:09 +01:00
Ben Toogood
94971aee77 Complete JWT implementation 2020-04-29 13:21:51 +01:00
Ben Toogood
0ed66d0664 Fix Typo 2020-04-29 09:38:39 +01:00
Ben Toogood
7e27c97c6c Remove Comment 2020-04-29 09:22:15 +01:00
Ben Toogood
669364985e JWT auth implementation 2020-04-29 09:21:17 +01:00
Asim Aslam
c7440274dd touch 2020-04-28 19:35:13 +01:00
Asim Aslam
8ccbf53dfc secret cookie unused 2020-04-28 18:12:07 +01:00
Asim Aslam
f908110fb6 swap out context access for account (#1589) 2020-04-28 17:35:18 +01:00
9bb1904a38 broker: add publish context (#1590)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-04-28 19:29:00 +03:00
06220ab8c8 client: add context publish option (#1588)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-04-28 19:03:37 +03:00
Janos Dobronszki
da66561d1e Fixing too large offsets for default runtime logs (#1587) 2020-04-28 13:42:15 +01:00
Dmitry Kozlov
52861310b0 fix HTTP 401 Unauthorized, {"message": "401: Unauthorized", "code": 0} (#1586)
fix file=bot.go:426 level=error service=bot error starting bot HTTP 401 Unauthorized, {"message": "401: Unauthorized", "code": 0}
see https://github.com/bwmarrin/discordgo#usage
2020-04-28 13:06:01 +01:00
414b2ec5f8 web: fix deadlock (#1585)
* web: fix deadlock

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* add web tests

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-04-28 12:23:52 +01:00
Janos Dobronszki
b875868a39 Don't ignore errors from checkout source code (#1584)
Don't check out code for builtin services.
2020-04-28 10:51:39 +02:00
Janos Dobronszki
8148e0a0f8 Micro log fixes (#1570) 2020-04-28 09:49:39 +02:00
ben-toogood
25c82245b1 Merge pull request #1582 from micro/k8s-srv-accounts
Runtime: Add Kubernetes ServiceAccounts & Remove imagePullSecrets
2020-04-27 15:24:16 +01:00
ben-toogood
95a7e21f5f Merge branch 'master' into k8s-srv-accounts 2020-04-27 15:08:24 +01:00
Asim Aslam
83ab47333f rename Codec to Secrets (#1581) 2020-04-27 14:57:57 +01:00
Ben Toogood
8d7d6ef358 Add k8s secrets 2020-04-27 14:37:28 +01:00
Ben Toogood
494e0b5060 Runtime: Add Kubernetes ServiceAccounts & Remove imagePullSecrets 2020-04-27 14:13:51 +01:00
Janos Dobronszki
434997e676 Display only logging file name as opposed to path in logs (#1580) 2020-04-27 09:55:50 +01:00
Janos Dobronszki
ec44b67e9f Fixing log file path in logs (#1578) 2020-04-27 09:36:09 +01:00
e0c9234c0e web: use default logger (#1577)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-04-27 00:03:05 +03:00
980b772801 fix races in web and logger (#1576)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-04-26 17:41:36 +03:00
a22da39e1c logger: add caller info to default implementation (#1575)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-04-26 17:11:53 +03:00
徐旭
7253635cd3 delete invalid copy (#1573)
* prealloc

* delete invalid copy
2020-04-26 12:44:59 +01:00
Asim Aslam
0a030f3d8a strip unused list endpoint 2020-04-24 18:05:38 +01:00
Asim Aslam
edee3b6765 Add proxy env test (#1569) 2020-04-24 11:26:46 +01:00
Asim Aslam
d62ae23a9c Strip label 2020-04-23 20:20:48 +01:00
Asim Aslam
c68226e9b0 only do namespace check if not default 2020-04-23 19:19:13 +01:00
ben-toogood
041d68b1ce Merge pull request #1566 from micro/image-pull-secret-fix
Fix Runtime Namespace List
2020-04-23 18:16:38 +01:00
ben-toogood
85a8f36565 Merge branch 'master' into image-pull-secret-fix 2020-04-23 18:15:04 +01:00
Ben Toogood
f34d58cfbd Remove Debug 2020-04-23 18:14:06 +01:00
Asim Aslam
e0a651bfc3 set namespace on create 2020-04-23 18:10:13 +01:00
Ben Toogood
cd35f503a0 Remove hardcoded labels 2020-04-23 18:08:02 +01:00
Ben Toogood
8b3d223fc0 Remove hardcoded labels: 2020-04-23 18:05:58 +01:00
Ben Toogood
bb25bd94c8 Log k8s requests 2020-04-23 17:56:00 +01:00
ben-toogood
986e3d3c35 Merge pull request #1565 from micro/image-pull-secret-fix
Runtime: Fix ImagePullSecret
2020-04-23 17:53:09 +01:00
Ben Toogood
616db3442a Debugging 2020-04-23 17:44:40 +01:00
Ben Toogood
5fe3c0bfe5 Merge branch 'image-pull-secret-fix' of https://github.com/micro/go-micro into image-pull-secret-fix 2020-04-23 17:37:33 +01:00
Ben Toogood
8849b85a7f Merge branch 'master' of https://github.com/micro/go-micro into image-pull-secret-fix 2020-04-23 17:37:15 +01:00
ben-toogood
893bbafa03 Merge branch 'master' into image-pull-secret-fix 2020-04-23 17:28:06 +01:00
Ben Toogood
4c05623a3c Image pull secret fix 2020-04-23 17:26:59 +01:00
Asim Aslam
ec929b3d2f log error and ensure we pass through namespace 2020-04-23 17:14:30 +01:00
Asim Aslam
2299559397 Check for namespace (#1564) 2020-04-23 16:22:41 +01:00
ben-toogood
6be53536d3 Merge pull request #1562 from micro/git-secrets
Runtime - Image Pull Secrets
2020-04-23 15:45:32 +01:00
ben-toogood
99d4b2b31a Merge branch 'master' into git-secrets 2020-04-23 15:39:37 +01:00
Janos Dobronszki
ff8ad7d4ca Default runtime now checks out code on demand (#1563)
* Default runtime now checks out code on demand

* Go mod tidy
2020-04-23 16:30:43 +02:00
ben-toogood
b692c045b5 Merge branch 'master' into git-secrets 2020-04-23 15:01:47 +01:00
Ben Toogood
b5f53595ca Pass image_pull_secrets in runtime service 2020-04-23 14:22:23 +01:00
Ben Toogood
88176dca53 Remove debugging 2020-04-23 14:13:07 +01:00
Ben Toogood
020476614c Tweak CreateImagePullSecret 2020-04-23 14:06:33 +01:00
Ben Toogood
0f42346976 Additonal Debugging 2020-04-23 14:03:04 +01:00
ben-toogood
692b27578c Runtime Namespace (#1547)
* Add context option to runtime; Add dynamic namespace to kubectl client

* Add namespace runtime arg

* Fixes & Debugging

* Pass options in k8s runtime

* Set namespace on k8s resources

* Additional Logging

* More debugging

* Remove Debugging

* Ensure namespace exists

* Add debugging

* Refactor namespaceExists check

* Fix

* Fix

* Fix

* Fix

* Change the way we check for namespace

* Fix

* Tidying Up

* Fix Test

* Fix merge bugs

* Serialize k8s namespaces

* Add namespace to watch

* Serialize namespace when creating k8s namespace

Co-authored-by: Ben Toogood <ben@micro.mu>
Co-authored-by: Asim Aslam <asim@aslam.me>
2020-04-23 13:53:42 +01:00
Micro
316b81f790 Debugging 2020-04-23 13:11:00 +01:00
Micro
5e3262a62c Passs img pull secrets using name key 2020-04-23 12:52:59 +01:00
Micro
053fa0e457 Fix template syntax 2020-04-23 12:38:00 +01:00
Micro
501a6bf3ea Add imagePullSecrets to PodSpec 2020-04-23 12:27:36 +01:00
Asim Aslam
7345ce9192 change logging for service startup 2020-04-23 11:24:39 +01:00
6fa27373ed bundle qson lib in util (#1561)
* copy qson from https://github.com/joncalhoun/qson
  as author not want to maintain repo
* latest code contains our fix to proper decode strings
  with escaped & symbol
* replace package in api/handler/rpc

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-04-23 11:08:09 +03:00
徐旭
e55c23164a fix prealloc in trace (#1558) 2020-04-22 16:10:59 +03:00
Asim Aslam
e25ab9f4ca Fix typo for proxy 2020-04-22 10:44:34 +01:00
bea092f082 server: set registered only after configuring subscribers (#1557)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-04-21 23:01:59 +03:00
Asim Aslam
d7ecb58f6c Add network proxying (#1556)
* Add network proxying

* go fmt
2020-04-21 15:54:40 +01:00
Jake Sanders
05d2b34e10 Add util/pki for creating and signing certificates (#1555) 2020-04-21 15:03:33 +01:00
ben-toogood
211fd9b9a3 Merge pull request #1554 from micro/oauth-login-hint
Add oauth login hint param
2020-04-21 13:40:47 +01:00
Ben Toogood
19f0836e70 Add oauth login hint param 2020-04-21 13:37:26 +01:00
Janos Dobronszki
075d7d4fef Renaming ShutdownSignals -> Shutdown (#1553) 2020-04-21 14:14:20 +02:00
Janos Dobronszki
e5c215556e Add SIGKILL to shutdown signals (#1552)
* Add SIGKILL to shutdown signals

* go mod tidy

* Add missing file
2020-04-21 14:00:12 +02:00
Janos Dobronszki
7c31edd5f8 Enabling default runtime to run multiple versions (#1545)
* Enabling default runtime to run multiple versions

* Trigger build

* Fix

* Sprintf
2020-04-20 15:54:29 +02:00
Asim Aslam
c4acf3c2cb Static serving disabled 2020-04-19 20:30:38 +01:00
Asim Aslam
53db26a614 Use go.micro.mu 2020-04-19 17:03:25 +01:00
Asim Aslam
dde8f18b52 Update readme 2020-04-19 00:46:33 +01:00
Asim Aslam
6071b74fb5 Update readme 2020-04-19 00:45:29 +01:00
Asim Aslam
ab041012b2 Update readme 2020-04-19 00:44:52 +01:00
Asim Aslam
226d6ad22b log whats happening in http handler 2020-04-19 00:41:03 +01:00
Asim Aslam
a08ff90976 fix this bs logging issue 2020-04-18 23:36:00 +01:00
Asim Aslam
ae8404d760 Log listening port 2020-04-18 23:32:20 +01:00
f00fd7a49e api/router: support pcre and google.api pattern matching (#1549)
* api/router: support pcre and google.api pattern matching

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-04-19 00:31:34 +03:00
Asim Aslam
ecbc42755c set network nodes in http resolver 2020-04-18 21:00:00 +01:00
Asim Aslam
16db76bee2 remove list endpoint from runtime and stop checking type in update 2020-04-17 17:54:34 +01:00
Asim Aslam
dca5305e8a replaced build with updated timestamp in runtime 2020-04-17 16:29:05 +01:00
Asim Aslam
c0b0f63757 Update docker workflow to push releases 2020-04-17 10:50:44 +01:00
Janos Dobronszki
ac5822f1ee Fix local runtime updates (#1543) 2020-04-16 17:50:24 +02:00
ben-toogood
ae56becbbd Merge pull request #1542 from micro/stream-auth
Set authorization header on grpc stream
2020-04-16 15:06:19 +01:00
ben-toogood
5bb18e685e Merge branch 'master' into stream-auth 2020-04-16 15:03:12 +01:00
Ben Toogood
2dfaab439c Set authorization header on grpc stream 2020-04-16 15:01:16 +01:00
62cedf64da api/router/registry: extract path based parameters from url to req (#1530)
* api/router/registry: extract path based parameters from url to req
* api/handler/rpc: fix empty body request parsing
* bundle grpc-gateway util funcs

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-04-15 17:50:51 +03:00
ben-toogood
9961ebb46e Merge pull request #1538 from micro/rule-priority
Add priority to auth.CreateRequest and auth.DeleteRequest
2020-04-15 11:54:01 +01:00
Ben Toogood
fe31a71557 Fix formatting 2020-04-15 11:50:52 +01:00
Ben Toogood
c9a6b07c52 Add priority to auth.CreateRequest and auth.DeleteRequest 2020-04-15 11:49:24 +01:00
ben-toogood
f1e6eff303 Merge pull request #1537 from micro/rule-priority
Add Priority to auth rules
2020-04-15 11:42:53 +01:00
Ben Toogood
2de03e5fd7 Tidy go mod 2020-04-15 11:39:53 +01:00
Ben Toogood
234c192faf Update protoc-gen-micro 2020-04-15 11:39:12 +01:00
Ben Toogood
ea29920afb Add Priority to auth rules 2020-04-15 11:31:19 +01:00
4d177a782e vendor proto files from google (#1536)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-04-15 13:22:32 +03:00
b700d425a4 api/handler/rpc: improvements and fixes (#1535)
* api/handler/rpc: fix empty body case
* api/handler/rpc: copy all request headers to metadata

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-04-15 01:37:15 +03:00
Asim Aslam
9a5b8ff50d use api 2020-04-14 22:14:55 +01:00
Asim Aslam
c787fd0483 fix missing pointer 2020-04-14 17:13:38 +01:00
Asim Aslam
1134ea5ff3 make proto.Message compatible with raw json 2020-04-14 16:59:24 +01:00
ben-toogood
fd16cd298f Merge pull request #1532 from micro/registry-namespace
Registry Namespace
2020-04-14 16:14:18 +01:00
ben-toogood
67e7aa223a Merge branch 'master' into registry-namespace 2020-04-14 16:03:29 +01:00
Asim Aslam
9d0381306d add a proto message without serialisation 2020-04-14 15:54:25 +01:00
ben-toogood
f8837bfcbd Merge branch 'master' into registry-namespace 2020-04-14 15:37:44 +01:00
268651df18 regenerate all proto based files (#1531)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-04-14 16:25:09 +03:00
Ben Toogood
e17825474f Add context options to the runtime 2020-04-14 12:32:59 +01:00
Ben Toogood
0c75a0306b Merge master into registry-namespace 2020-04-14 09:15:13 +01:00
Ben Toogood
d61d30ef66 Inject Namespace into Context 2020-04-14 09:14:07 +01:00
Asim Aslam
71d4253927 Merge branch 'master' of ssh://github.com/micro/go-micro 2020-04-13 23:05:47 +01:00
Asim Aslam
e515005083 Remove only allowing certain methods 2020-04-13 23:05:39 +01:00
Asim Aslam
4bdc18d64a Update README.md 2020-04-13 22:15:21 +01:00
Asim Aslam
f840a5003e Remove runtime List 2020-04-12 23:46:06 +01:00
Asim Aslam
5ef1698632 remove readme 2020-04-12 23:43:55 +01:00
Asim Aslam
1bb6967a38 reorder 2020-04-12 23:41:21 +01:00
Asim Aslam
a056bdce7c fix metadata parsing 2020-04-12 14:40:37 +01:00
Asim Aslam
b08c636b44 fixup handler tests 2020-04-12 14:29:38 +01:00
Asim Aslam
d03a02f2e4 fix import 2020-04-12 11:25:12 +01:00
Asim Aslam
08ca61c121 add metadata set 2020-04-12 11:17:23 +01:00
Asim Aslam
962588b649 Strip MetadataKey global var 2020-04-12 11:16:08 +01:00
Asim Aslam
cf67d460b7 strip down mdns watcher 2020-04-12 11:01:09 +01:00
Asim Aslam
4e539361fa strip file 2020-04-12 10:58:12 +01:00
3ce2ab88f5 broker/nats: remove embed nats server reference (#1527)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-04-11 22:37:29 +03:00
0a2363b49b api minor improvements (#1526)
* api/handler/rpc: unblock all http methods and set Host meta
* api/router/static: add debug log

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-04-11 22:21:55 +03:00
Asim Aslam
ec80ceb8c2 Update readme 2020-04-11 18:23:37 +01:00
Asim Aslam
ea2bb0275c Strip external use of mdns 2020-04-11 13:02:53 +01:00
Asim Aslam
51d4f737b8 fixup store cache# 2020-04-11 12:10:19 +01:00
Asim Aslam
3f81f685df Move sync 2020-04-11 12:00:34 +01:00
Asim Aslam
bb1ccf09e8 prefix store dir 2020-04-11 11:23:41 +01:00
Asim Aslam
c878237567 fix log file creation 2020-04-11 11:22:02 +01:00
Asim Aslam
ac8b6f944e Prefix logs dir micro/logs for runtime 2020-04-11 11:15:01 +01:00
Asim Aslam
0f2006ac50 fix compilation issues 2020-04-11 11:02:06 +01:00
Asim Aslam
c697eed1be Update comments 2020-04-11 10:48:32 +01:00
Asim Aslam
b887d91f94 remove readme 2020-04-11 10:38:13 +01:00
Asim Aslam
39470c1b11 Completely replace sync implementation 2020-04-11 10:37:54 +01:00
Asim Aslam
6d553cb6fe add whitespace 2020-04-11 09:34:04 +01:00
Asim Aslam
c612d86480 Move sync store 2020-04-11 09:33:10 +01:00
Asim Aslam
3f3d2f5027 fixup broker http address 2020-04-11 01:51:26 +01:00
bc71640fd9 broker: swap default broker from eats to http (#1524)
* broker: swap default broker from eats to http

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-04-11 03:46:54 +03:00
Asim Aslam
b979db6d9d remove sync event 2020-04-10 23:29:15 +01:00
Asim Aslam
57b758db7e push 2020-04-10 22:09:06 +01:00
Asim Aslam
b5f546b137 go mod tidy 2020-04-10 19:55:45 +01:00
Asim Aslam
d4b2c948dd Remove cloudflare store 2020-04-10 19:50:57 +01:00
Asim Aslam
b9a5e9d610 fixup sync map 2020-04-10 17:47:13 +01:00
Asim Aslam
57853b2849 remove etcd store 2020-04-10 17:43:02 +01:00
Asim Aslam
e5268dd0a6 move reg util to own package (#1523)
* move reg util to own package

* fix test

* fix broken static router
2020-04-10 17:41:10 +01:00
Asim Aslam
4fd12430d0 cleanup mdns files 2020-04-10 17:19:26 +01:00
Asim Aslam
d134b469be rename file 2020-04-10 17:17:24 +01:00
Asim Aslam
9a685b2df5 delete k8s registry (#1522) 2020-04-10 17:15:20 +01:00
Jake Sanders
6a666c9c7d Add json tags to store.Record (#1518) 2020-04-09 19:38:43 +01:00
Asim Aslam
53549b6b30 Add options for Database/Table (#1516)
* Add options for Database/Table

* fix opts
2020-04-09 17:56:13 +01:00
Jake Sanders
0a27a08184 Add Databases and Tables endpoints to store RPC proto (#1515)
* Add Databases and Tables to store RPC

* add Database to TablesRequest
2020-04-09 16:37:32 +01:00
Janos Dobronszki
77f0abb0ba Enabling micro run for subfolders (#1510)
* Enabling micro run for subfolders

* Use source instead of os.Args[2]

* Works now

* PR comments

* WorkDir -> Dir
2020-04-09 15:44:39 +01:00
Asim Aslam
29cccd0b4a minor tweak add log line to proxy and basic auth provider by default (#1513) 2020-04-09 14:10:17 +01:00
ben-toogood
bf65dc71c7 Merge pull request #1505 from micro/resover-refactor
Extract Micro Resolver (Namespace)
2020-04-09 13:14:49 +01:00
Asim Aslam
5bc8ee39f7 Merge branch 'master' into resover-refactor 2020-04-09 13:07:05 +01:00
8c1b477279 store/cockroach: fixup test (#1512)
* store/cockroach: fixup test

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-04-09 14:58:50 +03:00
Ben Toogood
f9cfbe96c0 Merge master into resover-refactor 2020-04-09 12:42:34 +01:00
Jake Sanders
2e379ca7d0 Don't break the build! 2020-04-09 12:18:02 +01:00
Jake Sanders
2659215d5e cockroachDB doesn't support this syntax (#1509) 2020-04-09 12:11:24 +01:00
1063b954de dont display t.Log/t.Logf as errors in github actions (#1508)
* fix tests and github action annotations

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-04-09 14:05:46 +03:00
Ben Toogood
4ff959ef50 Dynamic Namespace 2020-04-09 11:03:33 +01:00
Janos Dobronszki
bc1c8223e6 Remove ugly unneeded log in runtime local (#1507) 2020-04-09 11:50:12 +02:00
Ben Toogood
27eb7db1c2 Add default resolver to api router 2020-04-09 10:34:21 +01:00
Ben Toogood
3ede494945 Change import name 2020-04-09 10:32:08 +01:00
Ben Toogood
f102aba4c1 Fix HTTP tests 2020-04-09 10:28:38 +01:00
Asim Aslam
f2dd091ec0 strip log 2020-04-09 10:28:16 +01:00
Asim Aslam
c1ad6d6c7c set service name in web 2020-04-09 09:41:50 +01:00
Jake Sanders
1e7cd8c484 Make the constraint explicit rather than inferred (#1506) 2020-04-08 23:52:35 +01:00
Asim Aslam
bf8ebf8ad2 add namespace 2020-04-08 23:27:32 +01:00
Asim Aslam
1768958af7 fix typo 2020-04-08 22:50:56 +01:00
Asim Aslam
bf41d8d28e fix store table env var 2020-04-08 19:44:49 +01:00
Asim Aslam
45700eaabe set database/table in header 2020-04-08 19:25:57 +01:00
Asim Aslam
48dd30c4c2 fix http test 2020-04-08 19:20:43 +01:00
Ben Toogood
8ff86ae08b Extract micro resolver 2020-04-08 16:21:53 +01:00
Asim Aslam
b2079669f7 Strip namespace from router 2020-04-08 15:39:01 +01:00
Asim Aslam
2c1d1afd71 Strip namespace from registry router 2020-04-08 15:38:02 +01:00
Asim Aslam
9a73828782 Remove unused handlers 2020-04-08 15:34:11 +01:00
ben-toogood
c5d085cff8 Merge pull request #1496 from micro/namespace
Configurable Namespace & Public Suffix Domain Resolution
2020-04-08 13:48:50 +01:00
ben-toogood
9f4286fc4e Merge branch 'master' into namespace 2020-04-08 13:44:46 +01:00
Jake Sanders
77f5cc5023 Fix nil dereference in cloudflare store (#1504) 2020-04-08 13:00:30 +01:00
8400aba81c broker/memory: small memory improvements (#1501)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-04-08 14:56:54 +03:00
Jake Sanders
cc027d900e Close statements, add default table if the store was not initialised through service.Init() (#1502) 2020-04-08 12:08:08 +01:00
Edward
bc0dc2e509 fix :no syscall.Kill on windows #1474 (#1474) 2020-04-08 10:50:44 +01:00
1fbc056dd4 minimize allocations (#1472)
* server: minimize allocations on re-register

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* server: stop old instance before Init()

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* client/grpc: fix allocations in protobuf marshal

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* codec/json: fix allocations in protobuf marshal

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* remove stop from init

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* codec/grpc: expose MaxMessageSize

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* codec: use buffer pool

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* metadata: minimize reallocations

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* util/wrapper: use metadata helper

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* registry/cache: move logs to debug level

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* server: move logs to debug level

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* server: cache service only when Advertise is ip addr

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* server: use metadata.Copy

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-04-08 10:50:19 +01:00
Asim Aslam
98fc3dfbad use single data bucket 2020-04-08 09:57:51 +01:00
Asim Aslam
4b0e27413e add Store Close method (#1500)
* add Store Close method

* Update sync store build failure
2020-04-08 09:51:10 +01:00
ben-toogood
6b524e2c55 Merge branch 'master' into namespace 2020-04-08 09:12:28 +01:00
Asim Aslam
4cac7dcc48 fix file tests 2020-04-07 19:45:27 +01:00
Ben Toogood
e907d24e3b API Wrappers 2020-04-07 19:29:26 +01:00
Asim Aslam
39c352f210 Remove the test that takes 30 seconds sleeping 2020-04-07 18:22:40 +01:00
Ben Toogood
67cd59d7bc Rename namespace from Resolver.Endpoint 2020-04-07 16:27:59 +01:00
Ben Toogood
3735b0e529 Remove global namespace option 2020-04-07 16:27:01 +01:00
Ben Toogood
4362a885eb Refactor Namespace Resolver 2020-04-07 16:24:51 +01:00
Janos Dobronszki
038b936ce9 Setting up file store in constructor and not in init which is o… (#1499) 2020-04-07 16:43:43 +02:00
6aaad7d63f api/router/static: allow to specify body dst (#1486)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-04-07 15:38:27 +01:00
Janos Dobronszki
aaee01b1a7 Use file store by default (as opposed to memory store) (#1498)
* Use file store by default (as opposed to memory store)

* Default table for file store
2020-04-07 15:19:45 +02:00
Jake Sanders
71538adfdc Explicitly set the table name during service init (#1497) 2020-04-07 13:00:05 +01:00
Janos Dobronszki
2ea5b33955 Disk backed local store (#1491) 2020-04-07 13:53:22 +02:00
Ben Toogood
3df87510a1 Add namespace 2020-04-07 12:46:44 +01:00
Ben Toogood
9d598836c3 Fix Tests 2020-04-07 11:37:04 +01:00
Ben Toogood
05ac3ff274 Tweak 2020-04-07 11:24:13 +01:00
Ben Toogood
76f6f80318 Default to Hostname 2020-04-07 11:23:21 +01:00
Ben Toogood
cb96949551 Merge branch 'master' of https://github.com/micro/go-micro into namespace 2020-04-07 10:58:54 +01:00
ben-toogood
87cc4f273b Merge pull request #1495 from micro/log-level
Change cross namespace request err level
2020-04-07 10:58:22 +01:00
Ben Toogood
f0980e9b30 Change cross namespace request err level 2020-04-07 10:54:27 +01:00
Ben Toogood
977934f8fd ServiceNamespace => ServicePrefix in api server 2020-04-07 10:39:27 +01:00
Ben Toogood
9e116731b1 ServiceNamespace => ServicePrefix in api server 2020-04-07 10:38:27 +01:00
Ben Toogood
316424f0f7 Fix comments typo 2020-04-07 10:35:57 +01:00
Ben Toogood
bd23dc1f18 Improve micro.mu check 2020-04-07 10:34:26 +01:00
Ben Toogood
501fc5c059 Refactor to use publicsuffix 2020-04-07 10:28:39 +01:00
Ben Toogood
11e1e9120a Remove debugging 2020-04-07 10:10:37 +01:00
Ben Toogood
a81d86ed08 Merge Asim's Fixes 2020-04-07 10:08:06 +01:00
Ben Toogood
7206d5f964 Add Namespace to CombinedAuthHandler 2020-04-07 09:40:40 +01:00
Asim Aslam
b5f5027549 Move store scope to util 2020-04-07 02:23:16 +01:00
Asim Aslam
e8a86585da contains missing host port 2020-04-07 00:54:27 +01:00
Asim Aslam
5374896ed0 clone request 2020-04-07 00:29:35 +01:00
Asim Aslam
b6348ba59a Fix cruft 2020-04-07 00:25:11 +01:00
Asim Aslam
ca11c4a672 Few nitpicks 2020-04-07 00:19:49 +01:00
Lars Lehtonen
900b2d24f9 config/secrets/box: fix dropped test error (#1494) 2020-04-06 23:09:42 +01:00
Jake Sanders
3324d140c0 Rename store Namespace / Prefix options to Database and Table (#1492)
* Rename Namespace to DB, Rename Prefix to table, Remove Suffix Option

* Rename options

* Rename options

* Add store_table option

* Table per service, not Database per service
2020-04-06 16:45:55 +01:00
ben-toogood
3a378eb7d6 Merge pull request #1493 from micro/auth-encode-endpoint
Encode Endpoint in API auth wrapper
2020-04-06 16:21:14 +01:00
Ben Toogood
574bf5ac69 Set value in context, not metadata 2020-04-06 16:10:08 +01:00
Ben Toogood
774c0d30a7 Encode Endpoint in API auth wrapper 2020-04-06 16:01:42 +01:00
ben-toogood
0f570d98e1 Merge pull request #1475 from micro/auth-resolver
Auth integrate resolver to support micro web & api
2020-04-06 14:57:41 +01:00
ben-toogood
7f07e1a642 Merge branch 'master' into auth-resolver 2020-04-06 14:43:22 +01:00
ben-toogood
9b546a7242 Change auth namespace log level (#1490)
Co-authored-by: Ben Toogood <ben@micro.mu>
2020-04-06 13:51:28 +01:00
Asim Aslam
c4442a7533 Don't set the registry in new options for web services (#1489) 2020-04-06 13:40:40 +01:00
ben-toogood
bea7c3f7e7 Merge pull request #1488 from micro/disable-warn-log
Change namespace error log level
2020-04-06 12:55:47 +01:00
ben-toogood
cca9773269 Merge branch 'master' into disable-warn-log 2020-04-06 12:51:47 +01:00
Ben Toogood
600b20fb81 Change namespace error log level 2020-04-06 12:50:04 +01:00
Edward
31a1ea6fae fix: use registry from opts not use default directly:(#1436) (#1468)
web: use passed user registry, or default
2020-04-05 13:15:38 +03:00
bc7579f1d8 api/handler/rpc: fix panic on invalid error conversation (#1483)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-04-04 00:55:15 +03:00
38aed6f0f6 api/handler/rpc: not log error on client disconnect (#1482)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-04-04 00:37:18 +03:00
ben-toogood
7f8b35e295 Merge pull request #1480 from micro/host-fix
Add Debugging
2020-04-03 15:07:22 +01:00
ben-toogood
b09dd9a689 Merge branch 'master' into host-fix 2020-04-03 15:03:49 +01:00
Ben Toogood
a82ce4d1ae Add Debug 2020-04-03 15:03:18 +01:00
ben-toogood
34234fc486 Merge pull request #1479 from micro/host-fix
Auth host fix
2020-04-03 14:43:35 +01:00
Ben Toogood
4a850ff8a0 Auth host fix 2020-04-03 14:40:24 +01:00
ben-toogood
350dd41732 Merge branch 'master' into auth-resolver 2020-04-03 14:19:03 +01:00
ben-toogood
d8cca31738 Merge pull request #1478 from micro/auth-hosts-fix
Fix auth hosts bug
2020-04-03 14:13:51 +01:00
Ben Toogood
b864b3e350 Fix auth hosts bug 2020-04-03 14:09:25 +01:00
ben-toogood
41b746e435 Merge pull request #1477 from micro/fix
Hotfix
2020-04-03 13:37:50 +01:00
Ben Toogood
906263291b Hotfix 2020-04-03 13:37:02 +01:00
ben-toogood
46f0bda31e Merge pull request #1476 from micro/namespace-fix
Namespace Fix
2020-04-03 13:30:30 +01:00
Ben Toogood
d0e47206cc Fix 2020-04-03 13:29:48 +01:00
ben-toogood
ed6fe67880 Merge pull request #1471 from micro/namespace
Detect & Propagate Namespace
2020-04-03 13:07:26 +01:00
Ben Toogood
1374a9e528 Fix namespace bug in auth wrapper 2020-04-03 13:03:27 +01:00
Ben Toogood
a9c0e043d2 Fix nil grpc server auth bug 2020-04-03 12:50:50 +01:00
Ben Toogood
49a568e9c0 Set default server auth 2020-04-03 12:33:19 +01:00
Ben Toogood
dea2d7ab9f Fix go-micro auth wrapper init 2020-04-03 12:27:01 +01:00
Ben Toogood
ebb1a42d48 Merge branch 'namespace' of https://github.com/micro/go-micro into namespace 2020-04-03 12:14:26 +01:00
Ben Toogood
1096c8fb39 Fix failing test 2020-04-03 10:16:19 +01:00
Ben Toogood
91b9c3f92e Add defaults 2020-04-03 10:08:39 +01:00
Ben Toogood
183c8bfb81 Apply fix for apis 2020-04-03 09:45:39 +01:00
Ben Toogood
49a1130281 Merge branch 'auth-resolver' of https://github.com/micro/go-micro into auth-resolver 2020-04-03 09:34:57 +01:00
Ben Toogood
760233b858 Reverse Change 2020-04-03 09:34:52 +01:00
ben-toogood
ede076e899 Merge branch 'master' into auth-resolver 2020-04-03 09:33:13 +01:00
Ben Toogood
fdcb013f24 Fix web registry compatability bugs 2020-04-03 09:18:30 +01:00
Ben Toogood
ce23ab36cb Improve Err Handling 2020-04-02 18:41:06 +01:00
ben-toogood
61f0619e97 Merge branch 'master' into namespace 2020-04-02 18:05:21 +01:00
Ben Toogood
cfde3ec3d9 Remove resolver logic 2020-04-02 18:03:57 +01:00
Ben Toogood
4a4c666528 Remove resolver logic 2020-04-02 18:03:21 +01:00
Ben Toogood
8b35c264eb Pass resolver to api auth handler 2020-04-02 17:44:48 +01:00
Ben Toogood
4999f6dfd4 Namespace requests coming via api & web 2020-04-02 17:01:06 +01:00
Asim Aslam
31c4452fc7 delete monitor (#1470) 2020-04-02 14:05:17 +01:00
Janos Dobronszki
2cafa289b6 Stop LogStream if there is an error in k8s pod log streaming (#1469)
* Stop LogStream if there is an error in k8s pod log streaming

* Locking stream Stops

* PR comment
2020-04-02 12:16:35 +01:00
0241197c6a api/handler/rpc: binary streaming support (#1466)
* api/handler/rpc: binary streaming support

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* fixup

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* fix

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* fix sec webscoekt protol

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-04-02 10:13:04 +01:00
Asim Aslam
0a15ae9b9d Move String method (#1467) 2020-04-01 23:27:15 +01:00
Janos Dobronszki
d2b6d35220 log.Errorf when pod streaming fails (#1463)
* log.Errorf when pod streaming fails

* Error method added for loggers

Co-authored-by: Asim Aslam <asim@aslam.me>
2020-04-01 23:03:26 +01:00
Asim Aslam
e1bc0f6288 replace strings for store prefix (#1465)
Co-authored-by: ben-toogood <bentoogood@gmail.com>
2020-04-01 20:19:21 +01:00
ben-toogood
cd3d704aa5 Merge pull request #1459 from micro/auth-interface-update
Auth Interface Iteration
2020-04-01 17:56:38 +01:00
Ben Toogood
9de69529ce Fix token tests 2020-04-01 17:29:17 +01:00
ben-toogood
623f0c0c90 Merge branch 'master' into auth-interface-update 2020-04-01 17:24:01 +01:00
Ben Toogood
c766679687 Fix typo 2020-04-01 17:22:01 +01:00
Ben Toogood
df8c0bb5e1 Auth Generate, make secret optional 2020-04-01 17:20:02 +01:00
Ben Toogood
d577c32563 Add back auth.PrivateKey 2020-04-01 17:17:40 +01:00
Ben Toogood
365dfe9df5 Code => State 2020-04-01 17:11:46 +01:00
Ben Toogood
ae15793fc3 Support oauth codes 2020-04-01 15:36:22 +01:00
Janos Dobronszki
15fcd5ecef Remove Go micro 1.18 dependency (#1462) 2020-04-01 16:14:08 +02:00
Ben Toogood
1750fd8d10 Merge branch 'auth-interface-update' of https://github.com/micro/go-micro into auth-interface-update 2020-04-01 14:42:37 +01:00
Ben Toogood
525ab094c8 Remove LoginOptions 2020-04-01 14:42:11 +01:00
Janos Dobronszki
bb51b8203e Runtime logs (#1447)
* Runtime logs

* Slightly broken

* Pushing for diff

* Log trailing works locally

* LogsOptions

* Comments and streamcount support for local logs

* Adding kubernetes logs

* Fixing k8s logs

* K8s fixes

* StreamCount is now nuked

* PR comments

* PR comments again

* Fix typo
2020-04-01 15:40:15 +02:00
ben-toogood
75a75c56ad Merge branch 'master' into auth-interface-update 2020-04-01 14:37:06 +01:00
Ben Toogood
26cb6bf5b9 Remove Legacy JWT fields 2020-04-01 14:27:56 +01:00
Ben Toogood
9cbbd71855 Remove default login 2020-04-01 14:26:24 +01:00
Ben Toogood
f7655b71ea Merge branch 'auth-interface-update' of https://github.com/micro/go-micro into auth-interface-update 2020-04-01 14:25:07 +01:00
Ben Toogood
8e4d9e1702 Further Refactoring 2020-04-01 14:25:00 +01:00
Asim Aslam
20c95d94cd api completeness (#1460) 2020-04-01 12:07:50 +01:00
ben-toogood
0a7d8afe67 Merge branch 'master' into auth-interface-update 2020-04-01 09:42:45 +01:00
7b7a859a03 api: use http request Clone (#1458)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-04-01 01:50:37 +03:00
8a8742f867 api/handler/rpc: dont change types of url fields (#1457)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-04-01 01:26:58 +03:00
Asim Aslam
68b0238a5d add stream timeout option which defaults to 0 (#1456)
* add stream timeout option which defaults to 0

* fix option
2020-03-31 23:22:11 +01:00
1490aff38e api/handler/rpc: correctly parse nested url vars (#1455)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-04-01 00:23:17 +03:00
3a22efbd7d metadata: change method name (#1454)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-31 23:39:18 +03:00
5e65a46be3 metadata: allow to remove key from metadata (#1453)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-31 22:55:33 +03:00
18061723bb fix api metadata extract from context (#1452)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-31 22:36:51 +03:00
d6bef84de0 api/handler/rpc: fix metadata cleanup (#1451)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-31 21:59:35 +03:00
Ben Toogood
82bc3cbf8d Update interface to add provider and make secret optional 2020-03-31 19:01:43 +01:00
Ben Toogood
cffb0a1eae Remove ContextWithToken 2020-03-31 18:34:31 +01:00
Ben Toogood
134bc1c68a Implement new interface 2020-03-31 18:17:01 +01:00
Asim Aslam
6c6c5359b1 Add options to config (#1450) 2020-03-31 17:13:21 +01:00
Ben Toogood
8dbb5153f4 Tweak Auth Interface 2020-03-31 17:01:51 +01:00
ben-toogood
2674790694 Service => Service Auth (#1448)
* Service => Service Auth

* WithServicePrivileges => ServicePrivileges

* Fixes for CLI login

* ServicePrivileges => ServiceToken

* Fallback to service token

Co-authored-by: Ben Toogood <ben@micro.mu>
2020-03-31 16:18:04 +01:00
ben-toogood
9fb1d476a2 Merge branch 'master' into auth-srv-srv 2020-03-31 16:15:17 +01:00
Ben Toogood
36386354d7 Fallback to service token 2020-03-31 13:51:32 +01:00
Ben Toogood
bd70820b6b ServicePrivileges => ServiceToken 2020-03-31 13:48:28 +01:00
Ben Toogood
956029ae3d Fixes for CLI login 2020-03-31 13:30:14 +01:00
Ben Toogood
e0c7f48d20 WithServicePrivileges => ServicePrivileges 2020-03-31 12:57:38 +01:00
Ben Toogood
d659e435c6 Service => Service Auth 2020-03-31 12:44:34 +01:00
Jake Sanders
3d274ab6a2 Add namespace support to Kubernetes client (#1446)
* Add namespace support to Kubernetes client

* Fix LastUpdateTime Condition
2020-03-31 12:03:32 +01:00
Asim Aslam
1222d076f2 There can be only one! (#1445)
* There can be only one

* fix proto?
2020-03-31 10:18:50 +01:00
ben-toogood
76ade7efd9 Auth - Swap Refresh to Token and change secrets to be strings, not tokens (#1444)
* Refresh => Token

* Secret is no longer a token

Co-authored-by: Ben Toogood <ben@micro.mu>
2020-03-31 10:06:13 +01:00
c706ebe3fb auth proto: provide help to protoc-gen-go (#1442)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-31 00:35:11 +03:00
9e6db79860 regenerate all proto (#1440)
* regenerate all proto

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* regenerate from proto

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* regenerate from proto

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-30 21:58:32 +01:00
756b346672 auth/service: move all proto files to single dir (#1439)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-30 18:23:00 +03:00
ben-toogood
4db2f5e79d Add Namespace to Auth (#1438)
Co-authored-by: Ben Toogood <ben@micro.mu>
2020-03-30 09:51:37 +01:00
3d7d5ce6b4 api: add static router and improve path parser in rpc handler (#1437)
* api: add static router and improve path parser in rpc handler

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* expose metadata context key to be able to get unmodified map keys

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* server/grpc: fix jsonpb codec for protobuf msg

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* api/handler/rpc: write 204 status code when rsp is nil

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* api/handler/rpc: add check for nil response for non javascript

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-30 09:04:59 +01:00
Socket
8282e781e4 grpc pool should check state (#1435)
Co-authored-by: huangshaojie <huangshaojie@corp.netease.com>
2020-03-28 08:48:25 +00:00
e4acc63d5f add mdns registry debug (#1434)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-27 22:33:49 +03:00
Asim Aslam
45ee5e9ad1 Move error for api validation to trace level (#1432)
* remove error on endpoint validation

* trace level
2020-03-27 14:01:47 +00:00
Asim Aslam
b60fde0e64 Pass through source and metadata in Update and Delete calls to runtime (#1431) 2020-03-27 11:37:12 +00:00
Lars Lehtonen
011a783a9e store/cockroach: fix dropped test errors (#1419)
Co-authored-by: Asim Aslam <asim@aslam.me>
2020-03-27 10:15:37 +00:00
ben-toogood
6723d17b22 Default auth, return account secret on Inspect (#1430)
Co-authored-by: Ben Toogood <ben@micro.mu>
2020-03-27 09:54:29 +00:00
ben-toogood
47c7181d41 Default Auth: Add blank secret to account to prevent nil errors (#1429)
* Remove debug auth logs

* Default auth, return account secret on Inspect

Co-authored-by: Ben Toogood <ben@micro.mu>
2020-03-27 09:46:17 +00:00
b38da6ced0 api/handler/rpc: process all methods and merge url params to json body (#1427)
* api/handler/rpc: process all methods and merge url params to json body

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* add merge json test

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-27 07:59:31 +00:00
ben-toogood
1a53307a78 Remove debug auth logs (#1426)
Co-authored-by: Ben Toogood <ben@micro.mu>
2020-03-26 19:00:24 +00:00
Asim Aslam
e204f3e2e8 Add metadata Get method (#1425) 2020-03-26 18:50:00 +00:00
ben-toogood
329bd09f93 Fix Auth Init bug (#1424)
Co-authored-by: Ben Toogood <ben@micro.mu>
2020-03-26 18:09:51 +00:00
ben-toogood
4648fd0d09 Auth debugging (#1423)
* More auth debugging

* More auth debugging

* Increase auth debugging

Co-authored-by: Ben Toogood <ben@micro.mu>
2020-03-26 17:55:35 +00:00
ben-toogood
c905df3be6 Log auth verify requests (#1422)
* More auth debugging

* More auth debugging

Co-authored-by: Ben Toogood <ben@micro.mu>
2020-03-26 17:35:28 +00:00
Asim Aslam
62f9a054a4 100mb (#1421) 2020-03-26 16:57:31 +00:00
ben-toogood
00e7804f96 Auth - Add debugging to loading rules (#1420)
* Fix auth multi-rule edgecase

* Add logging to auth rules

Co-authored-by: Ben Toogood <ben@micro.mu>
2020-03-26 16:30:31 +00:00
ben-toogood
42b6bf5bbf Fix auth multi-rule edgecase (#1418)
Co-authored-by: Ben Toogood <ben@micro.mu>
2020-03-26 15:52:48 +00:00
ben-toogood
844c456839 Refactor Auth Service Protos, Add Access Rules (#1411)
* Refactor auth/service into two protos

* Accounts Proto

* Store Prefixes

* Misc

* Tweak Protos

Co-authored-by: Ben Toogood <ben@micro.mu>
Co-authored-by: Asim Aslam <asim@aslam.me>
2020-03-26 13:12:43 +00:00
Asim Aslam
7182ca1fd0 fix server logging (#1417) 2020-03-26 13:08:06 +00:00
02839cfba5 api/handler: use http.MaxBytesReader and buffer pool (#1415)
* api/handler: use http.MaxBytesReader

protect api handlers from OOM cases

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-26 14:29:28 +03:00
Asim Aslam
776a7d6cd6 Update filter comment for proxy (#1416) 2020-03-26 08:05:00 +00:00
beaa434610 logger: fix reading env var (#1414)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-25 22:00:43 +00:00
Asim Aslam
6efc5556e5 use requested service (#1413) 2020-03-25 20:59:37 +00:00
Asim Aslam
8d0826a031 Add check for k8s condition (#1412) 2020-03-25 19:32:41 +00:00
ben-toogood
378d03eb66 Tidying up auth (#1410)
* Don't clear auth rules if request fails

* Add jitter to auth service loading rules

* Remove unused error from ContextWithToken result

Co-authored-by: Ben Toogood <ben@micro.mu>
2020-03-25 18:34:13 +00:00
ben-toogood
56af826230 Update auth to pass seconds and not nanoseconds (#1409)
Co-authored-by: Ben Toogood <ben@micro.mu>
2020-03-25 17:03:45 +00:00
ben-toogood
511ebd8ec2 Fix Token Expiry Bug (#1408)
Co-authored-by: Ben Toogood <ben@micro.mu>
2020-03-25 14:40:37 +00:00
ben-toogood
1057ef6acb Add ContextWithToken (#1407)
* Add ContextWithToken

* Tidying up BearerScheme

Co-authored-by: Ben Toogood <ben@micro.mu>
2020-03-25 11:20:53 +00:00
ben-toogood
35e2a68a98 Fix auth bug restricting access to unauthorised endpoints (#1405)
Co-authored-by: Ben Toogood <ben@micro.mu>
2020-03-25 10:31:33 +00:00
ben-toogood
0e56382107 Fix service level auth, add improved error descriptions to aid with debugging (#1403)
Co-authored-by: Ben Toogood <ben@micro.mu>
2020-03-25 09:35:29 +00:00
Jake Sanders
dff98355be Missing ; in SQL query 2020-03-24 23:49:09 +00:00
8100d26430 api/router/registry: use logger (#1402)
* api/router/registry: use logger

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* api/server/acme: use logger

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-24 20:45:11 +00:00
Jake Sanders
397a8638f4 Cockroach Store bugfix (#1401) 2020-03-24 17:16:38 +00:00
Jake Sanders
eb4d2ae6aa Remove useless variable from cockroach store (#1400) 2020-03-24 15:37:30 +00:00
Jake Sanders
914340585c Trim space from env variables (#1399) 2020-03-24 14:51:43 +00:00
ben-toogood
84b4eb5404 Fix missing loop (#1398)
* WithRoles variadic args

* Load Rules

* Timer => Ticker

* Add missing for loop in auth service

Co-authored-by: Ben Toogood <ben@micro.mu>
2020-03-24 14:16:57 +00:00
ben-toogood
fd664f4392 Auth load rules (#1397)
* WithRoles variadic args

* Load Rules

* Timer => Ticker

Co-authored-by: Ben Toogood <ben@micro.mu>
2020-03-24 13:48:37 +00:00
ben-toogood
86272a3064 WithRoles variadic args (#1395)
Co-authored-by: Ben Toogood <ben@micro.mu>
2020-03-24 10:18:34 +00:00
ben-toogood
c1978265ab Auth Wildcard Endpoints (#1394)
* Auth Wildcard Endpoints

* Fix joinkey bug, improve tests

* Change joinKey

Co-authored-by: Ben Toogood <ben@micro.mu>
2020-03-24 09:39:33 +00:00
ben-toogood
e0e77f3983 Updated auth interface (#1384)
* Updated  auth interface

* Add Rule

* Remove Rule

* Return token from Renew

* Renew => Refresh

* Implement Tokens & Default Auth Implementation

* Change default auth to noop

* Change default auth to noop

* Move token.Token to auth.Token

* Remove Token from Account

* Auth service implementation

* Decode JWT locally

* Cookie for secret

* Move string to bottom of interface definition

* Depricate auth_exclude

* Update auth wrappers

* Update go.sum

Co-authored-by: Ben Toogood <ben@micro.mu>
2020-03-23 16:19:30 +00:00
9826ddbd64 api/handler/rpc: log errors (#1390)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-23 10:31:35 +03:00
0987363
87617be227 Add client header to rpcRequest header; issue #957 (#1378)
Co-authored-by: Asim Aslam <asim@aslam.me>
2020-03-21 23:25:23 +00:00
d559587807 client/grpc: remove json-iterator usage (#1387)
* minimize external deps and binary size
* if user wants json-iterator codec it must be used in server and
  client code. so best to use it via go-plugins

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-21 09:40:58 +00:00
Janos Dobronszki
9501512219 Auth util func RequestToContext (#1386) 2020-03-20 15:23:12 +00:00
Asim Aslam
d2f153d795 Add type of service (#1385) 2020-03-20 12:48:12 +00:00
Asim Aslam
e49be1da42 fix local runtime (#1383) 2020-03-19 22:38:37 +00:00
Jake Sanders
4c6f68d537 Implement store read cache (#1366)
* Implement store read cache

* Added cache tests and fixed a bug in memory store
2020-03-19 18:19:07 +00:00
cbb958def5 config: fix panic on multiple Close() (#1374)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-19 12:54:59 +03:00
Asim Aslam
40ff6ddfcf sigh, further status changes (#1371) 2020-03-18 22:47:03 +00:00
Asim Aslam
5ad7c36bd4 Fix labels for k8s (#1370) 2020-03-18 22:13:21 +00:00
Asim Aslam
99c3fe2bb8 fix status parsing (#1368) 2020-03-18 21:50:52 +00:00
Asim Aslam
1bd340701b add k8s service ip to metadata (#1367)
* add k8s service ip to metadata

* go fmt

* use same port as container
2020-03-18 18:27:29 +00:00
Jake Sanders
c91bf7e9e7 [WIP] Store Sync (#1365)
* Initial cache implementation

* Write queue implementation

* Accidentally started writing the storage sync service
2020-03-18 16:39:36 +00:00
41f8a8cb00 errors: add FromError func (#1362)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-18 03:10:38 +03:00
ben-toogood
cd04111e3d Pass redirect_to param on auth (#1361)
Co-authored-by: Ben Toogood <ben@micro.mu>
2020-03-17 20:04:16 +00:00
ben-toogood
00cd2448a4 Fix bug where auth token is not set from cookie when excluded endpoint (#1360)
Co-authored-by: Ben Toogood <ben@micro.mu>
2020-03-17 19:24:10 +00:00
ben-toogood
8a41d369f2 Auth JWT ID Fix (#1359)
* Auth JWT ID Fix

* Remove unused ID in jwt claims

Co-authored-by: Ben Toogood <ben@micro.mu>
2020-03-17 16:59:57 +00:00
Jake Sanders
638c219736 Cockroach store feature completion (#1358)
* Start fixing cockroach store

* Add prefix, suffix, limit, offset for cockroachdb store
2020-03-17 16:15:23 +00:00
ben-toogood
b3c631dd38 Support Wildcard Auth Excludes (#1357)
Co-authored-by: Ben Toogood <ben@micro.mu>
2020-03-17 16:03:49 +00:00
ab73127063 grpc client/server fixes (#1355)
* grpc client/server fixes

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-17 14:27:20 +03:00
Asim Aslam
03031a694d use pod phase/status (#1356) 2020-03-16 23:47:34 +00:00
li.peng
5712aafba9 fix: context cancel (#1350)
Co-authored-by: Asim Aslam <asim@aslam.me>
2020-03-16 10:45:33 +00:00
ac333d9d47 client/grpc: unwrap error after call (#1352)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-16 13:33:38 +03:00
ben-toogood
247707f583 Return store.ErrNotFound if not found when calling over rpc (#1353)
Co-authored-by: Ben Toogood <ben@micro.mu>
2020-03-16 10:30:56 +00:00
ben-toogood
d91c14eb30 grpc client error fix (#1351)
Co-authored-by: Ben Toogood <ben@micro.mu>
2020-03-16 12:53:15 +03:00
Asim Aslam
ca8684a886 fix k8s issues (#1349) 2020-03-15 15:09:18 +00:00
Asim Aslam
0449138f61 fix panic (#1348) 2020-03-14 21:18:41 +00:00
609f4826b3 server: remove duplicate code (#1346)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-13 22:15:09 +00:00
60993e6275 config/source/service: base64 fix (#1345)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-13 21:44:55 +00:00
Asim Aslam
e803fb0855 Runtime hacks (#1344)
* Add Args/Image to runtime

* remove the hacks
2020-03-13 18:39:59 +00:00
3543b275e0 fix log level helper (#1342)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-13 17:36:42 +03:00
fbde872e7f Revert "server/grpc: fix ordering of register and check for registered (#1338)" (#1341)
This reverts commit 62a644ddd8.
2020-03-13 09:30:44 +00:00
Asim Aslam
078dd4eb9b fix etcd (#1340)
* fix etcd

* update go mod
2020-03-13 08:55:23 +00:00
62a644ddd8 server/grpc: fix ordering of register and check for registered (#1338)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-12 22:04:11 +00:00
Asim Aslam
d8cfa7a295 add config to cmd (#1337)
* add config to cmd

* fix build
2020-03-12 18:47:40 +00:00
ben-toogood
47f1203e97 Add Config to service options (#1336)
Co-authored-by: Ben Toogood <ben@micro.mu>
Co-authored-by: Asim Aslam <asim@aslam.me>
2020-03-12 18:13:03 +00:00
Jake Sanders
1b4e881d74 Rewrite the store interface (#1335)
* WIP store rewrite

* Fix memory store tests

* Store hard expiry times rather than duration!

* Clarify memory test

* Add limit to store interface

* Implement suffix option

* Don't return nils from noop store

* Fix syncmap

* Start fixing store service

* wip service and cache

* Use _ for special characters in cockroachdb namespace

* Improve cockroach namespace comment

* Use service name as default store namespace

* Fixes

* Implement Store Scope

* Start fixing etcd

* implement read and write with expiry and prefix

* Fix etcd tests

* Fix cockroach store

* Fix cloudflare interface

* Fix certmagic / cloudflare store

* comment lint

* cache isn't implemented yet

* Only prepare DB staements once

Co-authored-by: Ben Toogood <ben@micro.mu>
Co-authored-by: ben-toogood <bentoogood@gmail.com>
2020-03-12 13:41:30 +00:00
ben-toogood
20ce61da5a Oauth google fixes (#1330)
* Fix Auth Headers

* Tweak Oauth to work for Google

Co-authored-by: Ben Toogood <ben@micro.mu>
Co-authored-by: Asim Aslam <asim@aslam.me>
2020-03-12 13:11:35 +00:00
chengguoqiang
eef4825be4 Update etcd.go (#1334)
add leaseId to the trace log
2020-03-12 10:09:38 +00:00
Asim Aslam
be9c6141f5 delete options (#1333) 2020-03-12 09:05:09 +00:00
Asim Aslam
1ca4619506 return store.ErrNotFound (#1332) 2020-03-11 23:09:42 +00:00
Asim Aslam
f55493993c set namespace rather than key (#1331) 2020-03-11 22:31:24 +00:00
7b385bf163 minimize allocations in logger and tunnel code (#1323)
* logs alloc

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* fix allocs

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* fix allocs

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* tunnel allocs

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* try to fix tunnel

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* cache cipher for send

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* more logger

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* more logger

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* more logger

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* more logger

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* more logger

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* more logger

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* more logger

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-11 17:55:39 +00:00
Jake Sanders
4125ae8d53 Add secrets interface to config/secrets (#1325)
* Interface for secrets

* Add secretbox secrets implementation

* Start working on box

* typo

* Add asymmetric encryption implementation

* go mod tidy

* Fix review comments

Co-authored-by: Asim Aslam <asim@aslam.me>
2020-03-10 22:52:06 +00:00
ben-toogood
48b2a5c37c Fix Auth Headers (#1324)
Co-authored-by: Ben Toogood <ben@micro.mu>
2020-03-10 16:47:01 +00:00
Asim Aslam
ed83c27f0e add websocket streaming to api rpc handler (#1326) 2020-03-10 15:21:43 +00:00
241614ff68 add helper function to determine logger level (#1321)
* add helper function to determine logger level

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-09 23:43:05 +03:00
mlboy
1a4f608ed1 add: auth add generate options Expiry for set token expires (#1319)
Co-authored-by: mlboy <ml3@meitu.com>
Co-authored-by: Asim Aslam <asim@aslam.me>
2020-03-09 17:16:31 +00:00
43b0dbb123 tunnel: reduce allocation and improve performance (#1320)
* tunnel: reduce allocation and improve performance

BenchmarkSha256Old-16 100000 156748 ns/op 11835 B/op 168 allocs/op
BenchmarkSha256Old-16 100000 156229 ns/op 11819 B/op 168 allocs/op

BenchmarkSha256New-16 100000 154751 ns/op 11107 B/op 161 allocs/op
BenchmarkSha256New-16 100000 154263 ns/op 11110 B/op 161 allocs/op

simple change lowers allocations and brings performance

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* fix

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* tunnel: reuse buf in Decrypt

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* fix unneeded conversations

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* base32 string is smaller than hex string

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-09 17:10:08 +00:00
ben-toogood
b344171c80 URL Encode Provider.Endpoint() (#1317)
Co-authored-by: Ben Toogood <ben@micro.mu>
2020-03-09 10:21:49 +00:00
ben-toogood
e3ce45495a os.Exit on log.Fatal (#1316)
* os.Exit on log.Fatal

* Fix TestOptions

Co-authored-by: Ben Toogood <ben@micro.mu>
2020-03-09 09:23:42 +00:00
f01664a551 Merge pull request #1313 from micro/upstream
fix ipv6 address usage in mdns registry and util/addr
2020-03-07 23:50:03 +03:00
8ecbdc1cd6 registry/mdns: add logging for invalid endpoint
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-07 23:19:48 +03:00
55c19afb0b registry/mdns: fix ipv6 addr in mdns registry
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-07 23:17:00 +03:00
077063c212 util/addr: check ip addrs before return
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-07 23:13:56 +03:00
ben-toogood
9a7a65f05e Auth Provider (#1309)
* auth provider mock interface

* Auth Provider Options

* Implement API Server Auth Package

* Add weh utils

* Add Login URL

* Auth Provider Options

* Add auth provider scope and setting token in cookie

* Remove auth_login_url flag

Co-authored-by: Asim Aslam <asim@aslam.me>
Co-authored-by: Ben Toogood <ben@micro.mu>
2020-03-07 11:06:57 +00:00
8ee5607254 [WIP]: broker ErrorHandler option (#1296)
* broker ErrorHandler option

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* rewrite Event interface, add error

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* implement new interface

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* change ErrorHandler func to broker.Handler

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* fix

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-06 21:25:16 +00:00
11be2c68b9 util/stream: fix imports (#1310)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-06 21:17:57 +00:00
a864f812f1 web: fix ipv6 address issue (#1308)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-06 18:44:56 +03:00
Asim Aslam
ae60bea8d8 add stream fix (#1305) 2020-03-06 14:40:47 +00:00
Jake Sanders
a851b9db7a Comment typo in gRPC subscriber (#1304) 2020-03-05 14:55:46 +00:00
d807dac2a7 server/grpc: avoid panic in case of nil Header (#1303)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-05 17:45:31 +03:00
ce2ba71002 server: subscribe to topic with own name if router not nil (#1295)
* server: subscribe to topic with own name if router not nil

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-05 10:29:50 +03:00
Asim Aslam
67c26c71b6 add jitter (#1298) 2020-03-04 15:37:17 +00:00
ben-toogood
9386f36a13 Exit on log.Fatal (#1297) 2020-03-04 13:46:01 +00:00
ben-toogood
6d803d9e45 Implement api/server/cors (#1294) 2020-03-04 11:40:53 +00:00
ben-toogood
6a9001bdb1 Set auth account in context (#1293) 2020-03-04 09:54:52 +00:00
Jake Sanders
3f0c28a815 Expiration is actually a unix timestamp (#1290)
* Expiration is actually a unix timestamp

* int -> int64
2020-03-03 18:15:50 +00:00
Asim Aslam
49ffc60afb Use Foo.Call on /foo (#1286)
Co-authored-by: Jake Sanders <i@am.so-aweso.me>
2020-03-03 16:47:15 +00:00
Jake Sanders
beb5e80e87 Fix nil pointer dereference (#1289) 2020-03-03 13:54:56 +00:00
Jake Sanders
eebd69c995 Change from renekroon/ttlcache to patrickmn/go-cache (#1288) 2020-03-03 13:35:49 +00:00
Jake Sanders
bc71989e2c int64 -> time.Duration (#1287) 2020-03-03 13:15:26 +00:00
89ba602e17 logger fixes and improvements (#1285)
* fix helper fields
* add metadata output for default logger

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-03 11:07:37 +03:00
Jake Sanders
f6102bde70 Add a cache to workers KV storage implementation (#1284)
* cloudflare-cache

* go mod tidy
2020-03-02 18:14:25 +00:00
Pieter Voorwinden
7cad77bfc0 Initialize header to prevent assignment to entry in nil map error (#1282)
Co-authored-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-02 19:17:26 +03:00
ben-toogood
1f2e067f71 k8s runtime - get status from pods (#1283) 2020-03-02 15:49:10 +00:00
b555269b1b copy fields in helper (#1281)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-03-02 14:18:36 +00:00
ben-toogood
9200c70202 Replace validation error with regex for cockroach namespace (#1270)
Co-authored-by: Asim Aslam <asim@aslam.me>
2020-03-01 22:09:06 +00:00
Sumanth Chinthagunta
d8377e09c9 feat(dockerfile): adding dumb-init to base image (#1278) 2020-02-29 21:55:15 +00:00
0754229878 broker/memory: add codec support (#1276)
allow easy testing of other services with memory broker
and also allows to more deeply simulate real brokers

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-02-29 23:00:29 +03:00
6b8930a960 add new helper method to logger (#1273)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-02-29 00:39:41 +00:00
d0a978bd50 redesign logger (#1272)
* redesign logger

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-02-29 03:31:59 +03:00
ben-toogood
afe6861e2f Update the k8s deployment to use metadata labels & custom source (#1271) 2020-02-28 15:07:55 +00:00
ben-toogood
962567ef42 Implement config singleton (#1268)
* Implement config singleton

* Pass token in grpc request headers

* Refactor BearerScheme

* Fix typo
2020-02-28 12:58:27 +00:00
Asim Aslam
e21ed3a183 gen account on base32 decode failure (#1269) 2020-02-27 16:11:05 +00:00
64a5ce9607 various fixes (#1267)
* logger: remove Panic log level

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* server/grpc: add missing Unlock in Subscribe error

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* server: minor code change

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* server/grpc: extend test suite with pub/sub testing

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* server/grpc: fix invalid check and allow subscriber error to be returned

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* server/grpc: add pubsub tests

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* client/grpc: check for nil req/rsp

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-02-26 18:34:40 +00:00
Asim Aslam
d651b16acd generate pseudo accounts (#1264)
* generate pseudo accounts

* when you think you're being clever

* return garbage pseudo account when no token
2020-02-26 13:42:32 +00:00
Eric
1034837f69 Adjusting the BeforeStart () position (#1263)
Co-authored-by: Asim Aslam <asim@aslam.me>
2020-02-26 11:44:10 +03:00
Lars Lehtonen
80f2bfd5d0 config: remove unused sep variable (#1262) 2020-02-26 08:25:33 +00:00
Asim Aslam
6aaaf54275 add MICRO_AUTH_TOKEN, parse token in wrapper, preload config and othe… (#1261)
* add MICRO_AUTH_TOKEN, parse token in wrapper, preload config and other things

* fix wrapper panic
2020-02-25 22:15:44 +00:00
Di Wu
603d37b135 Set option and cli args to the service profile (#1259) 2020-02-25 16:42:42 +00:00
Eric
53c3bff819 add Panic & Panicf to logger (#1258)
* add Panic & Panicf to logger
2020-02-25 17:44:29 +03:00
ben-toogood
dcf859098b Fix k8s commands for github (#1257) 2020-02-25 11:39:03 +00:00
b4a743898e fix router panic (#1254)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-02-24 23:15:59 +00:00
ben-toogood
f1e7ea3020 Handle non IsNotExist errors in config (#1251)
Co-authored-by: Asim Aslam <asim@aslam.me>
2020-02-24 18:07:11 +00:00
ben-toogood
5e8d5834eb Dynamic Runtime source for k8s with github packages (#1252)
* Dynamic Runtime source for k8s

* Still check for source

* Replace / with - for k8s service names

* Simplify sourceForName function
2020-02-24 17:47:47 +00:00
ben-toogood
ffdf986aac Refactor auth: add token and store implementations (#1230)
* Refactor auth: add token and memory implementations

* Fix typo

* Remove memory auth (implemented already by the store implementation), revert default to noop

* Add grpc header

* Global Config

* config/global => util/config

* Rename package to remove confict

* Tweak

* Improve Error Handling
2020-02-24 15:07:27 +00:00
Jake Sanders
56f8115ea8 Rename PR job (#1250) 2020-02-24 14:16:51 +00:00
5b0175c2e5 allocations improvements and tunnel fixes (#1248)
* reduce allocations in tunnel code

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* another allocation fix

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* allocate maps with len if it known

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* allocate key for send once

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-02-24 14:15:20 +00:00
Jake Sanders
01d88601c0 Split PR and merge tests (#1249) 2020-02-24 14:11:17 +00:00
Lars Lehtonen
d467236f8f broker/nats: remove unused setPublishOption() (#1234)
broker/nats: remove unused setSubscribeOption()
2020-02-24 13:49:27 +00:00
24d574ae71 server/grpc: add MaxConn option to limit max inflight requests (#1247)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-02-24 13:48:56 +00:00
cf0b39eaac logger fixes (#1244)
* logger: fix race conditions

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* restore util/log for compatibility

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-02-24 13:07:40 +00:00
1f767ba18c update go modules (#1240)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-02-23 20:47:44 +00:00
Asim Aslam
915c424213 Add docker build (#1239) 2020-02-23 15:57:21 +00:00
117f56ebf7 prune util/log and user logger (#1237)
* prune util/log and user logger

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* plaintext logger

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* add newline

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-02-23 13:45:20 +00:00
Gao.QiLin
ceed8942fc Update README.md change godoc => go.dev (#1236)
* Update README.md add go dev

* Update README.zh-cn.md add go dev
2020-02-22 08:56:42 +00:00
d1e25e7ead add metadata set method (#1232)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-02-21 23:04:47 +03:00
Jake Sanders
7e24c0c1cf Also run tests on PR (#1233) 2020-02-21 17:57:07 +00:00
Jake Sanders
ca251ba111 Switch from Travis CI to GitHub Actions (#1231)
* Create Github Action to run tests on push

* -v

* Update tests.yml

* TODO: Fix tests

* Fix colours

* Delete .travis.yml

* Update tests.yml

* builds -> build
2020-02-21 17:43:50 +00:00
Asim Aslam
116855572b Add log level helper funtions (#1229) 2020-02-21 08:43:23 +00:00
Asim Aslam
ee977acfef strip SetGlobalLevel (#1228) 2020-02-21 08:28:21 +00:00
Sumanth Chinthagunta
3fa7c26946 logger with helper methods (#1216)
* support unix daemon socket

* refactor(logger): logger fields changed to map[string]interface{}

* improvement(logger): adding string to Level Parser

* improvement(logger): rename ParseLevel to GetLevel

* refactor(logger): adding basic logger

adding micro default logger, and refactor logger interface

* refactor(logger): moved basic logger to top level package

* refactor(logger): adding default logger
2020-02-21 07:57:59 +00:00
Lars Lehtonen
88457b812e tunnel: Prune Unused Functions (#1224)
* tunnel: remove unused link.setLoopback()

* tunnel: remove unused link.accept()

* tunnel: remove unused link.connect()
2020-02-20 17:05:49 +00:00
Asim Aslam
78df154a4d move log level setting to option (#1222) 2020-02-20 08:26:12 +00:00
Lars Lehtonen
c7eed618c2 server/grpc: Prune Unused Code (#1220)
* server/grpc: remove unused grpcServer.newCodec()

* server/grpc: remove unused defaultRPCCodecs
2020-02-19 20:58:22 +00:00
ben-toogood
36bcd3bd82 Improve JWT Package Errors (#1206)
Co-authored-by: Asim Aslam <asim@aslam.me>
2020-02-19 09:51:43 +01:00
Asim Aslam
f4118dc357 secure the grpc client (#1215)
* secure the grpc client

* make compile

* Add system cert pool

* Revert manually adding ca certs

* Tweak comment

Co-authored-by: ben-toogood <bentoogood@gmail.com>
2020-02-19 08:44:35 +00:00
58598d0fe0 fixes for safe conversation and avoid panics (#1213)
* fixes for safe convertation

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* fix client publish panic

If broker connect returns error we dont check it status and use
it later to publish message, mostly this is unexpected because
broker connection failed and we cant use it.
Also proposed solution have benefit - we flag connection status
only when we have succeseful broker connection

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* api/handler/broker: fix possible broker publish panic

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-02-18 23:05:38 +00:00
6248f05f74 add missing option to client.NewMessage (#1212)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-02-18 14:18:59 +03:00
ben-toogood
aa9a0a8d23 Fix Micro Proxy nil Transport Bug (#1208) 2020-02-17 12:28:48 +03:00
ben-toogood
1e40c86dfe Ignore gRPC Proxy (#1205) 2020-02-17 08:14:45 +00:00
Asim Aslam
9696efde02 reorder auth interface (#1204) 2020-02-16 19:36:45 +00:00
Asim Aslam
b3fc8be24e normalise proxy name (#1203) 2020-02-15 21:57:30 +00:00
Sumanth Chinthagunta
fc5339a368 [W.I.P] refactor(logger): logger fields changed to map[string]interface{} (#1198)
* support unix daemon socket

* refactor(logger): logger fields changed to map[string]interface{}

* improvement(logger): adding string to Level Parser

* improvement(logger): rename ParseLevel to GetLevel
2020-02-15 18:19:28 +00:00
Asim Aslam
964b7dee3f add tls config to server (#1202)
* add tls config

* add TLSConfig to acme provider
2020-02-15 15:10:26 +00:00
Asim Aslam
158949d0d0 accept Listen option in grpc server (#1201) 2020-02-15 14:09:24 +00:00
Asim Aslam
eed8a0bf50 delete proxy cached route before updating (#1200) 2020-02-15 12:05:22 +00:00
Asim Aslam
c691d116ab when the stream errors cleanup the connection (#1199) 2020-02-15 11:35:08 +00:00
Eric
cbe8b7dd09 Removed redundant spaces (#1196) 2020-02-14 10:32:02 +03:00
Asim Aslam
203486fd31 check for etcd watcher canceled value 2020-02-13 22:34:56 +00:00
Asim Aslam
d9b3b17582 set dial timeout in stream 2020-02-13 18:51:32 +00:00
ben-toogood
e080ecb43a Auth Improvements (#1195)
* Exclude Stats & Trace from Auth

* Update Excluded Endpoints Format

* Tweak Implementation
2020-02-13 14:07:14 +00:00
ben-toogood
ea70711dd3 Exclude Stats & Trace from Auth (#1192) 2020-02-13 12:02:29 +00:00
6dc942bc19 client/grpc: fix panic on invalid message (#1191)
* client/grpc: fix panic on invalid message
* travis: disable lint and race for now

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-02-13 14:57:21 +03:00
Janos Dobronszki
d76baf59de Trace type is now being recorded (#1188) 2020-02-12 10:57:17 +00:00
79ad1e6fe3 various fixes for broker and messaging in server (#1187)
* provide broker disconnect messages in server

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* broker/eats: another fix

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-02-11 18:41:23 +00:00
2764de9a1a broker/eats: broker disconnect fix (#1186)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-02-11 15:46:50 +00:00
Asim Aslam
d1d6eada98 parse url encoded form in rpc handler (#1183)
* parse url encoded form in rpc handler

* Remove comment
2020-02-11 11:27:16 +00:00
ben-toogood
4a03183481 Return a 401 error on invalid auth tokens (#1184) 2020-02-11 11:22:22 +00:00
Asim Aslam
8ea84ac3eb Fix router panic for nil watcher 2020-02-10 15:38:41 +00:00
ben-toogood
4401c12e6c Auth Wrapper (#1174)
* Auth Wrapper

* Tweak cmd flag

* auth_excludes => auth_exclude

* Make Auth.Excludes variadic

* Use metadata.Get (passes through http and http2 it will go through various case formats)

* fix auth wrapper auth.Auth interface initialisation

Co-authored-by: Asim Aslam <asim@aslam.me>
2020-02-10 08:26:28 +00:00
c706afcf04 logger helper to pass down it via context (#1180)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-02-09 21:26:46 +00:00
Lars Lehtonen
ca1d0b94c3 config/cmd: remove 8 unused variables (#1175) 2020-02-08 11:19:10 +00:00
67acd9288b config/source/cli: fix tests (#1179)
* config/source/cli: fix tests
* skip mdns test in travis

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-02-08 02:45:32 +03:00
0bf6c9fc08 config/source/cli: fix default flag value loading (#1178)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-02-08 02:14:34 +03:00
99807a680c strip Micro-Topic header from incoming context in client.Call (#1177)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-02-07 22:09:52 +00:00
f0f7f860d6 add some docs (#1176)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-02-07 21:48:24 +00:00
Asim Aslam
ef537270ad Don't store traces for Debug endpoints 2020-02-07 20:58:03 +00:00
Asim Aslam
c7f075d157 rename file 2020-02-07 14:00:27 +00:00
Asim Aslam
812ea78604 Fix runtime deadlock 2020-02-07 14:00:09 +00:00
Asim Aslam
0755084a59 fix deadlock 2020-02-07 13:55:55 +00:00
ben-toogood
fe7f5a4134 Runtime Retries Limit (#1163)
* Implement Runtime Retries

* Remove Debug

* Action Feedback

* Refactor Retries

* Fix WithRetires Typo
2020-02-07 12:02:41 +00:00
ben-toogood
19c454ec4b Fix Local Runtime Default Command (#1173)
* Auth API Proto

* Fix local runtime bug

* Add Platform Proto

* Restructuring
2020-02-07 11:39:26 +00:00
Asim Aslam
0e9b4c26a4 import with braces 2020-02-06 21:39:08 +00:00
Asim Aslam
d40b13a045 mux to mtx 2020-02-06 21:37:17 +00:00
Asim Aslam
4079b22c1e reorder logger methods 2020-02-06 21:36:33 +00:00
Shu xian
fdfb2bc4c1 [WIP] logger first (#1161)
* logger first

* log->logger

* update comment

* add context in Options

* add Fields

* remove logfi

* add field encode

* add common Field Types

* update logger field
2020-02-06 21:35:46 +00:00
Asim Aslam
dbeb7cfe9c remove errors import 2020-02-06 18:45:12 +00:00
Asim Aslam
512df2628f trim source url if its set to github.com/ 2020-02-06 18:34:16 +00:00
Janos Dobronszki
92571db693 Tracing: traces now correctly form a tree (#1170)
* First cut of trace

* Dial it back yo

* Defensive programming
2020-02-06 17:22:16 +00:00
ben-toogood
16552620e0 Runtime Custom Source (Part 2) (#1169) 2020-02-06 16:16:01 +00:00
Ben Toogood
5414195dc3 Add Args 2020-02-06 12:31:54 +00:00
Ben Toogood
0591760932 Arg => Args 2020-02-06 12:17:16 +00:00
Ben Toogood
48b9f3f5e9 Fix 2020-02-06 11:28:34 +00:00
Ben Toogood
e46278a766 Test 2020-02-06 11:24:56 +00:00
Ben Toogood
2925b1615c Fix 2020-02-06 11:15:30 +00:00
Ben Toogood
fc4191c647 Fix 2020-02-06 11:12:40 +00:00
Ben Toogood
111126c780 Debugging 2020-02-06 11:00:14 +00:00
Ben Toogood
54371bba6a Debugging 2020-02-06 10:55:41 +00:00
Ben Toogood
c28737e88e Debugging 2020-02-06 10:54:11 +00:00
Ben Toogood
c7d922fac2 Debugging 2020-02-06 10:49:01 +00:00
Ben Toogood
f8e696bd30 Debugging 2020-02-06 10:44:12 +00:00
Ben Toogood
6aef28dad2 Runtime set service source 2020-02-06 10:33:23 +00:00
7105e4099c pass micro errors from grpc server to grpc client (#1167)
* pass micro errors from grpc server to grpc client

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* wrap micro errors.Error to grpc status

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-02-06 10:18:33 +00:00
Ben Toogood
f0762bbb6b Improve Logging 2020-02-06 10:16:32 +00:00
Ben Toogood
243c6a4246 Debug 2020-02-06 10:08:56 +00:00
Ben Toogood
9983aea928 Tidying Up 2020-02-06 09:29:27 +00:00
Ben Toogood
aa58a9749b Action Asim's Feedback 2020-02-06 09:17:10 +00:00
ben-toogood
d8110b70a3 Runtime custom docker img (#1168)
* Add DeploymentOptions to K8s Client

* WithBaseImage for  Runtime

* Revert Change

* Fix sequencing
2020-02-06 08:52:25 +00:00
a44dc90d45 fix ctx.Done issue #720 (#1166)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-02-05 21:13:14 +00:00
Shu xian
12181bd441 fix LevelInfo > LevelWarn (#1162) 2020-02-05 18:16:57 +00:00
Ben Toogood
8d44f7226f Merge branch 'master' of https://github.com/micro/go-micro 2020-02-05 13:59:51 +00:00
ben-toogood
bf747a86f4 Runtime (#1160)
* Add String to Runtime interface

* Setup Dynamic Runtime Configuration
2020-02-05 13:59:35 +00:00
Lars Lehtonen
4333f00a43 runtime/kubernetes: remove unused constants (#1159) 2020-02-04 21:02:05 +00:00
7ab3a31ac4 update micro/cli, tidy mod (#1156)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-02-03 23:29:44 +00:00
Ben Toogood
a1d5d6831f Add String to Runtime interface 2020-02-03 15:56:16 +00:00
ben-toogood
1b9cabd654 Update Micro Auth Protocol Buffer to use V2 (#1155) 2020-02-03 08:26:57 +00:00
ben-toogood
d621548120 Auth (#1147)
Implement the Auth interface, with JWT and service implementations.

* Update Auth Interface

* Define Auth Service Implementation

* Support Service Auth

* Add Auth Service Proto

* Remove erronious files

* Implement Auth Service Package

* Update Auth Interface

* Update Auth Interface. Add Validate, remove Add/Remove roles

* Make Revoke interface more explicit

* Refactor serializing and deserializing service accounts

* Fix srv name & update interface to be more explicit

* Require jwt public key for auth

* Rename Variables (Resource.ID => Resource.Name & ServiceAccount => Account)

* Implement JWT Auth Package

* Remove parent, add ID

* Update auth imports to v2. Add String() to auth interface
2020-02-03 08:16:02 +00:00
tpam28
449bcb46fe New backoff (#1153)
* new backoff function

* use backoff from util/backoff

* remove reset atemts

* change comment

* fmt
2020-02-02 20:32:55 +00:00
Asim Aslam
079102ea59 Merge branch 'master' of ssh://github.com/micro/go-micro 2020-02-02 19:50:09 +00:00
Asim Aslam
a9d371e727 fatal on command error 2020-02-02 19:49:59 +00:00
Asim Aslam
27efbc8779 Merge pull request #1150 from unistack-org/grpc_race
fix map race condition in grpc server
2020-02-01 00:10:46 +00:00
efb59d9709 fix map race condition in grpc server
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-02-01 02:52:53 +03:00
Asim Aslam
003f00b483 Merge branch 'master' of ssh://github.com/micro/go-micro 2020-01-30 23:24:54 +00:00
Asim Aslam
0be22c98c6 add tracing 2020-01-30 23:24:46 +00:00
Asim Aslam
bafedf1aad Merge pull request #1149 from alrs/remove-unused-kubernetes-variable
runtime/kubernetes: remove unused name variable
2020-01-30 17:30:43 +00:00
Lars Lehtonen
98d55545fd runtime/kubernetes: remove unused name variable 2020-01-30 09:25:50 -08:00
Asim Aslam
5f6271b044 Merge pull request #1148 from tpam28/master
fix test and description
2020-01-30 17:09:41 +00:00
Evgeniy
87753ad289 format results in TestBacloff 2020-01-30 20:08:03 +03:00
Evgeniy
ffb9da0230 fix test and description 2020-01-30 19:43:03 +03:00
Asim Aslam
50ac642666 Merge pull request #1146 from tpam28/master
exponentialBackoff was changed from power function to exponential
2020-01-30 14:35:17 +00:00
Evgeniy
f6fcfcb8fc exponentialBackoff was changed from power function to exponential function 2020-01-30 17:25:07 +03:00
Asim Aslam
21e0932339 Merge pull request #1144 from unistack-org/v2
fix import paths for v2 release
2020-01-30 11:46:29 +00:00
f23638c036 fix import paths for v2 release
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-01-30 14:44:40 +03:00
Asim Aslam
2b1e0a6fd6 go mod tidy 2020-01-30 10:33:40 +00:00
Asim Aslam
0889b814bb Merge pull request #1143 from crufter/bump-dep
Bump dep to fix platform web using new debug.Stats proto fields
2020-01-30 10:31:12 +00:00
Janos Dobronszki
a648c0d99c Bump dep to fix platform web using new debug.Stats proto fields 2020-01-30 10:27:21 +00:00
Asim Aslam
a291af59c4 Merge pull request #1142 from micro/tracing
Fix null tracer bug
2020-01-30 07:55:58 +00:00
Ben Toogood
d9f12731e1 Fix null tracer bug 2020-01-30 07:53:31 +00:00
Asim Aslam
4a838a8210 Merge branch 'master' of ssh://github.com/micro/go-micro 2020-01-29 23:14:16 +00:00
Asim Aslam
5969cc358e nats-e => eats 2020-01-29 23:14:05 +00:00
Asim Aslam
9f1a7e1139 Merge pull request #1127 from Allenxuxu/master
handle Loader.Load  return value error
2020-01-29 22:44:29 +00:00
Asim Aslam
dc257f5066 update to fix tracer 2020-01-29 22:43:40 +00:00
Asim Aslam
49b86c56e3 go fmt 2020-01-29 22:40:43 +00:00
Asim Aslam
1be8258721 fix initialisation 2020-01-29 22:39:31 +00:00
Asim Aslam
b2980aecb7 fix debug handler in proxy 2020-01-29 22:31:57 +00:00
Asim Aslam
de3c3b27b2 Merge pull request #1140 from micro/tracing
Tracing by Ben Toogood
2020-01-29 22:28:49 +00:00
Micro
a09eea8d4d Update the Debug Handler to use the servers tracer 2020-01-29 16:05:58 +00:00
Micro
62c067adcd Refactor debug/trace ready for Jaeger 2020-01-29 15:45:11 +00:00
Asim Aslam
59f6ca5564 Merge pull request #1139 from alrs/prune-unused-config-reader-func
config/reader/json: remove unused newValue()
2020-01-28 19:50:03 +00:00
Lars Lehtonen
895aa896bc config/reader/json: remove unused newValue() 2020-01-28 11:38:55 -08:00
Asim Aslam
74762edc42 Merge pull request #1138 from printfcoder/master
cockroach store supports URL connection string
2020-01-28 17:59:49 +00:00
shu xian
101017a29c cockroach supports URL connection string 2020-01-29 00:47:41 +08:00
Shu xian
c725b4c797 Merge pull request #3 from micro/master
merge
2020-01-29 00:45:27 +08:00
Asim Aslam
1108cc5e91 Merge pull request #1136 from unistack-org/flags
update micro/cli to urfave/cli/v2 and fix go-micro
2020-01-26 19:12:06 +00:00
Asim Aslam
6a9f5fac61 fire send in a go routine to prevent blocking other requests 2020-01-25 23:16:00 +00:00
e6a34bcbe7 update micro/cli to urfave/cli/v2 and fix go-micro
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-01-25 15:57:08 +03:00
Asim Aslam
1d00f2f771 add trace handler 2020-01-24 22:02:35 +00:00
Asim Aslam
4a6570a772 trace wrapper 2020-01-24 21:58:29 +00:00
Asim Aslam
a997a86e49 add trace context 2020-01-24 21:44:48 +00:00
Asim Aslam
2d28ff72d7 add trace 2020-01-24 21:32:07 +00:00
Asim Aslam
2b1844971c go fmt 2020-01-24 21:31:57 +00:00
Asim Aslam
49cc022ca2 add trace to handler 2020-01-24 21:29:29 +00:00
Asim Aslam
8d2dc8a822 trace Read endpoint 2020-01-24 21:24:51 +00:00
Asim Aslam
eeb6944ce5 Merge pull request #1133 from alrs/drop-unused-broker-code
broker: drop unused registryKey variable
2020-01-23 21:57:58 +00:00
Lars Lehtonen
add78f2967 broker: drop unused registryKey variable 2020-01-23 12:51:57 -08:00
Shu xian
bd6a5af2b5 Merge pull request #2 from micro/master
merge
2020-01-23 22:17:54 +08:00
Asim Aslam
ae08e9c106 check if event is nil 2020-01-23 12:41:22 +00:00
Asim Aslam
77c2a021da Add event id to router events 2020-01-23 11:44:06 +00:00
Asim Aslam
1c19678d04 Update proto Service => Config 2020-01-23 11:37:54 +00:00
Asim Aslam
6d636b7ab3 whoa bad commit, bad asim 2020-01-22 17:07:56 +00:00
Asim Aslam
009c598049 Change version to latest 2020-01-22 17:03:38 +00:00
Asim Aslam
5cceb00df2 Merge pull request #1131 from micro/router-refactor
refactor and cleanup some router code
2020-01-22 16:54:20 +00:00
Asim Aslam
3e24276eb1 fix break 2020-01-22 16:44:34 +00:00
Asim Aslam
29c1076950 refactor and cleanup some router code 2020-01-22 16:33:31 +00:00
Asim Aslam
8dbacb34f8 Merge pull request #1118 from printfcoder/master
add mucp for config/source
2020-01-21 22:35:35 +00:00
Asim Aslam
8b306780ee Merge pull request #1130 from micro/net-noloop
avoid connecting to self
2020-01-21 15:05:33 +00:00
Asim Aslam
9f7d374691 avoid connecting to self 2020-01-21 12:36:05 +00:00
Asim Aslam
a18e53f028 Merge branch 'master' of ssh://github.com/micro/go-micro 2020-01-20 21:31:16 +00:00
Asim Aslam
2208839027 Merge pull request #1129 from alrs/remove-unused-server-var
server: remove unused invalidRequest
2020-01-20 18:24:42 +00:00
Lars Lehtonen
7a17a221ff server: remove unused invalidRequest 2020-01-20 10:09:27 -08:00
Shu xian
8e1ff80b9e Merge pull request #1 from micro/master
merge
2020-01-20 20:08:21 +08:00
shu xian
94bb0f4c08 watch supports path 2020-01-20 18:31:18 +08:00
Allenxuxu
dbe209ebe4 Merge branch 'master' of https://github.com/micro/go-micro 2020-01-20 08:37:34 +08:00
Asim Aslam
fa0d884cfe fix bad import 2020-01-19 23:31:09 +00:00
Asim Aslam
ed2bd68d28 fix break in router service 2020-01-19 23:22:41 +00:00
Asim Aslam
97928e88f8 stop watcher 2020-01-19 23:15:57 +00:00
Asim Aslam
04cf86070c close stream 2020-01-19 22:55:57 +00:00
Asim Aslam
9df19e826e cancel stream 2020-01-19 22:53:56 +00:00
Asim Aslam
3f3c1919f4 strip certain plugins 2020-01-19 17:56:59 +00:00
Asim Aslam
d918694346 reorganise runtime 2020-01-19 17:47:27 +00:00
Asim Aslam
54fb61bba4 Move proto to service/ 2020-01-19 17:31:24 +00:00
Asim Aslam
fac75866d9 Move pool to util 2020-01-19 17:30:49 +00:00
Asim Aslam
a47ff65529 remove mock client 2020-01-19 17:24:22 +00:00
Asim Aslam
093bcedfe7 remove http broker 2020-01-19 17:21:55 +00:00
Asim Aslam
7b6d560bec Update README.md 2020-01-19 13:55:23 +00:00
Asim Aslam
43aa4e23bd update readme 2020-01-19 13:51:31 +00:00
Asim Aslam
bdd9ec560b strip sub comments 2020-01-19 13:47:14 +00:00
Asim Aslam
0c03bf064b only connect broker if there are subscribers 2020-01-19 13:45:28 +00:00
Asim Aslam
9a8c1b7ab8 update broker 2020-01-19 13:35:23 +00:00
Asim Aslam
e1ca40c1fc go fmt 2020-01-19 13:32:30 +00:00
Asim Aslam
e75b99f89c go fmt 2020-01-19 13:32:24 +00:00
Allenxuxu
ee7304a795 NewConfig return value error 2020-01-19 16:42:05 +08:00
Allenxuxu
a82fd19209 handle Loader.Load return value error 2020-01-19 16:31:02 +08:00
Asim Aslam
1983d607f3 set nats-e 2020-01-19 01:47:30 +00:00
Asim Aslam
10093a0ea2 set to nats-e 2020-01-19 01:29:00 +00:00
Asim Aslam
fc08a9146c Add broker comments on server subscribe 2020-01-19 01:16:36 +00:00
Asim Aslam
cafd280718 Default to grpc in registry service for now 2020-01-19 01:13:14 +00:00
Asim Aslam
11b104677a Shift embedded nats to the default 2020-01-19 00:55:01 +00:00
Asim Aslam
105596a0e5 use mucp server 2020-01-18 20:48:08 +00:00
Asim Aslam
0a37767127 Fix service registration with registry service 2020-01-18 19:53:51 +00:00
Asim Aslam
31e195bac7 strip image pull policy always 2020-01-18 18:37:38 +00:00
Asim Aslam
bdf1d20f4e extract an ip that can be advertised in embedded nats 2020-01-18 15:39:26 +00:00
shu xian
8d6f82707a update to standard name convention 2020-01-18 23:16:23 +08:00
Asim Aslam
058fd8adbf trace 1 2020-01-18 10:20:46 +00:00
Asim Aslam
13d1d2fa08 hard stop if graceful stop fails after 1 second 2020-01-18 10:18:23 +00:00
Asim Aslam
e666d0b807 add missing commit 2020-01-18 02:28:44 +00:00
Asim Aslam
39d7938405 Extract k8s run error 2020-01-18 02:13:24 +00:00
Asim Aslam
65df711b01 move nats local logic 2020-01-18 01:29:53 +00:00
Asim Aslam
fd6eb23307 do not wait to stop 2020-01-18 00:58:27 +00:00
Asim Aslam
fb3927fb8c Merge pull request #1126 from milosgajdos83/metric-update
Update route metric when receiving Sync routes
2020-01-17 18:29:55 +00:00
Milos Gajdos
891af703be Update route metric when receiving Sync routes 2020-01-17 18:24:36 +00:00
Asim Aslam
474472eedd Merge pull request #1124 from milosgajdos83/flush-advert-query
Use the same logic for advertising routes in Router and Network
2020-01-17 16:49:11 +00:00
Milos Gajdos
23d65145e6 Use the same logic for advertising routes in Router and Network
router.Query() allows to query the routes with given router.Strategy.
It uses the same logic as was implemented in flushRoutes but the code
was never updated. This way we are consistent across both router and
network packages.
2020-01-17 16:25:18 +00:00
shu xian
9ea4919b9b rename mucp source directory to service 2020-01-17 23:53:33 +08:00
Asim Aslam
f78e30770e Merge pull request #1123 from milosgajdos83/sync-metric
Update route metric before sending the Sync message
2020-01-17 15:44:49 +00:00
Milos Gajdos
bf9f319cdf Update route metric before sending the Sync message 2020-01-17 15:38:28 +00:00
shu xian
ad28b72dd3 rename mucpSource to service 2020-01-17 23:27:41 +08:00
Asim Aslam
8425ae77f8 Merge pull request #1122 from micro/blocking
don't block forever
2020-01-17 15:24:03 +00:00
Asim Aslam
d7b9b2713b don't block forever 2020-01-17 15:23:10 +00:00
Asim Aslam
be788415ad minor runtime fixes 2020-01-17 14:14:47 +00:00
shu xian
a03791c581 set DefaultClient 2020-01-17 21:32:00 +08:00
Asim Aslam
ee922a3da6 Merge pull request #1121 from milosgajdos83/no-routes-found
Continue processing Sync if no routes were returned from router Query
2020-01-17 13:05:47 +00:00
Milos Gajdos
624f1c1980 Continue processing Sync if no routes were returned from router Query 2020-01-17 12:58:13 +00:00
Milos Gajdos
607a226e34 Updated debug logs to make them less verbose 2020-01-17 12:14:56 +00:00
Asim Aslam
bac1bbfd97 Merge pull request #1120 from milosgajdos83/remove-solicit
Remove Solicitation from the network
2020-01-16 20:02:05 +00:00
Milos Gajdos
7f9b3b5556 Remove Solicitation from the network
Instead, when a new peer is discovered it is sent a sync message i.e. we
do the full sync when discovering peers
2020-01-16 19:43:10 +00:00
Asim Aslam
ba12513199 Merge pull request #1119 from milosgajdos83/sync-best-routes-only
Send only best routes via Sync. Only apply best routes.
2020-01-16 18:17:26 +00:00
Milos Gajdos
8fcfbc0d20 Strip unnecessary continue statement 2020-01-16 17:33:53 +00:00
Milos Gajdos
472186c1be Code consistency. Small bug fix. 2020-01-16 17:04:04 +00:00
Milos Gajdos
60c05bd899 Find the best routes in the routes we would advertise based on Strategy 2020-01-16 16:53:39 +00:00
Milos Gajdos
793e6013e5 Advertise routes with configured strategy. Simplify Sync apply logic 2020-01-16 16:42:23 +00:00
shu xian
071ab7aede add mucp for config/source 2020-01-17 00:10:15 +08:00
Milos Gajdos
eda8b00f84 Send only best routes via Sync. Only apply best routes. 2020-01-16 16:08:49 +00:00
Asim Aslam
eac2ab3c28 Merge pull request #1117 from micro/scheduler
Switch notifier to scheduler
2020-01-16 13:41:13 +00:00
Asim Aslam
76fba34c2f Merge pull request #1116 from milosgajdos83/query-strategy
QueryStrategy to allow querying routes based on Advertising Strategy
2020-01-16 13:39:39 +00:00
Asim Aslam
491a42d352 Switch notifier to scheduler 2020-01-16 13:34:04 +00:00
Milos Gajdos
5e85194a13 QueryStrategy to allow querying routes based on Advertising Strategy 2020-01-16 12:48:36 +00:00
Asim Aslam
689ae7cfc7 Storing tunnel.Session rather than transport.Client 2020-01-16 00:28:58 +00:00
Asim Aslam
19dbd77402 fix net masking in listed routes 2020-01-16 00:12:38 +00:00
Asim Aslam
b194b3adc9 Merge pull request #1115 from micro/net-mask
mask the route before sending
2020-01-15 23:13:53 +00:00
Asim Aslam
33a9b3bc17 mask the route before sending 2020-01-15 23:06:58 +00:00
Asim Aslam
6562154573 Fix the next panic 2020-01-15 21:38:37 +00:00
Asim Aslam
b32ebddf85 update nlopes/slack dep 2020-01-15 21:22:07 +00:00
Asim Aslam
b3e3dac975 Merge branch 'master' of ssh://github.com/micro/go-micro 2020-01-15 21:02:58 +00:00
Asim Aslam
f20e4daa60 fix rand panic 2020-01-15 21:02:53 +00:00
Asim Aslam
f67d87e99d Merge pull request #1114 from milosgajdos83/network-backward-compatibility
Fixed bug:m network.proto backwards compatibility unmarshal
2020-01-15 19:57:57 +00:00
Milos Gajdos
36928b716c Fixed bug:m network.proto backwards compatibility unmarshal 2020-01-15 19:45:43 +00:00
Asim Aslam
7c7b0ced5f Merge pull request #1104 from milosgajdos83/network-hackery
[WIP] Network hackery
2020-01-14 20:28:32 +00:00
Milos Gajdos
c67ef7e017 Bug fix: skip sending sync message if the peer is not in our graph 2020-01-14 19:37:50 +00:00
Milos Gajdos
dcd925f1e5 Code cleanup; Indentation. 2020-01-14 18:48:42 +00:00
Milos Gajdos
0ea56a5ffe Fixed tests 2020-01-14 18:22:58 +00:00
Milos Gajdos
821fda41ae Added Status method to network.Node fixed random segfaults. 2020-01-14 18:12:36 +00:00
Asim Aslam
1d311ab457 Embedded NATS Broker (#1110)
* if the address is produced by a default route don't hash it

* embedded nats

* fix url parsing

* don't override help

* add ready flag
2020-01-14 13:23:16 +00:00
Asim Aslam
b699d969e4 if the address is produced by a default route don't hash it (#1108) 2020-01-14 11:20:13 +00:00
Milos Gajdos
994d371ff1 Removed redundant comments. Add proper PruneStalePeers test. 2020-01-14 10:49:34 +00:00
Milos Gajdos
a91dad04ee Increment node error count and prune when Max limit is hit 2020-01-13 22:22:12 +00:00
Milos Gajdos
b4261e8cf9 Updated log and comments 2020-01-13 20:14:30 +00:00
Milos Gajdos
efcac3d009 Define tunnel errors 2020-01-13 20:14:30 +00:00
Milos Gajdos
770c7686ba Fix nasty bug when graph action may not have been executed in some
branches
2020-01-13 20:14:30 +00:00
Milos Gajdos
11904e1137 Regular sync with network every 5 minutes. Apply routes before peering. 2020-01-13 20:14:29 +00:00
Milos Gajdos
1e009e52dd Avoid having the same log statements in initNodes and resolveNodes 2020-01-13 20:14:29 +00:00
Milos Gajdos
bf42c028fb Added sync message. Refactored connect flow. Adverts are gossipped.
This commit adds a Sync message which is sent as a reply to Connect
message. This should in theory speed up convergence of a (re)connecting
node.

We respond to Sync message by sending a peer message back to the peer
origin of the Sync message. We consequently update our routing table and
peer graph with the data sent in via Sync message.

We now gossip advertse to up to 3 randomly selected peers instead of
sending a multicast message to the network.

Equally, Solicitation i.e. full table adverts are gossipped to a
randomly selected peer. If that fails we send a multicast message to the
network.
2020-01-13 20:14:29 +00:00
Milos Gajdos
0a4bd02503 Add RefreshSync method for Sync bookkeeping 2020-01-13 20:14:29 +00:00
Milos Gajdos
63edfaa852 Added Sync message
Sync message will be sent between peers when a new node connects/joins
the network
2020-01-13 20:14:29 +00:00
Milos Gajdos
802cc8239a Send solicit message properly. Updated comments. 2020-01-13 20:14:29 +00:00
Matthew Costa
75b1a62af3 Replace service prefix with FQDN style prefix (#1107)
* Replace service prefix with FQDN style prefix

According to the k8s documentation, the label and annotation prefixes should be in the format of a FQDN, with dot separated labels of no more than 63 characters. The current label and annotation paramteres are rejected by the k8s api, most likely because they have two forward slashes in them.

* Use go.micro as service and annotation prefix
2020-01-12 14:37:12 +00:00
Maarten Bezemer
50b20413d3 RPC stream client/server mutex fix (#884)
* Unlock RPC client while actually receiving a message

As receiving a message might block for a long time, unblocking the client allows to let it send messages in the meanwhile without using 'tricks'

* Unlock RPC server while actually receiving a message

As receiving a message might block for a long time, unblocking the client allows to let it send messages in the meanwhile without using 'tricks'

* Protect Close() against race conditions

* Concurrency and Sequence tests
2020-01-12 09:13:14 +00:00
Shu xian
fa5b3ee9d9 config/reader.Values add Set for specific path merge (#1099)
* add Set for specific path merge

* add Set

* add Del
2020-01-11 20:50:09 +00:00
Asim Aslam
f50a50eeb3 go fmt 2020-01-10 21:54:36 +00:00
Asim Aslam
e1e6199743 normalise runtime service status 2020-01-10 21:54:28 +00:00
Asim Aslam
61dd2b8489 Merge branch 'master' of ssh://github.com/micro/go-micro 2020-01-10 19:13:59 +00:00
Asim Aslam
6ca298c61d set default store, fix store options bug, add String method 2020-01-10 19:13:55 +00:00
f4fb923fb2 pass additional context for broker subscribe (#1105)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-01-10 15:04:15 +00:00
shikbupt
32a2005f6d add option for web service signal handler (#1091) 2020-01-10 14:25:28 +00:00
Asim Aslam
37d1139a57 ensure we close the grpc stream (#1098)
* ensure we close the grpc stream

* use g.Close

* use closed bool flag for checking connection close
2020-01-09 17:00:14 +00:00
Asim Aslam
a90a74c9e2 Change the store interface to remove variadic args (#1095) 2020-01-08 22:23:14 +00:00
Milos Gajdos
78aed5beed Fixed tunnel race conditions. (#1094) 2020-01-08 14:48:38 +00:00
Milos Gajdos
59fccb82ec Updated comments. Tiny cleanup changes. (#1093) 2020-01-08 13:18:11 +00:00
Asim Aslam
048065fe96 support ability to set store, address and namespace via flags and env vars (#1092) 2020-01-08 12:11:31 +00:00
Asim Aslam
0b8ff3a8bb fix grpc json streaming by setting content sub type (#1089) 2020-01-07 18:37:34 +00:00
Asim Aslam
1892bd05a5 only add api endpoint metadata if it exists (#1087) 2020-01-06 22:22:36 +00:00
Asim Aslam
be6e8a7c78 add store to defaults (#1086) 2020-01-06 17:44:32 +00:00
Asim Aslam
df9055f69c continue to process messages even after the connection is closed 2020-01-03 20:43:53 +00:00
Asim Aslam
649dd235c3 Merge branch 'master' of ssh://github.com/micro/go-micro 2020-01-03 19:46:24 +00:00
Asim Aslam
1af82df8b1 Check link is grpc 2020-01-03 19:46:14 +00:00
Eagle Wu
7098e59b5c remove ignore error in method publish (#1075) 2020-01-03 17:24:19 +00:00
Shu xian
31362bc331 prevent resource leak (#1080) 2020-01-03 13:31:47 +00:00
Asim Aslam
4e2339749c Merge branch 'master' of ssh://github.com/micro/go-micro 2020-01-02 21:19:50 +00:00
Asim Aslam
9cecf2e097 make grpc proxy streaming work 2020-01-02 21:11:25 +00:00
Lars Lehtonen
fe9c68238f runtime/kubernetes: remove unused name variable (#1078) 2020-01-02 20:42:46 +00:00
Asim Aslam
225b17559b fix log streaming 2020-01-02 18:23:43 +00:00
Asim Aslam
e697912ee5 don't panic on nil 2020-01-01 21:56:29 +00:00
Asim Aslam
6358b9277d don't write anything if theres no data 2019-12-31 22:58:14 +00:00
Asim Aslam
45c986c5f1 don't marshal frame values 2019-12-31 21:36:22 +00:00
Asim Aslam
fa01ff6604 update ctx test 2019-12-31 13:53:48 +00:00
Asim Aslam
fe1e018e8e update wrapper test 2019-12-31 13:45:49 +00:00
Asim Aslam
60ea537bbc upper case the metadata 2019-12-31 13:37:29 +00:00
Asim Aslam
488dc31743 log when starting the service 2019-12-31 12:07:52 +00:00
Asim Aslam
b6915f0898 set grpc by default (#1070) 2019-12-30 18:33:21 +00:00
Asim Aslam
04dfe4e867 fix breaking test 2019-12-30 17:39:02 +00:00
Asim Aslam
d8fe030a4b go fmt 2019-12-30 17:29:57 +00:00
Asim Aslam
f40d4578d5 go fmt 2019-12-30 17:29:45 +00:00
Asim Aslam
e0078bbcd5 Remove use of config/cmd in api 2019-12-30 17:29:20 +00:00
Asim Aslam
c145f355dd Moving to gRPC by default (#1069)
* Step 1

* Fix the test panics
2019-12-29 21:07:55 +00:00
943445270f fix registry check issue (#1067)
fix #1066

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-12-28 11:11:46 +00:00
Asim Aslam
61cde4a9f4 Kubernetes Registry (#1064)
* add teh k8s registry

* add k8s reg config/cmd

* go mod update
2019-12-27 20:08:46 +00:00
jamsonzan
22aa7d14b3 support streams pool for grpc (#1062)
* Update grpc_pool.go

* Update options.go

* Update grpc.go

* Update grpc_pool_test.go

* streams pool for grpc

* use busy list to speed up allocate while pool is very busy

* fix idle bug
2019-12-27 12:25:58 +00:00
Eagle Wu
a09b6729cc Fix missing recover while occur panic in handler (#1063) 2019-12-27 10:53:11 +00:00
Asim Aslam
2fe64001c0 Start runtime services inline 2019-12-24 17:51:30 +00:00
Asim Aslam
14c9c412cd Move and rename 2019-12-24 17:45:17 +00:00
Asim Aslam
361fdfba04 move around k8s api 2019-12-24 17:42:22 +00:00
Asim Aslam
5c8d1ae2b9 Update k8s log options 2019-12-24 17:33:05 +00:00
Asim Aslam
81e20160f5 reorder 2019-12-23 08:49:53 +00:00
Asim Aslam
ef95b28e3d add Write method to config source 2019-12-23 08:42:57 +00:00
shikbupt
1781542964 fix etcd LogConfig bug (#1056) 2019-12-23 07:29:13 +00:00
Asim Aslam
45208992b5 NewLog 2019-12-20 23:36:16 +00:00
Asim Aslam
847a01df82 Cleanup k8s logs 2019-12-20 23:34:08 +00:00
Jake Sanders
ce33e3b072 Kubernetes logging (#1054)
* wip

* Implementation of Kubernetes Logger

* Missing file

* Skip test in Travis
2019-12-20 23:16:05 +00:00
Asim Aslam
ae12fd1021 update crap logging 2019-12-19 18:25:22 +00:00
Asim Aslam
95ae2688a2 add formatters 2019-12-19 12:29:03 +00:00
Asim Aslam
2bcfb85613 Add log Format option 2019-12-19 12:20:33 +00:00
Asim Aslam
d52a111735 add requests/errors to stats 2019-12-18 18:36:42 +00:00
Asim Aslam
d4bec24eb7 Add os log buffer 2019-12-18 17:06:29 +00:00
Asim Aslam
2338e7c9d2 Cleanup go mod 2019-12-18 16:12:25 +00:00
Asim Aslam
f0e841595c move to structured logging 2019-12-18 16:02:11 +00:00
Asim Aslam
a82af19d43 strip newline 2019-12-18 15:19:20 +00:00
Asim Aslam
5d7254e79a fix the os logger 2019-12-18 15:06:25 +00:00
Asim Aslam
7c21a1b92a go fmt 2019-12-18 15:06:02 +00:00
Asim Aslam
587f64a87a Merge pull request #1051 from micro/event
publisher => event
2019-12-18 15:04:38 +00:00
Asim Aslam
cb9c4c3aef publisher => event 2019-12-17 23:05:46 +00:00
Asim Aslam
dda96cb87e Merge pull request #976 from micro/auth
First interface for auth
2019-12-17 21:38:11 +00:00
Asim Aslam
ebae497a72 use service rather than resource 2019-12-17 21:37:20 +00:00
Asim Aslam
515014fbeb update with resource 2019-12-17 21:27:05 +00:00
Asim Aslam
e9efcbe8dc strip logger 2019-12-17 18:34:21 +00:00
Asim Aslam
5a52593e66 go fmt 2019-12-17 18:24:00 +00:00
Asim Aslam
c61e12d5ee add event proto for runtiem 2019-12-17 18:17:32 +00:00
Asim Aslam
c2d59c1f4d Move logger 2019-12-17 18:16:45 +00:00
Jake Sanders
812fe9e640 Merge pull request #1049 from micro/kubernetes-logging
Kubernetes logging
2019-12-17 17:44:24 +00:00
Jake Sanders
f95bccce84 Use UTC in tests 2019-12-17 17:36:01 +00:00
Jake Sanders
81e7edd666 Adhere to new interfaces 2019-12-17 17:24:01 +00:00
Asim Aslam
46fd205eda rename files 2019-12-17 17:08:38 +00:00
Jake Sanders
c2b307e5bb Merge branch master of https://github.com/micro/go-micro into kubernetes-logging 2019-12-17 17:08:31 +00:00
Jake Sanders
b7ac62f7d2 Merge branch 'master' of https://github.com/micro/go-micro into kubernetes-logging 2019-12-17 17:06:07 +00:00
Asim Aslam
50d5c6402b Merge pull request #1048 from micro/logging
Move stream to interface
2019-12-17 17:05:13 +00:00
Asim Aslam
d2a3fd0b04 Move stream to interface 2019-12-17 16:56:55 +00:00
Jake Sanders
51f4bc6d56 Add logs to Interface 2019-12-17 16:30:09 +00:00
Jake Sanders
c3607c23e7 Fix after merge 2019-12-17 16:27:17 +00:00
Jake Sanders
34b1c403bb Merge branch 'master' of https://github.com/micro/go-micro into kubernetes-logging 2019-12-17 16:13:36 +00:00
Asim Aslam
91e057440d Merge pull request #1047 from micro/decruft-logger
Decruft logger
2019-12-17 16:13:20 +00:00
Jake Sanders
53ca742c66 Update the util/kubernetes client to retrieve logs 2019-12-17 16:09:51 +00:00
Asim Aslam
b35dfb1086 fix further breaks 2019-12-17 15:56:49 +00:00
Asim Aslam
d502e2f58a fix breaks 2019-12-17 15:46:09 +00:00
Asim Aslam
bc30efcf70 Decruft the debug logger interface 2019-12-17 15:38:03 +00:00
Jake Sanders
0415ead504 First commit for Kubernetes logger 2019-12-17 12:11:26 +00:00
Jake Sanders
e95f44d3f8 Move runtime/kubernetes/client to util/kubernetes/client 2019-12-17 11:32:38 +00:00
Asim Aslam
0489ae91e9 Merge pull request #1021 from unistack-org/registry_check
add RegisterCheck web server option for internal health checks
2019-12-17 08:49:00 +00:00
Asim Aslam
4e02f444fd Merge pull request #1024 from unistack-org/server
add server Context option to pass own context
2019-12-17 08:48:39 +00:00
Asim Aslam
6027a81f06 Update router comments 2019-12-17 08:28:45 +00:00
Asim Aslam
01f0e70213 add some commented out stuff 2019-12-16 17:37:11 +00:00
Asim Aslam
cb15fadcee go fmt 2019-12-16 17:36:47 +00:00
Asim Aslam
1c8d15fe4b Merge pull request #1046 from micro/storefix
Fix cockroachdb store implementation
2019-12-16 17:24:53 +00:00
Jake Sanders
55f5937c8b Remove debug 2019-12-16 17:16:10 +00:00
Jake Sanders
56619f2745 Fix cockroachdb store implemetation 2019-12-16 17:11:13 +00:00
Asim Aslam
0b59e2ce3d Merge pull request #1028 from Astone-Chou/fix
named return value for error defer modify.
2019-12-16 15:39:58 +00:00
Asim Aslam
1ea6390eae Add proxy string method 2019-12-16 15:18:20 +00:00
Asim Aslam
303adca500 rename postgres to cockroach 2019-12-16 15:09:59 +00:00
Asim Aslam
03700ae6c0 Replace proxy options 2019-12-16 14:55:47 +00:00
Asim Aslam
a1ddfa827e Merge pull request #1045 from micro/store-options
change store options
2019-12-16 14:46:15 +00:00
Asim Aslam
59751c02e6 change store options 2019-12-16 14:38:51 +00:00
Jake Sanders
e8e112144f Create database should take the name of the database 2019-12-16 14:15:30 +00:00
Asim Aslam
59246e0412 Merge pull request #1044 from micro/store-namespace
change use of store namespace/prefix in sql store
2019-12-16 12:20:57 +00:00
Asim Aslam
0131e9468f change use of store namespace/prefix in sql store 2019-12-16 12:13:18 +00:00
Asim Aslam
d5951f1d7c Merge pull request #1042 from ZGeomantic/feat-client-mock
support ctx as input params, error as output for MockClient.Call
2019-12-15 15:12:17 +00:00
Asim Aslam
f33b562c16 Merge pull request #1043 from jamsonzan/branch0
comment
2019-12-15 10:50:52 +00:00
jamsonzan
572fe58314 comment 2019-12-15 15:05:19 +08:00
gemantic
5602b93d7a support ctx as input params, error as output for MockClient.Call 2019-12-14 10:36:12 +08:00
Asim Aslam
64e438a8d4 Merge pull request #1038 from micro/tun
Next level tunnel optimisation
2019-12-13 15:34:03 +00:00
Asim Aslam
b0b6b8fce2 final updates 2019-12-13 15:27:47 +00:00
Asim Aslam
417a05db60 Merge pull request #1039 from xpunch/etcdLogConfig
Etcd log config
2019-12-13 09:23:54 +00:00
johnson
11e42aac69 etcd can set log config
default log level is info, which will log o log of unused logs
2019-12-13 11:22:05 +08:00
potato
885ba8f905 Merge pull request #6 from micro/master
Pull latest go-micro
2019-12-13 11:10:29 +08:00
Asim Aslam
caa74d1b5f fix build 2019-12-12 23:29:44 +00:00
Asim Aslam
f6b4a9da1c strip some code 2019-12-12 23:20:31 +00:00
Asim Aslam
74c5102e41 strip a couple things 2019-12-12 21:49:39 +00:00
Asim Aslam
7bd50cd251 fix more broken cruft 2019-12-12 17:10:32 +00:00
Asim Aslam
df728aaddd remove go routines from tunnel, fire network messages in go routines 2019-12-12 13:34:08 +00:00
Asim Aslam
ae934c19f1 fix tunnel test 2019-12-12 13:04:34 +00:00
Asim Aslam
e260cc4a24 save cruft 2019-12-12 12:27:46 +00:00
Asim Aslam
631faff7b8 Merge pull request #1035 from alrs/fix-grpc-test-goroutines
Fix service/grpc Test Goroutines
2019-12-11 16:39:22 +00:00
Lars Lehtonen
fd531349d7 service/grpc: t.Fatal out of TestGRPCTLSService() goroutine 2019-12-11 08:29:23 -08:00
Lars Lehtonen
27bab29e3c service/grpc: t.Fatal out of TestGRPCService() goroutine 2019-12-11 08:29:14 -08:00
Asim Aslam
27af221fd2 batch metric updates 2019-12-11 15:23:08 +00:00
Asim Aslam
6e28e7a86f Save current state of the world 2019-12-11 14:37:03 +00:00
Asim Aslam
ff69d46c98 strip some cruft from config/cmd 2019-12-10 18:12:29 +00:00
Asim Aslam
e966944ae5 sort resolved node list in network by lowest priority 2019-12-10 17:57:04 +00:00
Asim Aslam
8da77a3ddc use fixed port names for runtime k8s 2019-12-10 14:05:05 +00:00
Asim Aslam
8289dbabc4 Merge pull request #1034 from micro/strip-handlers
Strip handlers
2019-12-10 11:54:06 +00:00
Asim Aslam
d50f30d743 strip handlers 2019-12-10 11:46:13 +00:00
Asim Aslam
f8533551a4 move debug to trace for network peer refresh 2019-12-10 09:09:24 +00:00
Asim Aslam
7e46ff5d92 strip some more logging down 2019-12-10 09:08:03 +00:00
Asim Aslam
6b1eef5354 Merge branch 'master' of ssh://github.com/micro/go-micro 2019-12-09 22:56:33 +00:00
Asim Aslam
b29da80539 Move a few things around 2019-12-09 22:56:26 +00:00
Asim Aslam
a725ab2c94 Merge pull request #1032 from jankremlacek/patch-1
nlopes/slack dep update to fix broken unmarshal
2019-12-09 21:17:34 +00:00
Jan Kremlacek
1582aa1572 proper go.mod, go.sum 2019-12-09 22:08:57 +01:00
Jan Kremlacek
5352d53346 nlopes/slack dep update to fix broken unmarshal
About a month ago Slack introduced the updated structure of RTM messages which resulted in an inability to unmarshal received msg (original issue: https://github.com/nlopes/slack/issues/630). It's not an issue of micro itself, but of the github.com/nlopes/slack lib. The fix was already merged into master (https://github.com/nlopes/slack/pull/618), but the lib has not been released in any new version.

Thus so I propose to update directly to the commit:

go get github.com/nlopes/slack@d06c2a2b3249b44a9c5dee8485f5a87497beb9ea

The MicroBot does now work now with any Slack client newer than around a month old.
2019-12-09 21:52:28 +01:00
Asim Aslam
7d884eff9d Merge pull request #1031 from alrs/fix-web-test-goroutines
web: fix test goroutines
2019-12-09 18:03:07 +00:00
Lars Lehtonen
c9af88184b web: fix test goroutine in TestService() 2019-12-09 09:44:14 -08:00
Lars Lehtonen
f25ad35f0a web: fix test goroutine in TestTLS() 2019-12-09 09:28:42 -08:00
Asim Aslam
55ab44c8be Merge branch 'master' of ssh://github.com/micro/go-micro 2019-12-09 09:32:33 +00:00
Asim Aslam
59c1680594 Move Debug to Trace in router 2019-12-09 09:32:17 +00:00
Asim Aslam
b804303aa0 Merge pull request #1029 from Astone-Chou/lint_fix_fix
fix tiny error in linting fixes
2019-12-09 07:47:46 +00:00
Astone
55a15ecf12 fix tiny error in linting fixes 2019-12-09 11:18:45 +08:00
Astone
caa1bcf9fe named return value for error defer modify. 2019-12-09 11:08:21 +08:00
Asim Aslam
e2b2a30668 add net/http/pprof profiler 2019-12-08 20:31:16 +00:00
Asim Aslam
a9be1288d2 Merge pull request #1026 from micro/tun
Network & Tunnel refactor
2019-12-08 16:01:46 +00:00
Asim Aslam
679214e598 just return filtered routes 2019-12-08 15:39:45 +00:00
Asim Aslam
6064e1426c fix some potential go routine leaks 2019-12-08 15:02:54 +00:00
Asim Aslam
d28a868e46 Fix network startup connect 2019-12-08 14:37:17 +00:00
Asim Aslam
398acc67ca fix broken test 2019-12-08 13:45:24 +00:00
Asim Aslam
ce578800d0 n.initNodes 2019-12-08 12:17:31 +00:00
Asim Aslam
6307d6ba51 further cleanup of tunnel/network 2019-12-08 12:12:20 +00:00
Asim Aslam
283c85d256 done 2019-12-08 00:53:55 +00:00
Asim Aslam
9bd0fb9125 save changes 2019-12-07 23:28:39 +00:00
Asim Aslam
c445aed6b1 Cleanup and speedup network convergence along with direct messaging for connect and solicit 2019-12-07 19:54:29 +00:00
Asim Aslam
1d8c66780e save working solution 2019-12-06 00:18:40 +00:00
Asim Aslam
219efd27e9 Optimise the multicast to use one session in the tunnel 2019-12-05 23:11:42 +00:00
Asim Aslam
ac9001ac74 advert ttl inline with router table tick 2019-12-05 17:50:32 +00:00
Asim Aslam
2896614595 Merge pull request #1025 from milosgajdos83/router-knobs
Changed a few router knobs to avoid storms ⛈
2019-12-05 17:50:02 +00:00
Milos Gajdos
bca12a7003 Changed a few router knobs to avoid storms ⛈ 2019-12-05 17:11:17 +00:00
1c5a4c470f add server Context option to pass own context
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-12-05 19:37:03 +03:00
Asim Aslam
744b19d625 Merge pull request #1023 from milosgajdos83/dead-code
Fixing dead code and go vet moaning
2019-12-05 16:18:13 +00:00
Milos Gajdos
5865e89bed Fixing dead code and go vet moaning 2019-12-05 16:10:49 +00:00
Asim Aslam
3a10b1cdde Merge pull request #1022 from milosgajdos83/tunnel-races
This PR fixes various tunnel race conditions
2019-12-05 15:59:29 +00:00
Milos Gajdos
5db7514a91 This PR fixes various tunnel race conditions 2019-12-05 15:50:32 +00:00
a957e90ca8 add RegisterCheck web server option for internal health checks
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-12-05 17:28:11 +03:00
Asim Aslam
18cf025056 Merge pull request #1020 from Allenxuxu/master
Avoid excessive memory usage
2019-12-05 11:56:44 +00:00
Allenxuxu
b55b7d6b20 replace map with list 2019-12-05 19:29:48 +08:00
Asim Aslam
26b5d1994a Merge pull request #1019 from tboerger/no-newlin
No newlines at end of log messages
2019-12-05 10:08:16 +00:00
Thomas Boerger
30aec5b872 No newlines at end of log messages
Log messages should not end with a new line, this should be entirely
handled by the underlying log library.

Signed-off-by: Thomas Boerger <thomas@webhippie.de>
2019-12-05 10:56:45 +01:00
Asim Aslam
b0626089f3 Merge pull request #1016 from unistack-org/lint
lint fixes mostly for prealloc also remove deadcode from grpc client
2019-12-05 08:33:52 +00:00
Asim Aslam
af3d4e595f in memory stats buffer 2019-12-05 00:08:46 +00:00
Asim Aslam
40c09eed1c Logs to Log 2019-12-05 00:01:17 +00:00
Asim Aslam
fe46e7a9e9 Logs to Log 2019-12-04 23:58:29 +00:00
Asim Aslam
78647c7027 add timestamp to stats 2019-12-04 23:51:07 +00:00
Asim Aslam
26755f86b1 Merge pull request #1018 from micro/debug-service
Debug service
2019-12-04 14:40:58 +00:00
Asim Aslam
898848795b tab indent 2019-12-04 12:28:16 +00:00
Asim Aslam
24efbe6a41 Move debug handler to service dir 2019-12-04 12:27:30 +00:00
Asim Aslam
97433f716f add service name to debug proto 2019-12-04 12:02:44 +00:00
Asim Aslam
5200febaea add stats debug interface 2019-12-04 11:53:20 +00:00
a1eaf9cc20 linting fixes
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-12-04 00:22:02 +03:00
Asim Aslam
3f8af8c1e0 Merge branch 'master' of ssh://github.com/micro/go-micro 2019-12-03 20:32:10 +00:00
Asim Aslam
becaeefcba Revert. DO NOT peer solicit until we know better 2019-12-03 20:32:02 +00:00
7d5bdcf993 fix pointer dereference in memory registry
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-12-03 23:05:03 +03:00
Asim Aslam
81a7cf458c Merge pull request #1013 from unistack-org/linting
add golanglint-ci
2019-12-03 16:57:00 +00:00
Asim Aslam
a4ea61334b Merge pull request #1015 from milosgajdos83/router-race
Fix router race condition
2019-12-03 16:55:56 +00:00
Asim Aslam
3fbba9f83d Merge pull request #1014 from milosgajdos83/memreg-race
Fix memory registry race
2019-12-03 16:51:36 +00:00
Milos Gajdos
4a11a4c546 Fix router race condition 2019-12-03 15:22:54 +00:00
Milos Gajdos
265233517e Fix memory registry race 2019-12-03 14:53:07 +00:00
c581ceb1dc add golanglint-ci
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-12-03 16:31:43 +03:00
Asim Aslam
bb1a1358b7 Merge pull request #1012 from Astone-Chou/lint
improve code quality
2019-12-03 13:10:04 +00:00
Astone
29fb58db39 improve code quality 2019-12-03 20:59:02 +08:00
Asim Aslam
b6f0164501 Merge branch 'master' of ssh://github.com/micro/go-micro 2019-12-03 08:11:46 +00:00
Asim Aslam
2c0801fc1c couple bug fixes in tunnel 2019-12-03 08:11:36 +00:00
Asim Aslam
34c92f4964 Merge pull request #1011 from Astone-Chou/master
optimize: a better way for return error
2019-12-03 07:48:21 +00:00
Astone
f9b900b2ca optimize: a better way for return error 2019-12-03 12:47:29 +08:00
Asim Aslam
b5d65305db Merge pull request #1009 from unistack-org/panics
recover panics
2019-12-02 23:30:17 +00:00
b8e96f45d4 add recovery in case of panics
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-12-03 02:25:40 +03:00
90f9b0d0c9 initialize client options context if not provided
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-12-03 01:35:59 +03:00
Asim Aslam
972c0989af Merge pull request #1008 from micro/connect-fast
Optimizations to connect fast
2019-12-02 19:09:56 +00:00
Asim Aslam
5f04fd58ab optimizations to connect fast 2019-12-02 18:48:19 +00:00
Asim Aslam
da04aa8ae8 Switch to AdvertiseLocal by default 2019-12-02 17:36:20 +00:00
Asim Aslam
62bf0df864 Merge pull request #1007 from micro/ultra-hacks
ultra hacks to make debug handler work in proxy
2019-12-02 15:11:56 +00:00
Asim Aslam
91e9c0cb62 ultra hacks to make debug handler work in proxy 2019-12-02 14:55:35 +00:00
Asim Aslam
3356b83f24 register debug handler 2019-12-01 21:04:09 +00:00
Asim Aslam
795ec509fd Merge branch 'master' of ssh://github.com/micro/go-micro 2019-12-01 19:43:45 +00:00
Asim Aslam
93d66afe8c fix that broken logic 2019-12-01 19:43:36 +00:00
Asim Aslam
c840cee404 A variety of fixes to try combat the multicast issue 2019-12-01 19:36:16 +00:00
Milos Gajdos
e48cce6485 Merge pull request #1005 from milosgajdos83/nano-seconds
Time resolution change to be in line with debug/handler.Handler
2019-12-01 18:39:59 +00:00
Milos Gajdos
b2ecd93404 Time resolution change to be in line with debug/handler.Handler 2019-12-01 18:33:08 +00:00
Asim Aslam
2928c66624 Merge pull request #1004 from milosgajdos83/debug-logs
[WIP] Debug logs
2019-12-01 17:40:40 +00:00
Milos Gajdos
4613a820ca Small refactoring og logs
* log.Write now accepts log.Record
* we stream last 10 records first
* regenerate proto because of the above
2019-12-01 13:16:44 +00:00
Milos Gajdos
ecdadef633 Added hack support for logs streaming cruft 2019-12-01 13:16:44 +00:00
Milos Gajdos
7f1dea72f2 Simplified Logs RPC. Cleaned up code. Added comments. 2019-12-01 13:16:44 +00:00
Milos Gajdos
612f872f76 Server should not close the stream when done 2019-12-01 13:16:44 +00:00
Milos Gajdos
13d2a9ec7a Register proto handler properly 2019-12-01 13:16:44 +00:00
Milos Gajdos
9fab47ecdb Added DefaultLog variables 2019-12-01 13:16:44 +00:00
Milos Gajdos
265e8ade05 Embed DebugHandler proto 2019-12-01 13:16:44 +00:00
Milos Gajdos
60e0e81523 Added debug/service to grab the logs from a service 2019-12-01 13:16:43 +00:00
Milos Gajdos
b01357058a Regenerate proto cruft 2019-12-01 13:16:43 +00:00
Milos Gajdos
7deafbc5ce Added ReadOptions; Changed proto; Reimplemented Log(er) 2019-12-01 13:16:43 +00:00
Milos Gajdos
9e177be560 Embed logger into debug.Handler 2019-12-01 13:16:43 +00:00
Milos Gajdos
ee9776e7b2 Added debug.Logger interface 2019-12-01 13:16:43 +00:00
Milos Gajdos
3f7f2afc7b Dont be stupid -- stream does not require pointer. 2019-12-01 13:16:43 +00:00
Milos Gajdos
4e965e4ce5 First commit. Modified proto. Added empty handler method. 2019-12-01 13:16:43 +00:00
Asim Aslam
6f1c30aef5 remove unused value in router 2019-11-30 21:39:03 +00:00
Asim Aslam
00bbb3ac61 revert some protocol changes for now 2019-11-30 21:20:33 +00:00
Asim Aslam
ce1942c578 why didn't we think of this before...single service name for http broker 2019-11-30 21:00:36 +00:00
Asim Aslam
df7169c9f2 Merge branch 'master' of ssh://github.com/micro/go-micro 2019-11-30 01:16:53 +00:00
Asim Aslam
5e59db4c6d revert mdns timeout 2019-11-30 01:16:32 +00:00
Asim Aslam
25b3fda25b Merge pull request #1002 from micro/tun-fix
fix bug in the tunnel which causes multicast connections to be closed
2019-11-30 01:16:12 +00:00
Asim Aslam
9678daeafa fix bug in the tunnel which causes multicast connections to be closed 2019-11-30 01:14:40 +00:00
Asim Aslam
9ed257f151 Merge pull request #1001 from micro/storm
Changes for the storm
2019-11-29 17:33:23 +00:00
Asim Aslam
107124e5dc Changes for the storm 2019-11-29 17:27:29 +00:00
Asim Aslam
ce4acfa892 fix type filtering for k8s runtime 2019-11-29 13:05:18 +00:00
Asim Aslam
6bf4828296 triple the mdns timeout 2019-11-29 13:05:07 +00:00
Asim Aslam
76b4e78a6a fix command to accept variadic args 2019-11-29 11:55:25 +00:00
Asim Aslam
8b6475b8d4 Merge pull request #1000 from micro/runtime-type
Support service types in runtime
2019-11-29 11:46:21 +00:00
Asim Aslam
c3ed83dfba Support service types in runtime 2019-11-29 11:35:00 +00:00
Asim Aslam
114bc1e18b Merge pull request #995 from micro/rpc-leak
Fix rpc go routine leak
2019-11-27 17:24:19 +00:00
Asim Aslam
af94899b54 Fix rpc go routine leak 2019-11-27 17:12:07 +00:00
Asim Aslam
266b6dbc64 add debug buffer time based access 2019-11-27 13:57:19 +00:00
Asim Aslam
5932dd753c Merge pull request #981 from unistack-org/subscriber
subscriber recovery
2019-11-27 10:28:51 +00:00
86a6328254 subscriber recovery
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-11-27 13:21:20 +03:00
Asim Aslam
0d33c029a9 Merge pull request #994 from milosgajdos83/validator-regexp
Remove validator regexp as its no longer needed.
2019-11-27 08:10:00 +00:00
Milos Gajdos
8ecd2381a4 Remove validator regexp as its no longer needed. 2019-11-26 23:10:45 +00:00
Asim Aslam
7318807dce Merge pull request #993 from micro/k8s-fixes
Add fixes for label selector and skipping things that don't match
2019-11-26 22:32:58 +00:00
Asim Aslam
811275be26 Add fixes for label selector and skipping things that don't match 2019-11-26 22:28:08 +00:00
Asim Aslam
3f3fd38601 Add spec.template.metadata.annotations to the k8s template 2019-11-26 18:14:49 +00:00
Asim Aslam
44dd0b1302 Merge pull request #991 from micro/k8s-update
Patch spec template annotations and use event timestmap
2019-11-26 17:38:56 +00:00
Asim Aslam
6475c1f3ad Patch spec template annotations and use event timestmap 2019-11-26 17:33:41 +00:00
Asim Aslam
deabf0b8c9 fix entry into nil map 2019-11-26 14:56:23 +00:00
Asim Aslam
04ee4b04ad Merge pull request #990 from micro/buffer
Add debug/buffer package as a simple ring buffer
2019-11-26 14:27:39 +00:00
Asim Aslam
2892686c5f Merge pull request #988 from micro/k8s-update
Change the k8s runtime notifier update to get the deployment and upda…
2019-11-26 14:21:42 +00:00
Asim Aslam
8ee31a63f1 Add debug/buffer package as a simple ring buffer 2019-11-26 14:20:45 +00:00
Asim Aslam
4e363da91f Merge pull request #989 from micro/proto
Regenerate the protos
2019-11-26 13:57:49 +00:00
Asim Aslam
8b63df7a98 regenerate the protos 2019-11-26 13:53:33 +00:00
Asim Aslam
b06854b0d5 Change the k8s runtime notifier update to get the deployment and update build 2019-11-26 13:49:52 +00:00
Jake Sanders
39bf71376a Add some more issue templates (#987)
* Add some more issue templates

* Update bug_report.md

* Update bug_report.md
2019-11-26 11:48:14 +00:00
Jake Sanders
12d9c5b187 Merge pull request #986 from micro/bug-report-template
Create Bug Report Issue Template
2019-11-26 11:25:42 +00:00
Jake Sanders
d2eba3f8f9 Create Bug Report Issue Template
To encourage users to provide context with bug reports
2019-11-26 11:17:32 +00:00
Milos Gajdos
19f2f8b161 Merge pull request #982 from xmlking/master
go-micro docker now includes unprivileged user
2019-11-26 10:54:18 +00:00
Sumanth Chinthagunta
d41185eb84 go-micro docker now includes unprivileged user 2019-11-25 18:42:24 -08:00
Asim Aslam
c420fa2dec Merge pull request #979 from milosgajdos83/tunnel-encrypt
[WIP] Tunnel encryption
2019-11-25 19:12:24 +00:00
Asim Aslam
db03a564fb Merge pull request #980 from unistack-org/issue-940
grpc client goroutine leak fix
2019-11-25 19:10:34 +00:00
9763820c75 grpc client goroutine leak fix
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-11-25 22:02:24 +03:00
Milos Gajdos
9095b99f6b Token has been stripped; Headers are encrypted 2019-11-25 18:56:00 +00:00
Asim Aslam
080363e8c4 The mega cruft proxy PR (#974)
* the mega cruft proxy PR

* Rename broker id

* add protocol=grpc

* fix compilation breaks

* Add the tunnel broker to the network

* fix broker id

* continue to be backwards compatible in the protocol
2019-11-25 16:31:43 +00:00
Asim Aslam
252667398e Update the runtime for k8s name formatting and move Get to Read endpoint (#978)
* Update the runtime for k8s name formatting and move Get to Read endpoint

* strip regex validation
2019-11-25 16:31:14 +00:00
Milos Gajdos
f82c267d81 Encrypt session communication 2019-11-25 15:37:38 +00:00
Milos Gajdos
61fe552ac4 First commit: Outline of tunnel encryption code 2019-11-25 14:58:12 +00:00
Asim Aslam
7013e7467f Undefined time 2019-11-25 09:33:30 +00:00
Asim Aslam
dbc537007d First interface for auth 2019-11-25 09:30:26 +00:00
Asim Aslam
95045be83d Merge branch 'master' of ssh://github.com/micro/go-micro 2019-11-23 22:50:45 +00:00
Asim Aslam
52ccd900c7 reorder service struct fields 2019-11-23 22:50:13 +00:00
罗泽轩
64a251d69a improve the syncMap.Iterate test to make it 100% reproducible (#970)
* improve the syncMap.Iterate test to make it 100% reproducible

* rename store/mocks/Store.go

* rename mocks/store to mock/store
2019-11-23 14:13:17 +00:00
Asim Aslam
cae4148594 Fix platform specific os/process build 2019-11-23 08:25:56 +00:00
Milos Gajdos
38e29c5101 Svc metadata (#972)
* Added service metadata

* Added metadata to runtime service

* Add Annotations metadata to service metadata

* Add micro/micro as default service owners

* Update runtime/kubernetes/client/kubernetes.go

Change comment

Co-Authored-By: Jake Sanders <i@am.so-aweso.me>
2019-11-22 17:10:00 +00:00
Milos Gajdos
8dc3fb964e Pass source of service to Deployment API; render templates properly (#969)
* Pass source of service to Deployment API; render templates properly

* Enable Go modules by default. Honor runtime.Service.Exec

* Make sure you remove go.mod and go.sum
2019-11-21 17:31:13 +00:00
Asim Aslam
212144d658 fix windows compilation error 2019-11-21 11:19:52 +00:00
Milos Gajdos
11d81221cc Runtime service implementation (#965) 2019-11-20 14:54:42 +00:00
Milos Gajdos
55252cbc32 Fix the router test; get rid of time dependency (#964) 2019-11-20 14:53:12 +00:00
Asim Aslam
c87a58db0a add ability to set web icon 2019-11-20 12:43:43 +00:00
49d73faa5f return error to caller on grpc server request processing (#962)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-11-20 10:28:30 +00:00
da6c1be607 dont panic on missing headers in broker event (#963)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-11-20 07:55:47 +00:00
Milos Gajdos
94d409b180 Change DefaultImage to micro/go-micro 2019-11-19 20:49:01 +00:00
Milos Gajdos
d6e97c5970 Service.Exec is a slice of strings (#960) 2019-11-19 19:36:29 +00:00
Asim Aslam
64d5a528ca fix broken build 2019-11-19 16:55:33 +00:00
Milos Gajdos
538d3752f9 Added Dockerfile for go-micro (#959) 2019-11-19 16:50:31 +00:00
Asim Aslam
fb5b358ae2 fix mdns test 2019-11-19 16:50:16 +00:00
Milos Gajdos
6a0082741c Packager is now builder (#958) 2019-11-19 16:09:43 +00:00
Shu xian
5744050943 api event supports for GET url params (#956) 2019-11-18 16:37:45 +00:00
Asim Aslam
168cc06827 increase timeout on travis 2019-11-18 12:58:06 +00:00
Asim Aslam
fa01cadc35 lower the mdns timeout to 10ms (#955) 2019-11-18 12:50:51 +00:00
Asim Aslam
342c29de7d fix TestMemoryRegistryTTLConcurrent test 2019-11-16 21:13:06 +00:00
Asim Aslam
eeed493766 move test data 2019-11-16 18:52:27 +00:00
Asim Aslam
90d7a87914 Move wrapper internally since its not top level relevant 2019-11-16 18:48:24 +00:00
Erik Hollensbe
a1c6cdf193 Now specify HandleSignal as an option to toggle signal handling. (#948)
Signed-off-by: Erik Hollensbe <github@hollensbe.org>
2019-11-16 11:13:34 +00:00
Erik Hollensbe
bec13a45cd Attempt to fix the timing error in the memory concurrency test (#952)
Only shows in travis

Signed-off-by: Erik Hollensbe <github@hollensbe.org>
2019-11-16 11:11:13 +00:00
Erik Hollensbe
4107733453 Memory registry from #801 with additional tweaks (#951)
* PoC: memory registry using maps instead of slice madness

* Updated proto and handlers. Fixed tests across codebase.

* Implemented ttl pruning for memory registry

* Added extensive memory registry tests

* Squased a bunch of bugs

* Proto indent; memory.Registry.String() returns "memory"

* Write a test to prove memory registry TTLs are busted

Signed-off-by: Erik Hollensbe <github@hollensbe.org>

* Additional memory testing and fixups:

* DefaultTTL removed
* When TTL == 0, it is automatically removed from expiry conditions
* Additional improvements to new tests

Signed-off-by: Erik Hollensbe <github@hollensbe.org>
2019-11-16 10:55:11 +00:00
Milos Gajdos
97c1300f53 [WIP] Micro Runtime (#947)
* Add Get() and GetOptions.

* Removed watcher. Outline of client. YAML templates

* Added default service and deployment templates and types

* Added API tests and cleaned up errors.

* Small refactoring. Template package is no more.

* Ripped out existing code in preparation to small rework

* Reshuffled the source code to make it organized better

* Create service and deployment in kubernetes runtime

* Major cleanup and refactoring of Kubernetes runtime

* Service now handles low level K8s API calls across both K8s deployment
an service API objects
* Runtime has a task queue that serves for queueing runtime action
requests
* General refactoring

* No need for Lock in k8s service

* Added kubernetes runtime env var to default deployment

* Enable running different versions of the same service

* Can't delete services through labels

* Proto cruft. Added runtime.CreateOptions implementation in proto

* Removed proxy service from default env variables

* Make service name mandatory param to Get method

* Get Delete changes from https://github.com/micro/go-micro/pull/945

* Replaced template files with global variables

* Validate service names before sending K8s API request

* Refactored Kubernetes API client. Fixed typos.

* Added client.Resource to make API resources more explicit in code
2019-11-15 13:41:40 +00:00
mirwaisx
0af8be35bb -bugfix #889 set body corretly in case of missing content-type (#950) 2019-11-15 13:03:45 +00:00
Asim Aslam
a91b3f3e8b windows specific os tag 2019-11-15 08:20:05 +00:00
Asim Aslam
383658edf2 Fix a runtime deadlock as well as fixing some graceful exiting issues (#945) 2019-11-14 14:26:21 +00:00
Asim Aslam
16754a7477 Set theme jekyll-theme-architect 2019-11-14 11:55:07 +00:00
Asim Aslam
58b25d7241 Update CNAME 2019-11-14 11:54:16 +00:00
Asim Aslam
1c7d44282e Set theme jekyll-theme-minimal 2019-11-14 11:17:02 +00:00
Asim Aslam
8e9eef794f Set theme jekyll-theme-minimal 2019-11-14 11:15:50 +00:00
Asim Aslam
920c026f14 Create CNAME 2019-11-14 11:01:36 +00:00
Asim Aslam
946c76cb03 Delete CNAME 2019-11-14 11:01:27 +00:00
Asim Aslam
43d11a9b8d Create CNAME 2019-11-14 10:50:51 +00:00
Asim Aslam
9f481542f3 Fix a codec race by locking the buffers. Include a buffer pool for perf. (#941)
* Fix a codec race by locking the buffers. Include a buffer pool for perf.

* Read Lock on buffer Read
2019-11-13 11:05:53 +00:00
Asim Aslam
cffa5b6b50 Make use of cloudflare 1.0.0.1 by default to resolve addresses 2019-11-12 15:46:30 +00:00
Asim Aslam
8867539d78 Update FUNDING.yml 2019-11-12 12:35:09 +00:00
Asim Aslam
671408b3a5 Create FUNDING.yml 2019-11-12 12:27:51 +00:00
Lars Lehtonen
bdb62e8ed1 store/postgresql: fix dropped error (#938) 2019-11-12 07:54:33 +00:00
Asim Aslam
72522a869a fix endpoint extractor panic 2019-11-11 17:37:48 +00:00
Asim Aslam
fd5c29addc Add the ability to only advertise local routes or don't advertise at all (#932)
* Add the ability to only advertise local routes or don't advertise at all

* Reorder processing to shortcircuit no advertising
2019-11-11 15:28:37 +00:00
Asim Aslam
65b1283459 add metadata.Get(context, key) as short hand 2019-11-11 09:13:02 +00:00
Huang.X
5ffe367cae fix# Change the Log level and add WarnLevel (#935)
* fix# Change the Log level and add WarnLevel

* fix# Change the Log level and add WarnLevel
2019-11-11 07:57:13 +00:00
Till Knuesting
5ae3e179b9 preallocated slices (#934) 2019-11-11 00:03:51 +00:00
c696a859be fix data race for server Wait option (#931)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-11-09 21:52:41 +00:00
Asim Aslam
174b01ca29 update link in readme 2019-11-09 16:20:54 +00:00
Asim Aslam
c433de80cd Update go mod 2019-11-09 15:44:52 +00:00
Asim Aslam
f2b4c07a00 Merge branch 'master' of ssh://github.com/micro/go-micro 2019-11-09 15:37:54 +00:00
Asim Aslam
929ffdcc42 Update readme 2019-11-09 15:37:30 +00:00
Lars Lehtonen
5aa28dfb0d store/cloudflare: fix dropped error (#930) 2019-11-09 15:18:51 +00:00
Asim Aslam
a9e8fc6039 Don't set stream unless its true 2019-11-09 10:32:52 +00:00
Milos Gajdos
0b1e6d7eaf Simplified k8s API Body watcher code and test. (#923) 2019-11-08 15:57:32 +00:00
Milos Gajdos
1ffa289d39 Make build timestamp parsing errors clearer (#929) 2019-11-08 15:57:07 +00:00
Milos Gajdos
68419cc024 Patch deployment spec metadata (#928) 2019-11-08 14:12:03 +00:00
8227206208 use service id in profile file name (#925)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-11-08 09:11:55 +00:00
Milos Gajdos
6f28852e1b K8s list deployments (#921)
* Outline of ListDeployments method

* Added implementation of DeploymentList
2019-11-07 07:44:57 +00:00
Asim Aslam
0e3550229b update readme 2019-11-06 22:04:02 +00:00
Asim Aslam
f9400ba713 update readme 2019-11-06 22:03:35 +00:00
Asim Aslam
ce080d76c6 add debug/profile package (#920)
* add debug/profile package

* set service+version for profile
2019-11-06 19:36:04 +00:00
Asim Aslam
254045e9f3 Remove go routines for mdns watcher and cache registry (#919) 2019-11-06 15:49:40 +00:00
Milos Gajdos
b84134581c Flap detection vol2 (#915)
* We now purge flapping routes before regular tick processes them

* Updated comments

* Record the timestamp as soon as you receive the event

* Set route Address to routing table test

* Fixed a bunch of deadlocks. Added basic Router tests.
2019-11-05 17:44:24 +00:00
Till Knuesting
f67c5e779f preallocated slices (#917) 2019-11-05 17:43:12 +00:00
Milos Gajdos
4a694c9d02 Change flap detection configuration (#914)
* Change flap detection configuration

* Make PenaltyHalfLife a float, not int 🤦‍♂️

* Lower event suppression to 200
2019-11-04 19:01:52 +00:00
Till Knuesting
24b8d2a315 preallocating slices (#904)
* preallocated some slices when size is known

* gofmt

* gofmt
2019-11-04 10:33:53 +00:00
Asim Aslam
2f3c251b00 Recovery should be < 500 2019-11-03 17:10:00 +00:00
Asim Aslam
c1b0a968ae Augment the router penalty and decay as a hack fix (#912)
* Augment the router penalty and decay as a hack fix

* increase recovery cost
2019-11-03 16:29:10 +00:00
Asim Aslam
81e9298be6 Merge branch 'master' of ssh://github.com/micro/go-micro 2019-11-03 16:12:24 +00:00
Asim Aslam
45cd14c4b7 Suppress log messages 2019-11-03 16:12:17 +00:00
罗泽轩
8579c8b321 avoid deadlock in syncMap.Iterate (#909)
Previously, when syncMap iterates a list of records which have the same
content in different order, a deadlock might happen. By enforcing a certain
order, the deadlock can be avoided.
2019-11-03 08:18:48 +00:00
罗泽轩
bd37e67839 fix a typo in sync/lock/memory package (#910) 2019-11-03 08:17:01 +00:00
Asim Aslam
d3151f1f0f Merge branch 'master' of ssh://github.com/micro/go-micro 2019-11-02 23:13:10 +00:00
Asim Aslam
c45ea62ea8 Do not deregister services in the monitor unless Reap is called 2019-11-02 23:13:01 +00:00
Yang Shi
c14bf5dc4e improve the log of panic recovering (#906) 2019-11-02 23:08:54 +00:00
Asim Aslam
292da40886 runtime handler/proto placeholder 2019-11-02 22:54:35 +00:00
Milos Gajdos
6f7702a093 [WIP] K8s update and runtime package changes (#895)
* First commit: outline of K8s runtime package

* Added poller. Added auto-updater into default runtime

* Added build and updated Poller interface

* Added comments and NewRuntime that accepts Options

* DefaultPoller; Runtime options

* First commit to add Kubernetes cruft

* Add comments

* Add micro- prefix to K8s runtime service names

* Get rid of import cycles. Move K8s runtime into main runtime package

* Major refactoring: Poller replaced by Notifier

POller has been replaced by Notifier which returns a channel of events
that can be consumed and acted upon.

* Added runtime configuration options

* K8s runtime is now Kubernetes runtime in dedicated pkg. Naming kung-fu.

* Fix typo in command.

* Fixed typo

* Dont Delete service when runtime stops.

runtime.Stop stops services; no need to double-stop

* Track runtime services

* Parse Unix timestamps properly

* Added deployments into K8s client. Debug logging
2019-11-02 13:25:10 +00:00
Asim Aslam
a94a95ab55 Merge pull request #908 from hb-chen/fix-907
fix-907
2019-11-02 08:59:14 +00:00
Hobo86
e8d2f207d8 fix-907
web service need modify registry service nodes while register interval
2019-11-02 16:39:56 +08:00
Asim Aslam
bd1918900e Merge pull request #901 from micro/sqlstore
Implementation of PostgreSQL for micro store
2019-11-01 15:48:47 +00:00
Asim Aslam
cf3af68e31 Merge pull request #903 from tegk/gofmt
used gofmt with -s flag on whole project
2019-11-01 15:25:53 +00:00
Jake Sanders
15e3b9b4c0 Let people connect with just a hostname 2019-11-01 15:16:05 +00:00
Asim Aslam
107a7ab07f Merge pull request #902 from micro/runtime-panic
Fix panic caused when ctrl+c a non started service
2019-11-01 15:12:33 +00:00
Asim Aslam
e9dfccc616 Fix panic caused when ctrl+c a non started service 2019-11-01 15:08:01 +00:00
tegk
f88518d994 used gofmt with -s flag on whole project 2019-11-01 15:07:53 +00:00
Jake Sanders
ee35fe61af update go.mod for postgres 2019-11-01 14:13:47 +00:00
Jake Sanders
dee63b2b2c Implementation of postgres store 2019-11-01 14:13:21 +00:00
Asim Aslam
0aa01b2ebf Output the build error in plugin 2019-11-01 08:33:14 +00:00
Asim Aslam
f089a89e8a Merge pull request #897 from micro/route-filtering
add ability to filter routes based on headers
2019-11-01 08:15:23 +00:00
Asim Aslam
174fbde049 add ability to filter routes based on headers 2019-10-31 22:34:06 +00:00
Asim Aslam
967d7ecda7 fix runtime panic 2019-10-31 22:30:21 +00:00
Asim Aslam
fb76755684 Merge branch 'master' of ssh://github.com/micro/go-micro 2019-10-31 17:22:45 +00:00
Asim Aslam
cf593e7c50 fix link panic 2019-10-31 17:22:38 +00:00
Asim Aslam
74286c2939 Merge pull request #893 from yandd/master
fix rcache ttl
2019-10-30 21:31:08 +00:00
yandd
f9c639af4e fix rcache ttl 2019-10-30 14:01:51 +08:00
Asim Aslam
dab0f3223f Add Update/List endpoints to runtime 2019-10-29 12:29:21 +00:00
Asim Aslam
d89256d8d5 add network resolver record priority field 2019-10-28 15:31:46 +00:00
Asim Aslam
99b410c81b fix metadata test 2019-10-25 23:28:43 +01:00
Asim Aslam
92b7d2db3b Rename to Merge 2019-10-25 23:27:59 +01:00
Asim Aslam
20c6c36bc4 Merge pull request #883 from xmlking/master
PatchContext method added
2019-10-25 23:23:37 +01:00
Asim Aslam
1f626a55ed Merge pull request #887 from micro/collapse-routes
hash address based on service name + node address
2019-10-25 23:12:56 +01:00
Asim Aslam
b42d242ec1 hash address based on service name + node address 2019-10-25 23:06:49 +01:00
Asim Aslam
51922c1763 Refresh route metrics in the proxy 2019-10-25 22:46:43 +01:00
Sumanth Chinthagunta
1c6b85e05d AppendContext with overwrite flag 2019-10-25 08:27:28 -07:00
Asim Aslam
e85863d6cc Merge pull request #886 from micro/tunnel-error
Don't error where the connection is not unicast
2019-10-25 15:48:09 +01:00
Asim Aslam
5d7bf53f78 don't error where the connection is not unicast 2019-10-25 15:41:37 +01:00
Asim Aslam
44c0f1946d Merge pull request #882 from micro/link-state
A few changes for the network / tunnel link state
2019-10-25 14:28:43 +01:00
Asim Aslam
1c9ada6413 Reorder setChannel method 2019-10-25 14:24:37 +01:00
Asim Aslam
c170189efb We need the message back to set the link 2019-10-25 14:22:38 +01:00
Asim Aslam
3831199600 Use best link in tunnel, loop waiting for announce and accept messages, cleanup some code 2019-10-25 14:16:22 +01:00
Sumanth Chinthagunta
1f658cfbff adding PatchContext - this will create new context with original + patch metadata 2019-10-24 17:51:54 -07:00
Asim Aslam
f26d470db1 A few changes for the network / tunnel link state 2019-10-24 17:51:41 +01:00
Asim Aslam
f5b8a12106 Merge pull request #880 from milosgajdos83/tunnel-sessionlink
Make sure we pick some link when Dialling
2019-10-24 16:14:32 +01:00
Milos Gajdos
494eb13534 Make sure we pick some link when Dialling 2019-10-24 16:07:31 +01:00
Asim Aslam
4db1e09798 change options to be trimmed down 2019-10-23 23:12:45 +01:00
Asim Aslam
232c8ac7a1 More cleanup of store cf 2019-10-23 23:10:44 +01:00
Asim Aslam
68d0efbeaa Move api types in cf store 2019-10-23 22:57:11 +01:00
Asim Aslam
70aaca9876 further cleanup 2019-10-23 22:54:55 +01:00
Asim Aslam
3ce71e12ff Don't recall vals everywhere 2019-10-23 22:51:08 +01:00
Asim Aslam
fb3d729681 sync map uses store list 2019-10-23 22:35:28 +01:00
Asim Aslam
d65658c890 Update options usage in store/api 2019-10-23 22:31:36 +01:00
Asim Aslam
3fc04f4dff fixup some acme related things 2019-10-23 22:15:15 +01:00
Asim Aslam
82f94c7861 Change store.Sync to store.List 2019-10-23 22:05:39 +01:00
Asim Aslam
ecac392dbe unexport api response/message in cloudflare store 2019-10-23 21:54:37 +01:00
Asim Aslam
4e5a568063 races, race conditions everywhere 2019-10-23 21:24:31 +01:00
Asim Aslam
87de2ecaa0 Merge pull request #876 from milosgajdos83/peerlink-route-metric
Peerlink route metric
2019-10-23 20:31:21 +01:00
Milos Gajdos
4f1dd3f965 Fixed a small messup when printing logs 2019-10-23 20:01:45 +01:00
Milos Gajdos
71122836b8 Use event.Route.Link for getting the route metrics 2019-10-23 19:55:01 +01:00
Milos Gajdos
b67be88952 Check for local links and empty gateways 2019-10-23 19:48:26 +01:00
Asim Aslam
83b232ae26 Merge pull request #879 from micro/cloudflareexpiry
Throw away cloudflare-go library and reimplement workers KV
2019-10-23 17:44:13 +01:00
Milos Gajdos
776284b187 Make sure you dont overflow MaxInt64 2019-10-23 17:42:04 +01:00
Jake Sanders
53ee4ee482 goodbye cloudflare-go 2019-10-23 17:33:20 +01:00
Milos Gajdos
35729092e0 Unexport network.Message 2019-10-23 17:32:45 +01:00
Jake Sanders
4f5db08238 Remove cloudflare-go and reimplement workers KV 2019-10-23 17:31:15 +01:00
Milos Gajdos
68789af4ea Prune peerlinks of pruned nodes 2019-10-23 17:29:03 +01:00
Milos Gajdos
b3d4a7f740 If no link found, return max possible value 2019-10-23 16:51:22 +01:00
Milos Gajdos
f4f178c130 Set metric on egress. Increment metric on ingress. 2019-10-23 16:51:22 +01:00
Milos Gajdos
1ff65e140a Change router.Route metric to int64. Set the route metric properly 2019-10-23 16:51:22 +01:00
Milos Gajdos
326156671d Set route metric to link Length 2019-10-23 16:51:22 +01:00
Milos Gajdos
6353b2b894 Keep track of peer links 2019-10-23 16:51:22 +01:00
Asim Aslam
caca93f65b Merge pull request #877 from micro/tun-delay
Tunnel Delay and link buffers
2019-10-23 16:49:18 +01:00
Asim Aslam
bf4a73d5c0 Close the socket in the link 2019-10-23 16:39:26 +01:00
Asim Aslam
fe180148a1 rearrange where we account for errors and data sent 2019-10-23 16:15:39 +01:00
Asim Aslam
842fc01568 add send/recv queues for link 2019-10-23 16:05:21 +01:00
Asim Aslam
d4832e8f34 Remove consul registry (#818) 2019-10-23 15:53:28 +01:00
Asim Aslam
5ac5865154 add comment 2019-10-23 10:55:53 +01:00
Asim Aslam
f07a6ac29b Merge pull request #875 from micro/tun-measure
Measure roundtrip times on link
2019-10-22 21:20:57 +01:00
Asim Aslam
d64f8c665e add rate measure 2019-10-22 19:38:29 +01:00
Asim Aslam
407694232a Measure roundtrip times on link 2019-10-22 18:43:09 +01:00
Asim Aslam
418b8648bb Merge pull request #874 from micro/tun-metrics
Add placeholders for link metrics
2019-10-22 17:03:07 +01:00
Asim Aslam
85e273afa5 reorder methods 2019-10-22 17:02:22 +01:00
Asim Aslam
ab9fa20a50 Update comments 2019-10-22 16:53:47 +01:00
Asim Aslam
4fddd69229 Add placeholders for link metrics 2019-10-22 16:50:00 +01:00
Asim Aslam
317cf76566 Merge pull request #872 from micro/round-robin
Round robin routes we've sorted by metric
2019-10-22 11:58:44 +01:00
Asim Aslam
f792fac1cc Round robin routes we've sorted by metric 2019-10-22 11:53:49 +01:00
Asim Aslam
a89d1edc41 fix divide by zero bug 2019-10-19 08:11:05 +01:00
Asim Aslam
d3140c0fc2 Merge pull request #867 from milosgajdos83/rlock-mess
Avoid recursive RLock()
2019-10-18 11:35:08 +01:00
Milos Gajdos
3d5d9be02a Avoid recursive calls to RLock()
Topology calls itsel recursively invoking RLock. This, according to go
documentation is wrong. This commit moves the body of Topology function
to a non-thread safe unexported function to keep locsk at check!
2019-10-18 11:26:43 +01:00
Asim Aslam
5c38f38dd9 No need to lock here since Topology read locks and makes copies 2019-10-18 11:26:43 +01:00
Asim Aslam
63fd8b9d1b Merge pull request #864 from micro/strip-topic
strip topic from http broker subscribe service name
2019-10-17 18:48:46 +01:00
Asim Aslam
3aedea4c56 strip topic from http broker subscribe service name 2019-10-17 18:37:37 +01:00
Asim Aslam
0da9dff077 Merge pull request #863 from micro/certmagice2e
E2E tests for certmagic ACME provider
2019-10-17 16:42:33 +01:00
Jake Sanders
05774f2c76 Don't touch go.mod 2019-10-17 16:35:09 +01:00
Jake Sanders
4885bba2ac E2E tests for certmagic ACME provider
* Actually set the CA
* Fix the certmangic.storage interface to return the correct error type
* Write an e2e test for certmagic against the let's encrypt staging CA
2019-10-17 16:31:02 +01:00
Asim Aslam
9d559848c2 Merge pull request #862 from milosgajdos83/tunnel-cleanup
Cleanup of tunnel.Dial(). Clean up network channel processors
2019-10-16 21:19:30 +01:00
Milos Gajdos
2ae583ce94 Cleanup of tunnel dial code. Clean up network channel processors 2019-10-16 20:44:22 +01:00
Asim Aslam
7c1e22b607 Merge pull request #861 from micro/certmagicstorage
Distributed storage for certmagic
2019-10-16 14:10:02 +01:00
Jake Sanders
7d2afa34a0 Implementation and tests for certmagic.Storage interface 2019-10-16 12:58:14 +01:00
Jake Sanders
a6e95d389f Implementation of certmagic storage using micro's store and sync packages 2019-10-15 19:32:20 +01:00
Asim Aslam
b1d5dc20fa Merge pull request #860 from micro/tunnel-mode
Tunnel mode
2019-10-15 16:14:38 +01:00
Asim Aslam
be5093798b Use DialMode/ListenMode 2019-10-15 16:08:38 +01:00
Asim Aslam
3759c9c091 Merge pull request #859 from milosgajdos83/handle-channel-conn-errors
Handle tunnel session Accept errors gracefully
2019-10-15 16:05:19 +01:00
Milos Gajdos
4936a2e1a5 Exponential backoff for failed accept connections 2019-10-15 15:58:33 +01:00
Asim Aslam
ca934951ad Use multicast on network/control channels 2019-10-15 15:57:13 +01:00
Asim Aslam
ca18089382 Fix bugs related to needing to send Broadcast 2019-10-15 15:55:08 +01:00
Asim Aslam
7b1f5584ab Tunnel mode 2019-10-15 15:40:04 +01:00
Milos Gajdos
fed5af68e6 Handle Accept errors gracefully.
Originally when Accept fails we log the error and let the program flow
continue. This can lead to us spawning handling connection go routines
on nil connections which in turn leads to Go panics.
2019-10-15 15:07:28 +01:00
Asim Aslam
fdfeb437f9 Merge pull request #856 from micro/cloudflare
Cloudflare Store implementation for workers KV
2019-10-15 14:29:34 +01:00
Jake Sanders
a46133f059 cloudflare workers KV Store implementation 2019-10-15 12:35:45 +01:00
Jake Sanders
9bd0a8f3b5 Update go.mod for cloudflare 2019-10-15 12:35:20 +01:00
Asim Aslam
44b794722e rcache becomes cache 2019-10-14 22:39:26 +01:00
Asim Aslam
247249050b move mutex to memory 2019-10-14 22:38:22 +01:00
Asim Aslam
b1fed01752 add network name to node 2019-10-14 22:26:23 +01:00
Asim Aslam
df1e680256 Merge pull request #854 from micro/lock-http
Lock http
2019-10-14 22:01:25 +01:00
Asim Aslam
854b01c20c Add acquire/release to http path 2019-10-14 21:52:18 +01:00
Asim Aslam
745299bce5 add http lock implementation 2019-10-14 21:39:25 +01:00
Asim Aslam
607fdb3fcb Merge pull request #852 from micro/mutex
add mutex lock implementation
2019-10-14 15:23:59 +01:00
Asim Aslam
a1342c23fb add mutex lock implementation 2019-10-14 15:17:25 +01:00
Asim Aslam
1cea2f5bba Merge pull request #850 from micro/acmetypo
TLS -> ToS
2019-10-14 12:10:55 +01:00
Jake Sanders
a1b4786682 TLS -> ToS 2019-10-14 12:04:49 +01:00
Asim Aslam
b701da6d69 Merge pull request #849 from micro/connect-init
Connect init
2019-10-13 18:40:11 +01:00
Asim Aslam
f77df51f60 Support reconnects 2019-10-13 18:36:22 +01:00
Asim Aslam
d6c6e7815e Spaces not tabs 2019-10-13 12:40:53 +01:00
Asim Aslam
01492997ea add Network.Init method 2019-10-13 12:38:13 +01:00
Asim Aslam
174f1b857c Network handler moves to service/handler 2019-10-13 12:37:56 +01:00
Asim Aslam
5029d80e68 add Network.Connect handler and network/metadata fields to node 2019-10-13 12:37:39 +01:00
Asim Aslam
b59c5a4488 move network handler to service/handler 2019-10-13 12:37:13 +01:00
Asim Aslam
f7f65b82e6 Cleanup registry handler/service 2019-10-13 12:23:13 +01:00
Asim Aslam
2e47fdc6f5 Check the node map to avoid dupes in resolved nodes 2019-10-12 20:26:06 +01:00
Asim Aslam
18ea19a122 Regenerate go.mod 2019-10-12 12:04:55 +01:00
Asim Aslam
4d75b936f8 Merge pull request #846 from theophanous/master
fix: bumped quic-go version to v0.12.1
2019-10-11 18:24:45 +01:00
Peter Theophanous
62aaa72715 fix: bumped quic-go version to v0.12.1 2019-10-11 18:16:56 +01:00
Asim Aslam
8c344ed55b Merge pull request #839 from theophanous/master
bumped quic-go version to v0.12.1
2019-10-11 17:26:48 +01:00
Peter Theophanous
db843c8d87 reset orig 2019-10-11 17:15:20 +01:00
Asim Aslam
dd7677e6cc Add nil check for acme provider 2019-10-11 16:52:57 +01:00
Asim Aslam
a4f0dd8939 Merge pull request #845 from micro/certmagic
Implementation of CertMagic as the ACME provider
2019-10-11 16:52:21 +01:00
Jake Sanders
591e87448b Travis doesn't let us bind :443 2019-10-11 16:47:12 +01:00
Jake Sanders
09a202ccf0 Merge branch 'master' of https://github.com/micro/go-micro into certmagic 2019-10-11 16:25:28 +01:00
Jake Sanders
723c17fdd7 Implementation of certmagic as an ACME provider 2019-10-11 16:25:15 +01:00
Jake Sanders
9bd96d4cc1 Update go.mod for ACME changes 2019-10-11 16:24:25 +01:00
Asim Aslam
9bfe4d9bf7 Merge pull request #844 from micro/store
Store service implementation
2019-10-11 14:49:44 +01:00
Asim Aslam
76eee089e3 Add store service client 2019-10-11 14:44:42 +01:00
Asim Aslam
cfa2b668e2 go fmt 2019-10-11 14:44:34 +01:00
Asim Aslam
a96f6adf07 store handler implementation 2019-10-11 14:08:50 +01:00
Asim Aslam
49fe5d9fd5 Merge pull request #843 from milosgajdos83/dead-code
Clean up dead tunnel code
2019-10-11 11:15:29 +01:00
Milos Gajdos
21469a0427 Clean up dead tunnel code
Running go vet on tunnel package returns:
$ go vet ./...
./default.go:929:2: unreachable code
./link.go:104:2: unreachable code
./listener.go:184:2: unreachable code
./session.go:241:2: unreachable code
2019-10-11 11:02:45 +01:00
Asim Aslam
e351e9518f Merge pull request #842 from milosgajdos83/cache-status
Check cache status error
2019-10-11 10:55:35 +01:00
Milos Gajdos
fc89c9831e heck cache status error 2019-10-11 10:47:42 +01:00
Peter Theophanous
5e5d57d954 bumped quic-go version to v0.12.1 2019-10-10 22:23:33 +01:00
Asim Aslam
98e1f2c2d3 Merge pull request #838 from micro/etcd
Use etcd serializable option
2019-10-10 19:22:10 +01:00
Asim Aslam
59a3e7d4f4 Use etcd serializable option 2019-10-10 19:16:31 +01:00
Asim Aslam
1be6ec9b3c Merge pull request #837 from milosgajdos83/prune-dead-router-peers
Prune routes from routers that are not in your peer graph
2019-10-10 16:12:56 +01:00
Milos Gajdos
f6931f3da7 Prune routes from routers that are not in your peer graph 2019-10-10 15:28:27 +01:00
Asim Aslam
b2f99a27b7 Visit all the nodes in flatten 2019-10-10 14:35:11 +01:00
Asim Aslam
1f5ebf330d Merge pull request #836 from micro/prune-address
Prune the peer address
2019-10-10 11:43:19 +01:00
Asim Aslam
0dee11e006 Prune the peer address 2019-10-10 11:25:28 +01:00
Asim Aslam
b55018eaa1 Merge pull request #833 from orbli/patch-1
Add dialoptions and calloptions
2019-10-10 07:40:48 +01:00
orb li
77108771db Conceptual deliverable 2019-10-10 13:55:16 +08:00
Asim Aslam
5a6e73d4a8 Merge pull request #835 from milosgajdos83/router-strategy
Router strategy
2019-10-09 19:18:59 +01:00
Milos Gajdos
7a4bff4e9f Changed names of some variables. 2019-10-09 19:08:24 +01:00
Milos Gajdos
d5ce96da24 Avoid locking on reading strategy for now 2019-10-09 18:19:48 +01:00
Milos Gajdos
837597fe6f Make Optimal strategy default. Collapse routing tables based on strategy 2019-10-09 17:24:38 +01:00
Milos Gajdos
96e564e402 Add router advertisement Strategy option to router. 2019-10-09 17:24:38 +01:00
Asim Aslam
fe94237448 Update router querying method (#834)
* Add address to router query options. Drop Query interface for QueryOptions

* Cleanup isMatch function

* Update network proto
2019-10-09 17:13:52 +01:00
Jake Sanders
107b7419b7 Start abstracting away the ACME provider (#830)
* Start abstracting away the ACME provider

* Move ACME to interface with sub-package implementations

* Addressing comments

* Library -> Provider

* Missed a couple of Library -> Provider

* One more Library -> Provider

* remove constants
2019-10-09 16:42:05 +01:00
orb li
226d55d752 Adding dependency 2019-10-09 16:48:45 +08:00
orb li
88ef785127 Add dialoptions and calloptions 2019-10-09 15:56:39 +08:00
Asim Aslam
44473f954f Merge pull request #829 from milosgajdos83/limit-net-connections
Limit the number of outbound connections to MaxConnections
2019-10-08 15:56:45 +01:00
Milos Gajdos
fe5846603a Only limit the number of nodes returned by network resolver. 2019-10-08 15:48:52 +01:00
Milos Gajdos
61800fb7d7 Fix typo: MaxCconnections -> MaxConnections 2019-10-08 15:15:50 +01:00
Milos Gajdos
ec2fbde979 Limit the number of outbound connections to MaxConnections
This commit also fixes control channel shenanigans:
- recover error in control channel accept
2019-10-08 14:48:04 +01:00
Asim Aslam
b886dd4b8f Merge pull request #828 from micro/net-lookup
Use dns resolver on peer nodes
2019-10-08 10:36:04 +01:00
Asim Aslam
94adeebed4 Use dns resolver on peer nodes 2019-10-08 09:25:23 +01:00
Asim Aslam
d043ca15c1 Merge pull request #827 from micro/resolver
Add dns net.LookupHost resolver!
2019-10-08 09:08:34 +01:00
Asim Aslam
ad823d5177 Add dns net.LookupHost resolver! 2019-10-08 09:04:13 +01:00
Asim Aslam
89d71417f5 Merge pull request #825 from milosgajdos83/net-chan-nodes
Recover net channel Accept() errors. Init tunnel nodes before tunnel.Connect()
2019-10-07 20:29:45 +01:00
Milos Gajdos
9d9683b6f9 Recover net channel Accept errors. Init tunnel nodes before Connect 2019-10-07 19:09:04 +01:00
Asim Aslam
0edcd5c8dc Merge pull request #824 from micro/tunnel
wait for response on accept message
2019-10-07 18:33:00 +01:00
Asim Aslam
2e1432d5dc wait for response on accept message 2019-10-07 18:29:49 +01:00
Asim Aslam
e4f8b5de70 Merge pull request #823 from micro/list-services
Support listing full service info in etcd
2019-10-07 16:15:30 +01:00
Asim Aslam
e9dcff49e0 Support listing full service info in etcd 2019-10-07 16:11:52 +01:00
Asim Aslam
fa6590f999 Merge pull request #822 from micro/service
Add Name to Service
2019-10-07 08:43:07 +01:00
Asim Aslam
fd8a0fb2f5 Update internal service definition 2019-10-07 08:34:15 +01:00
Asim Aslam
b594547408 Add service Name 2019-10-07 08:32:28 +01:00
Asim Aslam
2c00e726b6 Decode and hash the existing node 2019-10-06 13:43:41 +01:00
Asim Aslam
68a3fc7996 Merge pull request #820 from micro/etcd-reg
Fix etcd registry lease processing and suppression
2019-10-06 10:03:38 +01:00
Asim Aslam
2fb2d7145e Fix etcd registry lease processing and suppression 2019-10-06 09:54:26 +01:00
Asim Aslam
6fe9f2a958 Merge pull request #815 from micro/broker
Add broker service implementation
2019-10-04 17:23:29 +01:00
Asim Aslam
86984a8a8a Extend the stream timeout 2019-10-04 16:44:21 +01:00
Asim Aslam
cfb846ee7e Fix race in cache 2019-10-04 16:40:21 +01:00
Asim Aslam
e36960612a go fmt 2019-10-04 16:40:16 +01:00
Asim Aslam
04320d69ff Fix and comment broker service 2019-10-04 16:30:03 +01:00
Asim Aslam
c4b6d0f3a8 fix major deadlock in registry cache 2019-10-04 16:29:56 +01:00
Asim Aslam
3c6b6553fb Use peerAddress as the thing to listen on 2019-10-03 18:35:54 +01:00
Asim Aslam
d5658ab0b0 Merge pull request #816 from micro/net-advertise
Advertise your peer address as advertised address
2019-10-03 17:42:11 +01:00
Asim Aslam
2244eb8597 Advertise your peer address as advertised address 2019-10-03 17:37:29 +01:00
Asim Aslam
05eacd74c8 Add logging for broker handler 2019-10-03 17:30:37 +01:00
Asim Aslam
b80654bf7e Add broker service to config/cmd 2019-10-03 16:22:26 +01:00
Asim Aslam
0941a0f031 Merge pull request #814 from milosgajdos83/etcd-port
Append a port to address if it does not exist
2019-10-03 16:20:43 +01:00
Asim Aslam
4de346920f Add broker service implementation 2019-10-03 16:19:02 +01:00
Milos Gajdos
b8815dff14 Append a port to address if it does not exist 2019-10-03 16:16:25 +01:00
Asim Aslam
b1163b9dee Fix breaking import 2019-10-03 11:26:24 +01:00
Asim Aslam
af5d7a3420 Move the remaining consul cruft to go-plugins 2019-10-03 11:22:35 +01:00
Asim Aslam
b5f33b2aaa Rename Dump to Sync 2019-10-03 09:56:25 +01:00
Asim Aslam
a9c85eda68 Merge pull request #813 from micro/store
Move out consul sync/lock and store. Move data/store to store
2019-10-03 09:51:21 +01:00
Asim Aslam
b5ca40a91a Move out consul sync/lock and store. Move data/store to store 2019-10-03 09:46:20 +01:00
Asim Aslam
b81bb07afc Merge pull request #812 from micro/gossip
Remove gossip registry
2019-10-03 09:36:14 +01:00
Asim Aslam
8d2b12258f Remove gossip registry 2019-10-03 09:29:48 +01:00
Asim Aslam
31026da2a1 Update etcd.go
Use /micro/registry as the etcd key prefix
2019-10-02 20:33:59 +01:00
Asim Aslam
1129803bcb Merge pull request #810 from milosgajdos83/etcd
First commit to add etcd registry support
2019-10-02 20:27:38 +01:00
Milos Gajdos
25148af44c First commit to add etcd registry support 2019-10-02 18:56:53 +01:00
Asim Aslam
36675aff1e Merge pull request #809 from micro/log-prefix
Add ability to set log prefix
2019-10-02 17:47:27 +01:00
Asim Aslam
b6db0d2663 Add ability to set log prefix 2019-10-02 17:42:34 +01:00
Asim Aslam
2370fb1209 Set gateway to node address rather than id 2019-10-02 15:52:31 +01:00
Asim Aslam
519e8a7213 Merge pull request #808 from micro/net-address
Hash the network address
2019-10-02 15:27:07 +01:00
Asim Aslam
308424488b Hash the network address 2019-10-02 15:22:44 +01:00
Asim Aslam
5d77ce9e9b Rename rcache file to cache 2019-10-02 12:35:20 +01:00
Asim Aslam
9eb6262168 Merge pull request #807 from unistack-org/fixup
some spelling fixes in memory and gossip registry
2019-10-02 10:47:59 +01:00
b722798caa some spelling fixes in memory and gossip registry
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-10-02 03:54:04 +03:00
Asim Aslam
0cf7b70423 Merge pull request #806 from milosgajdos83/go-mod-shrink
Update go.mod
2019-10-01 20:13:26 +01:00
Milos Gajdos
03b8ceab5c Update go.mod 2019-10-01 19:33:23 +01:00
Asim Aslam
e8a53610f1 Update go mod to use 1.13 2019-10-01 19:09:29 +01:00
Asim Aslam
e48155118f Update go mod 2019-10-01 18:55:03 +01:00
Asim Aslam
6477c3afff Bump travis 2019-10-01 18:33:26 +01:00
Asim Aslam
57647772c8 Merge pull request #790 from milosgajdos83/memreg-ttl
[WIP] Memory registry TTL expiry
2019-09-30 15:35:57 +01:00
Milos Gajdos
4b73ac9dc5 Simplified code. Small bug fix the used to lead to multi-registry loop. 2019-09-30 12:48:59 +01:00
Milos Gajdos
3f3f1272b3 Turn regular logs to Debug logs; annotate with Registry "tag" 2019-09-30 12:48:59 +01:00
Milos Gajdos
859ecb1872 Dont set default TTL. Stop tracking nodes with no TTL 2019-09-30 12:48:59 +01:00
Milos Gajdos
204c7d1fcf Fixed options bug and proto indenting 2019-09-30 12:48:59 +01:00
Milos Gajdos
8417361bce Set registry TTL to seconds, not the nanoseconds 2019-09-30 12:48:59 +01:00
Milos Gajdos
d85ca7abd2 Set registry TTL properly via protobuf Options 2019-09-30 12:48:59 +01:00
Milos Gajdos
e973bfaa25 Add TTL options to memory registry. 2019-09-30 12:48:59 +01:00
Milos Gajdos
27bd9581bf Refresh TTL; prune expired nodes. 2019-09-30 12:48:59 +01:00
Milos Gajdos
16c7b3a390 Added Registry TTL to memory registry. Tracking node lifetimes. 2019-09-30 12:48:59 +01:00
potato
f933457cc1 Merge pull request #5 from micro/master
pull request from go-micro
2019-09-30 17:22:51 +08:00
Asim Aslam
219d759f1d Merge pull request #802 from micro/services
Add Network.Services handler
2019-09-30 07:55:03 +01:00
Asim Aslam
b90871c241 Add Network.Services handler 2019-09-30 07:51:13 +01:00
Asim Aslam
1322fb0d9d Merge pull request #800 from kordenlu/master
fix rcache node overwrited issue
2019-09-30 07:17:46 +01:00
lubaoquan
0eb69e4f9a Undo go.mod go.sum change,fixes https://github.com/micro/go-micro/issues/793 2019-09-30 10:57:35 +08:00
lubaoquan
1ed73d0f91 fixes https://github.com/micro/go-micro/issues/793 2019-09-30 10:38:53 +08:00
lubaoquan
866631df1d fixes https://github.com/micro/go-micro/issues/793 2019-09-30 10:36:43 +08:00
lubaoquan
d5e962c4a8 fixes https://github.com/micro/go-micro/issues/793 2019-09-29 10:27:38 +08:00
Asim Aslam
9ec27392de Merge pull request #799 from milosgajdos83/go1.13-fix-tests
Fix tests to make go-micro work on Go 1.13
2019-09-27 18:14:54 +01:00
Milos Gajdos
de1d9122ea Remove 1.13 support because go-quic reasons nobody understands 2019-09-27 17:19:38 +01:00
Milos Gajdos
87a5e85062 Add 1.13 support. Fix tests to enable 1.13 support 2019-09-27 17:14:24 +01:00
Asim Aslam
da572041ca Merge pull request #797 from RichardLindhout/patch-1
Do not log error when EOS is being written on an EOF socket
2019-09-27 15:18:35 +01:00
Richard Lindhout
a725998c0a Update rpc_server.go 2019-09-27 16:01:16 +02:00
Richard Lindhout
f3b723ca44 Do nog log error when EOS is being written on an EOF socket 2019-09-27 15:02:21 +02:00
Asim Aslam
e1bb4d7379 Merge pull request #795 from milosgajdos83/advert-events
Rather than append to list of events just keep the last event
2019-09-26 18:13:28 +01:00
Milos Gajdos
2d7975a7ce Rather than append to list of events just keep the last event for a route hash 2019-09-26 17:54:55 +01:00
Asim Aslam
8b77d62ed4 Merge pull request #794 from micro/hash
Don't shutdown old nodes in mdns registry
2019-09-26 16:50:17 +01:00
Asim Aslam
ef7bb46884 Don't shutdown old nodes in mdns registry 2019-09-26 16:46:09 +01:00
Asim Aslam
06975f64b7 Merge pull request #792 from milosgajdos83/router-fixes
Simplified table code. Fixed event dedup
2019-09-26 12:53:40 +01:00
Milos Gajdos
a4c04d8f50 Only emit Update event if a route was updated/added 2019-09-26 12:45:10 +01:00
Milos Gajdos
b2577e6022 Update log statement 2019-09-26 12:19:00 +01:00
Milos Gajdos
77f3e7ef48 Simplified table code. Fixed event dedup. 2019-09-26 11:56:30 +01:00
Asim Aslam
6f2a8298ef Fix router log messages 2019-09-25 20:29:25 +01:00
Asim Aslam
9e33637213 Do not log send/recv body 2019-09-25 20:24:56 +01:00
Asim Aslam
99dbed0b67 Merge pull request #789 from micro/cache
Preserve cache in the face of failure
2019-09-25 19:49:21 +01:00
Asim Aslam
2b8210a106 Preserve cache in the face of failure 2019-09-25 19:44:46 +01:00
Asim Aslam
dfcedbab1e In case of non 200 response return error 2019-09-25 16:53:06 +01:00
Asim Aslam
140e3d576c Merge pull request #788 from micro/stream
Revert to creating new connections for stream
2019-09-25 15:26:09 +01:00
Asim Aslam
afa1f50435 Revert to creating new connections for stream 2019-09-25 15:21:21 +01:00
Asim Aslam
cb22136a35 Merge pull request #787 from micro/solicit
only solicit the first time seeing a peer
2019-09-25 14:35:09 +01:00
Asim Aslam
ae40553bad only solicit the first time seeing a peer 2019-09-25 14:30:35 +01:00
Asim Aslam
855cd5ecf4 Merge pull request #786 from micro/net
Do not embed proxy/router/tunnel
2019-09-25 13:00:36 +01:00
Asim Aslam
f23c6d91ba Do not embed proxy/router/tunnel 2019-09-25 12:56:52 +01:00
Asim Aslam
c3b430af53 Merge pull request #785 from micro/link
Keep track of errors and delete beyond error count > 3
2019-09-25 12:36:23 +01:00
Asim Aslam
3d2bf7d4f6 Add log message 2019-09-25 12:36:07 +01:00
Asim Aslam
6c2b9d7636 Keep track of errors and delete beyond error count > 3 2019-09-25 12:14:09 +01:00
Asim Aslam
be5799b09f Merge pull request #783 from micro/service
Add flag for registry service client
2019-09-25 11:14:17 +01:00
Asim Aslam
7fe64192a7 Add flag for registry service client 2019-09-25 11:09:19 +01:00
Asim Aslam
624d37cf13 Merge pull request #781 from milosgajdos83/hash-reg-service
Emit memory registry event only when it actually happens
2019-09-25 07:44:55 +01:00
Milos Gajdos
1f23c8a85a Emit memory registry event only when it actually happens 2019-09-25 01:58:28 +01:00
Asim Aslam
96e79c4498 Add runtime output 2019-09-24 19:00:11 +01:00
Asim Aslam
1b08036a0b add create options 2019-09-24 18:32:35 +01:00
Asim Aslam
c52651c4d0 Move runtime.Start to be non blocking 2019-09-24 18:05:51 +01:00
Asim Aslam
9f880a1215 Merge pull request #780 from milosgajdos83/registry-event
[WIP] Registry event
2019-09-24 14:48:38 +01:00
Milos Gajdos
39755721d0 Fix proto formatting 2019-09-24 14:39:51 +01:00
Milos Gajdos
ccda1d3559 Remove rpc Sync method from registry handler 2019-09-24 10:41:48 +01:00
Milos Gajdos
61ee436cc4 Added Sync RPC call; it's identical to ListServices for now 2019-09-23 21:08:31 +01:00
Milos Gajdos
04a5d884da Move global vars to the top of the src file: conventions 2019-09-23 20:48:25 +01:00
Milos Gajdos
0ec1b840fd Add registry event to registry package 2019-09-23 20:48:25 +01:00
Asim Aslam
71ab35e055 Merge pull request #778 from micro/register-interval
Set register ttl and interval by default
2019-09-23 18:04:52 +01:00
Asim Aslam
fa0d020556 Set register ttl and interval by default 2019-09-23 17:59:34 +01:00
Asim Aslam
d8dc713e2d Fix the http resolver to use micro.mu url 2019-09-23 17:50:53 +01:00
Asim Aslam
d38c8b23f2 Merge pull request #777 from micro/net-nodes
Set rpc methods as Network.Graph/Nodes/Routes
2019-09-23 15:47:49 +01:00
Asim Aslam
4260913b45 Set rpc methods as Network.Graph/Nodes/Routes 2019-09-23 15:41:05 +01:00
Asim Aslam
ac5eb5da47 Remove fmt 2019-09-22 15:31:07 +01:00
Asim Aslam
2434c7b2a7 replace version format 2019-09-22 15:21:22 +01:00
Asim Aslam
9fbc88a60f Provide a way to get status now 2019-09-20 17:55:02 +01:00
Asim Aslam
444cc59250 Ensure transport matches for monitoring service 2019-09-20 17:20:15 +01:00
Asim Aslam
95e4ed8ee9 Merge pull request #775 from micro/proxy-watcher
Fix the proxy watcher
2019-09-20 16:36:00 +01:00
Asim Aslam
4eb1aaae85 Fix the proxy watcher 2019-09-20 16:25:29 +01:00
Asim Aslam
46450ba507 Merge pull request #773 from micro/net-hash
Only hash address if its a local route
2019-09-20 10:50:35 +01:00
Asim Aslam
f13887f604 Only hash address if its a local route 2019-09-20 09:40:55 +01:00
Asim Aslam
66769e671f Merge pull request #772 from micro/peers
Replace Nodes with Peers
2019-09-19 16:53:17 +01:00
Asim Aslam
7e05d2c440 Replace Nodes with Peers 2019-09-19 16:32:15 +01:00
Asim Aslam
0abeb3f660 Merge pull request #771 from milosgajdos83/peers-race
Remove data race; Unlock once done pruning/deleting
2019-09-19 11:59:03 +01:00
Milos Gajdos
a38482ffcb Remove data race; Unlock once done pruning/deleting 2019-09-19 11:53:13 +01:00
Asim Aslam
ee74e26582 Merge pull request #769 from micro/advertise
allow setting advertise address
2019-09-18 19:06:24 +01:00
Asim Aslam
6222bc2a1e only set tunnel address if advertise is blank 2019-09-18 19:04:22 +01:00
Asim Aslam
05e62a2b95 allow setting advertise address 2019-09-18 18:56:02 +01:00
Asim Aslam
cdbab3df66 Merge pull request #766 from milosgajdos83/hash-service
Hash the service before advertising it to the network.
2019-09-17 18:39:17 +01:00
Milos Gajdos
38d6ffdf9a Hash the service address before advertising it to the network. 2019-09-17 18:34:06 +01:00
Asim Aslam
e586763301 Merge pull request #761 from milosgajdos83/delete-peer-gw
Delete dead peer [gateway] routes
2019-09-17 16:54:35 +01:00
Milos Gajdos
3201b4cb36 Gateway is now set to node Id, hence we prune peer.id Gateway 2019-09-17 16:31:33 +01:00
Asim Aslam
837cb4fc11 Merge pull request #763 from milosgajdos83/gateway-addressing
Fix gateway addressing
2019-09-17 16:27:35 +01:00
Milos Gajdos
21dc7bcccf Fix gateway addressing
- Set Gateway as node.ID when advertising
- Set server.Address as node.ID to listen on
- Set server.Advertise as node.Address
2019-09-17 16:11:02 +01:00
Asim Aslam
a811b4be3d Merge pull request #762 from micro/net-address
Set node address to tunnel address
2019-09-17 15:44:13 +01:00
Asim Aslam
9147d378bc Set node address to tunnel address 2019-09-17 15:40:00 +01:00
Asim Aslam
b7b968ad74 remove the funding thing 2019-09-17 12:43:20 +01:00
Asim Aslam
8e8a4c1a9d Update FUNDING.yml 2019-09-17 12:42:50 +01:00
Asim Aslam
bc29164f77 Update FUNDING.yml 2019-09-17 12:39:41 +01:00
Asim Aslam
e161b2fa84 Create FUNDING.yml 2019-09-17 12:36:36 +01:00
Milos Gajdos
a72a2f717d Prune stale nodes in the whole topology. 2019-09-16 19:22:55 +01:00
Milos Gajdos
2599ee8591 Prune routes routable via dead node. 2019-09-15 12:17:12 +01:00
Asim Aslam
364c5a4861 Immediately start services 2019-09-14 08:07:36 -07:00
Asim Aslam
c8a675249d Merge pull request #759 from micro/runtime
update runtime to function
2019-09-13 22:01:52 -07:00
Asim Aslam
0cdfc7b9ea add create/delete/start/stop to runtime 2019-09-13 21:58:03 -07:00
Asim Aslam
0fc4c180ee update runtime to function 2019-09-13 21:33:14 -07:00
Asim Aslam
e5f6480f8a Merge pull request #757 from milosgajdos83/empty-advert
Skip processing Advert which carries no events
2019-09-13 17:29:36 -07:00
Milos Gajdos
ccb6778f7f Skip processing Advert which carries no events 2019-09-13 20:46:14 +01:00
Asim Aslam
ef86c9625b Merge pull request #750 from milosgajdos83/node-peers
[WIP] Neighbour is now Peer. Peer is a node in network topology.
2019-09-13 12:00:16 -07:00
Asim Aslam
b23ee58865 Update default.go 2019-09-13 11:55:53 -07:00
Milos Gajdos
323a72be34 Small refactoring; Split horizon loop break. 2019-09-13 18:46:24 +01:00
Milos Gajdos
d72e91fb38 Unlock on return from network.Connect 2019-09-13 03:31:58 +01:00
Milos Gajdos
b91c3147e7 Node API allows us to drop all network locks
Network locks are now needed only when accessing client map. node map
access is serialied with the node mutex.
2019-09-13 03:03:56 +01:00
Milos Gajdos
ef91d836eb Implement Solicit method for handler.Router 2019-09-13 03:03:56 +01:00
Milos Gajdos
77c6c9781b getProtoTopology has been replaced by PeersToProto
This helps us remove redundant code across node and handler
2019-09-13 03:03:56 +01:00
Milos Gajdos
fa4ff8921e Removed redundant lock. Simplified proto topology 2019-09-13 03:03:56 +01:00
Milos Gajdos
d6be91e8af Changed RPC methods. Changed Network interface.
* Nodes/Topology removed from public methods from Network interface
* Peers() returns max depth 3 topology
* handler.Topology rpc endpoint removed
* handler.Peers rpc endpoint accept "depth" param to return max depth peers
2019-09-13 03:03:56 +01:00
Milos Gajdos
588484c3bf Fixed some races. Added more tests. 2019-09-13 03:03:56 +01:00
Milos Gajdos
d58eb51976 Code change to make Solicit router.proto message 2019-09-13 03:03:55 +01:00
Milos Gajdos
35cf2a5739 Make topology test more generic 2019-09-13 03:03:55 +01:00
Milos Gajdos
2dfbe93d65 Added more node tests. Small refactoring of Netowkr and handler. 2019-09-13 03:03:55 +01:00
Milos Gajdos
16fcf1fbda Nodes, Peers and Topology methods for node
Topology accepts an argument to define the depth of the topology
requested from the network. proto definitions have been modified
accordingly, too.
2019-09-13 03:03:55 +01:00
Milos Gajdos
cbce5490d7 Lock the Nodes method properly when collecting them. 2019-09-13 03:03:55 +01:00
Milos Gajdos
4c709f7ac1 Write Lock() advert update: we are writing into peers map here 2019-09-13 03:03:55 +01:00
Milos Gajdos
baf4c05663 Send solicit message to ControlChannel 2019-09-13 03:03:55 +01:00
Milos Gajdos
195c6a8c90 Neighbour is now peer. Neighbourhood is Peers. Small refactor. 2019-09-13 03:03:54 +01:00
Milos Gajdos
f91d0408ab Moved node implementation into dedicated source file 2019-09-13 03:03:54 +01:00
Milos Gajdos
eec780aaa7 Update neighbours when neighbour message is received 2019-09-13 03:03:54 +01:00
Milos Gajdos
f0a1031e97 Adding new peers up to given depth. Outline of node gaph Update 2019-09-13 03:03:54 +01:00
Asim Aslam
a6668ae057 Move delete link log message 2019-09-12 17:40:47 -07:00
Asim Aslam
af5421c2cf Merge pull request #756 from micro/tunnel
Missing fixes for the tunnel
2019-09-12 17:17:33 -07:00
Asim Aslam
2406ef9999 Missing fixes for the tunnel 2019-09-12 17:12:49 -07:00
Asim Aslam
af585d3a57 Merge pull request #755 from micro/tunnel
Add tunnel fixes for quic and keepalive
2019-09-12 16:35:53 -07:00
Asim Aslam
97cf478f71 Add tunnel fixes for quic and keepalive 2019-09-12 16:22:43 -07:00
Asim Aslam
ec6a30be37 Links above Dial/Listen in interface 2019-09-11 12:49:27 -07:00
Asim Aslam
634c55e2d7 Merge pull request #753 from micro/link
Option to set Link
2019-09-11 12:16:07 -07:00
Asim Aslam
cb0de43dba add link status 2019-09-11 12:12:11 -07:00
Asim Aslam
63d535aea9 Add link field to session 2019-09-11 12:07:43 -07:00
Asim Aslam
6819386e05 Remove dead link code 2019-09-11 12:00:55 -07:00
Asim Aslam
988603f87e Merge pull request #752 from printfcoder/master
recover gPRC handler if panic
2019-09-11 09:10:30 -07:00
Asim Aslam
9ca7d90f11 link crufT 2019-09-11 07:11:40 -07:00
Asim Aslam
6ec32805d0 Don't allow socket close while writing h2 headers 2019-09-10 18:26:12 -07:00
Shu Xian
c1c173dfe5 recover handler if panic 2019-09-11 00:40:40 +08:00
Shu Xian
ce18de2647 Merge branch 'master' of github.com:micro/go-micro 2019-09-11 00:39:19 +08:00
Asim Aslam
3e3bbe3fd0 Merge pull request #751 from micro/link
Move link to tunnel/
2019-09-10 08:16:35 -07:00
Asim Aslam
b5eea02f7a Move link to tunnel/ 2019-09-10 08:12:28 -07:00
Asim Aslam
08c6f60b0f Merge pull request #746 from micro/plugin
Support plugin loading
2019-09-10 05:38:10 -07:00
Asim Aslam
065c7d5616 fix plugin init 2019-09-10 05:32:49 -07:00
Asim Aslam
a5ce3e32da Support plugin loading on service.Init 2019-09-09 20:17:36 -07:00
Asim Aslam
3bfbcd5e6a Add default plugin loader 2019-09-09 19:43:13 -07:00
Asim Aslam
b6c6b13277 Support plugin loading 2019-09-09 19:09:28 -07:00
Asim Aslam
04b31d374c Merge pull request #745 from micro/registry-service
Add service registry
2019-09-09 13:05:46 -07:00
Asim Aslam
e828a099c5 Merge pull request #744 from micro/mdns-domain
Use .micro domain for mdns
2019-09-09 11:59:37 -07:00
Asim Aslam
2c16c7e62f Fix build breaks 2019-09-09 09:25:47 -07:00
Asim Aslam
1f44d7a4a1 Add registry handler 2019-09-09 09:20:17 -07:00
Asim Aslam
b076ef906a Add service registry 2019-09-09 08:57:57 -07:00
Asim Aslam
c669a2b155 Use .micro domain for mdns 2019-09-09 05:11:25 -07:00
Asim Aslam
48a3e51aca Merge pull request #742 from micro/unlock
unlock before sending the message to avoid deadlock
2019-09-06 17:06:39 +01:00
Asim Aslam
e8aaca27d3 unlock before sending the message to avoid deadlock 2019-09-06 16:57:17 +01:00
Asim Aslam
5596407144 Merge pull request #741 from milosgajdos83/list-nodes
List nodes now works properly. Send solicit message on ControlChannel
2019-09-06 15:18:25 +01:00
Milos Gajdos
7971b1b7f9 Remove debug logs 2019-09-06 15:12:23 +01:00
Milos Gajdos
dafbacbdcb Properly handle the list of the nodes. Send solicit on ControlChannel 2019-09-06 15:09:49 +01:00
Asim Aslam
df5657dcd1 Merge pull request #737 from milosgajdos83/buffered-advertchan
Lets make advert channel buffered so we don't lose adverts
2019-09-05 19:19:03 +01:00
Milos Gajdos
bb595c85b2 Lets make advert channel buffered so we don't lose adverts 2019-09-05 19:05:47 +01:00
Asim Aslam
bc6187ea89 Merge pull request #734 from micro/tunnel
Update tunnel to send discovery on connect and multicast messages. An…
2019-09-05 18:19:37 +01:00
Asim Aslam
ed1faa7a5c Add a discover ticker, announce on connect and refactor 2019-09-05 18:13:02 +01:00
Asim Aslam
1d9298ae2b Merge pull request #736 from milosgajdos83/solicit-routes
Solicit routes when new node is discovered
2019-09-05 18:08:49 +01:00
Milos Gajdos
dddfb6f878 Fixed typos and simplified map iteration 2019-09-05 17:59:14 +01:00
Milos Gajdos
ec354934e3 Move Errors to separate init block 2019-09-05 17:44:47 +01:00
Milos Gajdos
b01c8e06e0 Update error name to ErrClientNotFound 2019-09-05 17:43:59 +01:00
Asim Aslam
97b1071f7e Merge pull request #735 from huangzhhui/patch-1
Fixed the link of Chinese documentation
2019-09-05 17:43:03 +01:00
Asim Aslam
1527a84297 Shorten multicast discovery 2019-09-05 17:40:41 +01:00
Milos Gajdos
5ddfd911ba Replace send message code by one network method 2019-09-05 17:18:16 +01:00
黄朝晖
2310ee424c Update README.zh-cn.md 2019-09-05 23:52:54 +08:00
Milos Gajdos
2522d8cb96 Send solicit message when new neighbour is discovered 2019-09-05 16:04:44 +01:00
Asim Aslam
d198765c6c Put back close of listener 2019-09-05 15:23:19 +01:00
Asim Aslam
1840b5bd74 Update tunnel to send discovery on connect and multicast messages. Announce as broadcast 2019-09-05 15:16:11 +01:00
Milos Gajdos
9161b20d6b Add Solicit method to router interface
When calling Solicit, router lists all the routes and advertise them
straight away
2019-09-05 13:23:33 +01:00
Asim Aslam
a1ba1482c5 Only set link if not multicast 2019-09-05 07:41:19 +01:00
Asim Aslam
d0761e0a1b Merge pull request #733 from milosgajdos83/freeze-graph
Freeze network graph when building full network topology
2019-09-05 07:21:53 +01:00
Milos Gajdos
4b1a7abb42 Freeze network graph when building full network topology
Also added some comments and debug logs
2019-09-05 00:16:22 +01:00
Asim Aslam
e33bd17894 Merge pull request #732 from micro/massive-cruft
Fix massive cruft in tunnel dial to set the link on discovered
2019-09-04 20:27:07 +01:00
Asim Aslam
cc5d811a83 add comment to tunnel link selection 2019-09-04 20:19:53 +01:00
Asim Aslam
e15389febb Fix massive cruft in tunnel dial to set the link on discovered 2019-09-04 20:18:26 +01:00
Asim Aslam
6d63c3777f Merge pull request #731 from micro/tunnel
Add some fixes
2019-09-04 18:53:48 +01:00
Asim Aslam
d8a1b47954 Remove lock from link 2019-09-04 18:48:43 +01:00
Asim Aslam
b9a2f719a0 Add some fixes 2019-09-04 18:46:20 +01:00
Asim Aslam
46a9767648 Merge pull request #730 from milosgajdos83/advert-lastseen
Update node.lastSeen properly. Set node.lastSeen when processing advert
2019-09-04 18:13:43 +01:00
Milos Gajdos
dd9f42e3b9 Update lastSeen timestamp properly. Set lastSeen when processing advert 2019-09-04 18:02:13 +01:00
Asim Aslam
f2c8492c77 Merge pull request #729 from micro/tunnel
Tunnel session management and unicast/multicast
2019-09-04 16:25:38 +01:00
Asim Aslam
407381912b Don't try discover on multicast, don't block existing sessions on listen 2019-09-04 15:55:37 +01:00
Asim Aslam
d559ce9da2 Provide Links() method in Tunnel 2019-09-04 15:41:57 +01:00
Asim Aslam
7ab3934eb7 add message comment 2019-09-04 12:18:37 +01:00
Asim Aslam
0075477df0 make tunnel broker use multicast 2019-09-04 12:18:31 +01:00
Asim Aslam
d5be2136ad cleanup new message creation 2019-09-04 12:16:31 +01:00
Asim Aslam
c718b8bf93 Move vars and comment 2019-09-04 12:00:11 +01:00
Asim Aslam
a24818ee54 Fix typo 2019-09-04 11:58:25 +01:00
Asim Aslam
66db0ac52c Move announce into session 2019-09-04 11:58:03 +01:00
Asim Aslam
b9c437fbfe Tunnel discover/announce/open/session/close 2019-09-04 09:48:05 +01:00
Asim Aslam
147899283c Merge pull request #728 from wuyumin/master
Update config source README file
2019-09-04 09:16:04 +01:00
Yumin Wu
5b991cd2c2 Update config source README file 2019-09-04 15:49:58 +08:00
Yumin Wu
bb64f94313 .gitignore file for develop tools 2019-09-04 15:47:46 +08:00
Milos Gajdos
4f4b3d3bae Send connect message to NetworkChannel once we are not at caller mercy 2019-09-03 19:51:52 +01:00
Asim Aslam
eb4a709195 Merge branch 'master' of ssh://github.com/micro/go-micro into tunnel 2019-09-03 17:20:39 +01:00
Asim Aslam
6c21b31226 Merge pull request #727 from milosgajdos83/bug-overhaul
Major bug overhaul in how we handle network.Nodes and related handler
2019-09-03 17:20:15 +01:00
Milos Gajdos
6eb6d050ed Major bug overhaul in how we handle network.Nodes and related handler 2019-09-03 16:39:27 +01:00
Asim Aslam
6c7582a6be Move message to session 2019-09-03 15:56:37 +01:00
Milos Gajdos
3ea4490d6c Don't preallocate the slice if you don't index later on. 2019-09-03 15:02:30 +01:00
Asim Aslam
b50c44a758 Merge pull request #726 from milosgajdos83/prune-nodes
Prune nodes that have not announced themselves for certain time period.
2019-09-03 10:28:31 +01:00
Milos Gajdos
ec6318befc Prune nodes that have not announced themselves for certain time period. 2019-09-03 10:00:14 +01:00
Asim Aslam
5440325a18 Merge pull request #724 from milosgajdos83/efficient-bfs-queue
Make Nodes() BFS implementation efficient
2019-09-03 07:43:37 +01:00
Milos Gajdos
fb13877904 Make Nodes() BFS implementation efficient 2019-09-03 02:58:17 +01:00
Asim Aslam
2f5e3c66b9 Merge pull request #723 from milosgajdos83/sort-nodes-search
Sort the returned slice of nodes before searching
2019-09-02 20:13:20 +01:00
Milos Gajdos
a8d4299df9 Sort the returned slice of nodes before searching
See docs:
https://golang.org/pkg/sort/#Search
2019-09-02 20:00:52 +01:00
Asim Aslam
90745c14f2 Merge pull request #722 from milosgajdos83/net-handler
[WIP] Network handler
2019-09-02 17:15:38 +01:00
Milos Gajdos
86665454e7 Implementation of Nodes method. First take on full handler 2019-09-02 17:06:21 +01:00
Milos Gajdos
4f5a849211 Added Nodes method to Network interface 2019-09-02 12:40:05 +01:00
Milos Gajdos
bf53c16e4b Rough outline of Network introspection interface 2019-09-02 12:40:05 +01:00
Asim Aslam
6c3631728b Merge pull request #721 from micro/tunnel
Separate lookup nodes and setup nodes
2019-09-02 12:10:24 +01:00
Asim Aslam
2cdfed359f Separate lookup nodes and setup nodes 2019-09-02 12:05:47 +01:00
Asim Aslam
956be5c59d Merge pull request #717 from micro/client-stream
use with stream for client connection
2019-09-02 07:36:41 +01:00
Asim Aslam
52d9d75dfa use with stream for client connection 2019-08-31 18:26:48 +01:00
Asim Aslam
0d94784e72 Add some tunnel comments 2019-08-31 17:32:20 +01:00
Asim Aslam
65c2de5a79 Merge pull request #716 from micro/tunnel
Rename Tunnel ID to Channel
2019-08-31 16:32:41 +01:00
Asim Aslam
6fa9d7270f Rename Tunnel ID to Channel 2019-08-30 20:05:00 +01:00
Asim Aslam
140c830af1 Merge pull request #715 from milosgajdos83/net-debug
Add proto definitions for network introspection.
2019-08-30 12:38:24 +01:00
Milos Gajdos
b37837ad92 Add proto definitions for network introspection. 2019-08-30 12:29:26 +01:00
Asim Aslam
10b64af0b3 Merge pull request #713 from milosgajdos83/route-loop-break
Avoid setting routes that route back to the node without its being direct GW to dest
2019-08-30 11:33:17 +01:00
Asim Aslam
5d01284574 Merge pull request #714 from wuyumin/master
Load consul source
2019-08-30 10:15:37 +01:00
Yumin Wu
ff81e4b246 Load consul source 2019-08-30 16:20:58 +08:00
Milos Gajdos
e955e3f798 Avoid routes that route back to node without its being direct GW to dest 2019-08-30 00:04:46 +01:00
Asim Aslam
a17a8b3372 Merge branch 'master' of ssh://github.com/micro/go-micro 2019-08-29 17:21:49 +01:00
Asim Aslam
e1d56fbf58 switch warn to error logging 2019-08-29 17:21:43 +01:00
Milos Gajdos
e7d8cdda44 Avoid duplicate debug logs. 2019-08-29 16:58:07 +01:00
Asim Aslam
690640eeeb Merge pull request #712 from milosgajdos83/route-update
Only emit table event if table.Update actually happens
2019-08-29 16:30:27 +01:00
Milos Gajdos
4f788c6fc7 Only emit the events when actually deleting the route 2019-08-29 16:25:21 +01:00
Milos Gajdos
f50bd400f8 Only emit event if Update actually happens 2019-08-29 16:21:30 +01:00
Asim Aslam
b457ec1990 Merge pull request #711 from milosgajdos83/node-neighbours
Don't override the neighbours.
2019-08-29 15:48:13 +01:00
Milos Gajdos
ffa6b551f4 Don't override the neighbours. 2019-08-29 15:42:07 +01:00
Asim Aslam
3d03fe4076 Fix panic for nil slice 2019-08-29 15:09:01 +01:00
Asim Aslam
6eecb199e9 Merge pull request #710 from micro/nodes
add the ability to provide seed nodes to the network
2019-08-29 15:00:51 +01:00
Asim Aslam
7479515099 add the ability to provide seed nodes to the network 2019-08-29 14:53:30 +01:00
Asim Aslam
6e3d53e1ee Merge pull request #709 from micro/tunnel-arp
Tunnel Direction Fix
2019-08-29 13:13:25 +01:00
Asim Aslam
721c5e6857 fix broken build 2019-08-29 13:11:20 +01:00
Asim Aslam
7d033818cf if the service name is blank, barf 2019-08-29 13:10:06 +01:00
Asim Aslam
00ab58f61b Fix loopback cruft 2019-08-29 12:42:27 +01:00
Asim Aslam
b3aef71fdb Merge pull request #708 from milosgajdos83/route-metric
Set the route.Metric before updating routing table
2019-08-29 12:28:43 +01:00
Milos Gajdos
8606f1e143 Set the route.Metric before updating routing table 2019-08-29 11:45:47 +01:00
Asim Aslam
927fac2cec Merge pull request #706 from milosgajdos83/neighbour-map
Broadcast neighbourhood
2019-08-28 23:16:42 +01:00
Asim Aslam
6ab86c9e57 Don't process unless connected, and only fire loopback messages back up the loopback 2019-08-28 23:12:22 +01:00
Milos Gajdos
db8e2620cb Make tunnel channel clients key-able. Neighbour map simplified.
tunClient is a map of tunnel clients keyed on tunnel channel name.
Neighbour map is now a cimple map of nodes which contains its nodes.
2019-08-28 23:11:26 +01:00
Milos Gajdos
d09b7dbbef Broadcast neighbourhood; fix critical bugs in channel connections
This commit introduces neighbourhood announcements which allows to
maintaing neighbour map if each next-hop node.

It also fixes a critical bug when accepting connections for a particular
tunnel channel.
2019-08-28 20:11:19 +01:00
Asim Aslam
a4f5772555 add network field to the routes 2019-08-28 08:41:19 +01:00
Asim Aslam
731f6f74dd Merge pull request #703 from milosgajdos83/net-id
Adds network id. Skips processing routes when router is the origin.
2019-08-28 08:05:19 +01:00
Milos Gajdos
5e7208119e Adds network id. Skips processing routes when router is the origin. 2019-08-27 23:08:35 +01:00
Asim Aslam
470304ef87 Merge pull request #701 from h-hy/master
Check last for the address binded in lo interface (LVS , DR mode)
2019-08-27 18:08:52 +01:00
huanghaoyan
a6ab4d7b4b check last for the address bind in lo interface. 2019-08-27 23:35:27 +08:00
Asim Aslam
87b56d46ac Use tunnel transport and set server address 2019-08-27 13:21:36 +01:00
Milos Gajdos
371b23d055 Introduce DefaultLink; dont hardcode name of the link 2019-08-27 11:36:46 +01:00
Asim Aslam
f97565ef0a Merge pull request #685 from milosgajdos83/default-network
Default network implementation
2019-08-27 11:02:55 +01:00
Asim Aslam
0888d2fbbc Add grpc content-type 2019-08-27 08:13:58 +01:00
Shu xian
75e20b5bf7 Merge pull request #1 from micro/master
merge
2019-08-27 09:38:18 +08:00
Asim Aslam
443fc0ebde Merge pull request #700 from micro/h2-grpc
H2 grpc
2019-08-26 15:55:31 +01:00
huanghaoyan
35e7b9551f ignore Loopback Address (LVS,DR mode) 2019-08-26 21:48:40 +08:00
Asim Aslam
6daf4fda72 Full support for grpc server side 2019-08-26 12:33:59 +01:00
Asim Aslam
36623bfe50 Improve stream processing 2019-08-25 19:30:22 +01:00
Asim Aslam
6128d18ee0 checkpoint fixing data race to process h2 and grpc requests 2019-08-24 20:12:04 +01:00
Asim Aslam
abadb2211e Merge pull request #698 from micro/tunnel-broker
Add a tunnel broker
2019-08-24 14:37:20 +01:00
Asim Aslam
ca267f73de add a tunnel broker 2019-08-24 09:46:55 +01:00
Asim Aslam
d8608b2343 Merge pull request #697 from micro/static-resolver
Add a static network node resolver
2019-08-23 22:05:02 +01:00
Milos Gajdos
ed8d28c9ab Set Route.Link to "network" not Route.Network. Oops! 2019-08-23 21:08:18 +01:00
Milos Gajdos
88e47b9b06 Dont bail when unable to resolve network nodes. 2019-08-23 17:48:14 +01:00
Asim Aslam
1b0295de0d Add a static network node resolver 2019-08-23 17:24:21 +01:00
Milos Gajdos
9448d7c164 Set Route.Network to "network" and Router.Gateway to network.Address 2019-08-23 16:01:57 +01:00
Milos Gajdos
8c3eec9f2a Set the default resolver to registry 2019-08-23 15:14:16 +01:00
Milos Gajdos
e53484302c Added ControlChannel tunnel.Listener to process incoming messages 2019-08-23 15:14:16 +01:00
Milos Gajdos
db89fc4efe Set server name to the correct value. 2019-08-23 15:14:16 +01:00
Milos Gajdos
e1599b0f17 Set server name. Set default network name. 2019-08-23 15:14:16 +01:00
Milos Gajdos
a09d5d2e9a Add Address method. Start and Stop router/server. 2019-08-23 15:14:16 +01:00
Milos Gajdos
6c1f1d66f7 Switch received messages on the right header 2019-08-23 15:14:16 +01:00
Milos Gajdos
a6e1287b27 Replaced incorrect proto import path 2019-08-23 15:14:15 +01:00
Milos Gajdos
fcec6e8eae First attempt to implement default network interface 2019-08-23 15:14:15 +01:00
Milos Gajdos
30dd3f54f0 Make router.Table docs consistent 2019-08-23 15:14:15 +01:00
Milos Gajdos
6beae23afd First commit. Outline of the default network. 2019-08-23 15:14:15 +01:00
Asim Aslam
718780367e Merge pull request #696 from milosgajdos83/server-idempotent
Make server Start() and Stop() idempotent
2019-08-23 15:12:33 +01:00
Milos Gajdos
ba99f037fb Lock started flag when changing it. 2019-08-23 15:07:08 +01:00
Milos Gajdos
80dc0b97a9 Make server starts and stops idempotent 2019-08-23 15:00:57 +01:00
Asim Aslam
1a32e3a11d Merge pull request #695 from micro/proxy-link
Support multiple clients in the proxy as Links
2019-08-23 14:48:49 +01:00
Asim Aslam
955dc2a23d change where we order the routes 2019-08-23 14:11:53 +01:00
Asim Aslam
934b8eb86d Error as link not found 2019-08-23 14:09:57 +01:00
Asim Aslam
b7f510ff64 support links in the proxy 2019-08-23 14:05:11 +01:00
Asim Aslam
353eade6c3 Update client proto 2019-08-23 12:06:11 +01:00
Asim Aslam
a133e61c2d Merge pull request #694 from milosgajdos83/tunnel-loopback-sleep
Lock when setting loopback flag and receiving keepalives
2019-08-22 17:35:03 +01:00
Milos Gajdos
99d39e743b Lock when setting loopback flag and receiving keepalives 2019-08-22 16:31:37 +01:00
Asim Aslam
0cdac2aa36 Merge pull request #689 from milosgajdos83/router-stop
Make router.Stop idempotent
2019-08-21 21:25:48 +01:00
Milos Gajdos
75871287a1 Make stop idempotent. Small refactoring. Router name is memory. 2019-08-21 21:10:42 +01:00
Asim Aslam
fb750a0bb1 Don't start the router if its already running 2019-08-21 18:58:56 +01:00
Asim Aslam
c6e15ef2d1 rename server, set version to timestamp 2019-08-21 15:43:46 +01:00
Asim Aslam
f787cc0ee0 Merge pull request #687 from micro/tunnel
Add tunnel address
2019-08-21 13:01:28 +01:00
Asim Aslam
c2d85a6e1f Add tunnel address 2019-08-21 12:55:10 +01:00
Milos Gajdos
86f0c06fac Removed filewatch counter test. 2019-08-21 11:26:41 +01:00
Asim Aslam
0aea8e3163 Merge pull request #686 from milosgajdos83/config-watcher
Introduce ErrStoppedWatcher for source.Source Watchers and fixed test
2019-08-21 11:06:14 +01:00
Milos Gajdos
4ea27517b5 Source watcher ErrStoppedWatcher and fixed test 2019-08-20 22:32:47 +01:00
Asim Aslam
f8e68ae101 Add string method to tunnel 2019-08-20 17:21:35 +01:00
Asim Aslam
f848041c49 Add a message type to the tunnel 2019-08-20 17:20:21 +01:00
Asim Aslam
dfbd730b8c Fix mucp service option passing 2019-08-20 16:48:09 +01:00
Asim Aslam
ac2a5a04a2 Merge pull request #681 from unistack-org/fix_wg
fix panic: negative WaitGroup counter
2019-08-19 12:06:45 +01:00
f1d08f251f fix panic: negative WaitGroup counter
avoid double wait group Done()

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-08-19 13:58:57 +03:00
Asim Aslam
718ae42808 Merge pull request #680 from printfcoder/master
fix file watcher event bug on Linux
2019-08-19 08:34:21 +01:00
Shu Xian
2413cbcd80 fix file watcher event bug on Linux
the watcher can not normally get events of file changes on linux. it just can get the first two changes.
2019-08-19 15:28:24 +08:00
Asim Aslam
9c820445a4 Merge pull request #679 from micro/grpc-codec
Force grpc client/server to use grpc codec for broker
2019-08-18 11:37:38 +01:00
Asim Aslam
c44fd63301 Force grpc client/server to use grpc codec for broker 2019-08-18 11:28:21 +01:00
Asim Aslam
d9a699ae6f Merge pull request #673 from micro/multiplex
Stream Multiplexing
2019-08-16 17:41:45 +01:00
Asim Aslam
4495ca3839 Use client.Call for non streaming requests 2019-08-16 17:24:17 +01:00
Asim Aslam
0b0eee41d0 functioning proxy code 2019-08-16 16:46:29 +01:00
Asim Aslam
e18f8defde Merge pull request #672 from milosgajdos83/tunnel-ping
Monitor outbound links and delete them when disconnected
2019-08-16 16:09:14 +01:00
Milos Gajdos
7abdc68049 Fixed the race. Made wait channel boolean. 2019-08-16 15:40:35 +01:00
Milos Gajdos
c90e1ccb99 Fixed reconnect code; refactor tunnel tests. 2019-08-16 15:18:34 +01:00
Asim Aslam
991142cd57 No need to set request in the buffer 2019-08-16 14:42:45 +01:00
Asim Aslam
5a5b1b8f6e only continue to stream when its a stream 2019-08-15 20:54:28 +01:00
Asim Aslam
58bc4c103f go fmt 2019-08-15 20:54:09 +01:00
Asim Aslam
88817dc53f Strip some dead code 2019-08-15 20:54:00 +01:00
Asim Aslam
ef04331b86 multiplexing cruft 2019-08-15 20:08:49 +01:00
Milos Gajdos
67215ae5da Changed nodeLink to setupLink 2019-08-15 19:24:24 +01:00
Milos Gajdos
f120452d28 Monitor outbound links periodically and reconnect the failed links. 2019-08-15 18:18:58 +01:00
Milos Gajdos
740cfab8d0 Monitor outbound links and delete them when disconnected 2019-08-15 16:52:16 +01:00
Asim Aslam
f6b8045dd5 send client error if it exists 2019-08-15 15:22:53 +01:00
Asim Aslam
b776fbb766 add a pseudo socket implementation 2019-08-15 15:09:56 +01:00
Asim Aslam
a42de29f67 Do same for host port on deregister 2019-08-15 08:59:50 +01:00
Asim Aslam
0f6d09af33 go fmt 2019-08-15 08:47:32 +01:00
Asim Aslam
2dd5109eee Merge pull request #669 from printfcoder/master
fix registry addr error for mq-rpc
2019-08-15 07:36:06 +01:00
Shu xian
e609095ba4 Merge pull request #2 from micro/master
merge
2019-08-15 08:38:08 +08:00
Asim Aslam
4843f09afa Merge pull request #670 from milosgajdos83/loopback-msg-fix
Fixing the tunnel loopback messaging
2019-08-14 17:28:15 +01:00
Milos Gajdos
f9eddf1e6f Fixing the tunnel loopback messaging 2019-08-14 17:14:39 +01:00
Shu xian
f19308f1e6 Merge pull request #1 from micro/master
merge
2019-08-14 22:02:41 +08:00
Asim Aslam
8f0c2e0412 add a better tunnel test 2019-08-14 14:38:17 +01:00
Shu Xian
bf0e46dc0d fix registry addr error for mq-rpc 2019-08-14 21:32:28 +08:00
Asim Aslam
15975d2903 Merge pull request #668 from milosgajdos83/tun-token-loopback
[WIP] Tunnel loopback connections
2019-08-14 14:32:18 +01:00
Milos Gajdos
9f2f0e3cea Moved Close method to the bottom 2019-08-14 13:26:23 +01:00
Milos Gajdos
151bcf0ea1 Send and receive on loopback tunnel interface 2019-08-14 13:00:10 +01:00
Asim Aslam
dc0fbfc3c0 Merge pull request #666 from unistack-org/log
export log levels and reverse log level order
2019-08-14 07:41:01 +01:00
Milos Gajdos
e607485c6b Check for token in every received message. 2019-08-14 01:23:03 +01:00
70d0029658 add warn log level
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-08-14 02:26:51 +03:00
a606813fdf export log levels and reverse log level order
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-08-14 02:18:22 +03:00
Milos Gajdos
750267b308 first commit to draft up a way for Sending messages to loopback 2019-08-13 20:11:23 +01:00
Asim Aslam
7ce0305db4 only operate on clients that are the same as the server 2019-08-13 16:08:56 +01:00
Asim Aslam
c39591af0e add a mux package for the proxy 2019-08-13 15:21:51 +01:00
Asim Aslam
fedc6be3e6 Merge pull request #663 from milosgajdos83/router-start
Add Start method to router
2019-08-13 08:12:56 +01:00
Milos Gajdos
cb1679fd8d Add Start method to router
Added Start to router packages.
Fixed potential deadlocks.
2019-08-12 22:23:46 +01:00
Asim Aslam
c0a676bfa9 Only check the router status if the lookup fails 2019-08-12 17:06:08 +01:00
Asim Aslam
cb4e376c64 Update go mod 2019-08-12 12:35:09 +01:00
Asim Aslam
c2c8182a5b delete tunnel headers and add some TODOs 2019-08-11 21:53:40 +01:00
Asim Aslam
01cb146e0d send message once after creating socket 2019-08-11 18:24:16 +01:00
Asim Aslam
d0d729a789 fix the tunnel execution 2019-08-11 18:11:33 +01:00
Asim Aslam
113d87d855 Merge branch 'master' of ssh://github.com/micro/go-micro 2019-08-11 16:15:30 +01:00
Asim Aslam
56df10f68b use keepalive in quic by default 2019-08-11 16:12:31 +01:00
Asim Aslam
3a5428fb36 Merge pull request #660 from xpunch/serviceNotFoundIssue
Service not found issue
2019-08-11 12:44:27 +01:00
johnson
178a3b3d8e Merge remote-tracking branch 'origin/master' into serviceNotFoundIssue
# Conflicts:
#	client/grpc/grpc.go
2019-08-11 19:34:00 +08:00
johnson
de34f259ba update service not found error tooltip
fixing test failed issue

change back error type
change registry.ErrNotFound back to selector.ErrNotFound

change back error type
change registry.ErrNotFound back to selector.ErrNotFound

remove the single node tunnel test

Fix read yaml config from memory

package main

import (
	"fmt"

	"github.com/micro/go-micro/config"
	"github.com/micro/go-micro/config/source/memory"
)

var configData = []byte(`
---
a: 1234
`)

func main() {
	memorySource := memory.NewSource(
		memory.WithYAML(configData),
	)
	// Create new config
	conf := config.NewConfig()

	// Load file source
	conf.Load(memorySource)

	fmt.Println(string(conf.Bytes()))
}
2019-08-11 19:31:22 +08:00
potato
81b68a1d7f Merge pull request #4 from micro/master
update fork
2019-08-11 19:05:49 +08:00
Asim Aslam
1a600810a7 Merge pull request #661 from XiaoLer/patch-2
Fix read yaml config from memory
2019-08-11 12:03:18 +01:00
potato
94127ae1aa Merge pull request #3 from micro/master
update fork
2019-08-11 18:24:57 +08:00
刘小乐
cd2ac648ff Fix read yaml config from memory
package main

import (
	"fmt"

	"github.com/micro/go-micro/config"
	"github.com/micro/go-micro/config/source/memory"
)

var configData = []byte(`
---
a: 1234
`)

func main() {
	memorySource := memory.NewSource(
		memory.WithYAML(configData),
	)
	// Create new config
	conf := config.NewConfig()

	// Load file source
	conf.Load(memorySource)

	fmt.Println(string(conf.Bytes()))
}
2019-08-11 18:05:35 +08:00
Asim Aslam
e613b0c205 remove the single node tunnel test 2019-08-11 09:54:02 +01:00
potato
57dacf1831 Merge pull request #2 from micro/master
update fork
2019-08-11 10:22:33 +08:00
Asim Aslam
8986b3135f Strip logging 2019-08-10 18:46:54 +01:00
Asim Aslam
6dd3ea1853 Remove listen check 2019-08-10 18:44:50 +01:00
Asim Aslam
2c66e94045 fix some tunnel bugs like races and duplicate messages... 2019-08-10 16:37:49 +01:00
Asim Aslam
c1ff3ceee4 Add more verbose not found error 2019-08-09 12:31:29 +01:00
potato
b13604fb4b Merge pull request #1 from micro/master
Update forks to latest
2019-08-09 18:46:28 +08:00
Asim Aslam
057adb2b2e Merge pull request #658 from XiaoLer/patch-1
no more `WithData` method, instead of  `WithJSON`
2019-08-09 11:37:35 +01:00
刘小乐
7bd6d1b549 no more WithData method, instead of WithJSON 2019-08-09 12:45:59 +08:00
Asim Aslam
37988b596d Merge pull request #656 from milosgajdos83/tun-listener
Close the tunnel listener when the tunnel is cloed.
2019-08-08 15:25:19 +01:00
Milos Gajdos
9eb45dac82 Close the tunnel listener when the tunnel is cloed. 2019-08-08 15:20:53 +01:00
Asim Aslam
59b13aef22 tunnel skip zero length nodes 2019-08-08 13:15:30 +01:00
Asim Aslam
1e496938b7 more tunnel logging 2019-08-08 13:07:13 +01:00
Asim Aslam
fbc1d523d7 add ability to set log level via env var 2019-08-08 13:07:04 +01:00
Asim Aslam
11795071fb Fix panic 2019-08-08 12:45:37 +01:00
Asim Aslam
c7e8a2aeb9 Merge pull request #651 from magodo/master
wait nats drain since it's asynchronous
2019-08-08 00:30:01 +01:00
Asim Aslam
cb1c1afc84 add quic to defaults 2019-08-08 00:19:30 +01:00
Asim Aslam
3fc7d9ea50 Quic requires an initial message to start the session so we need connect 2019-08-08 00:19:16 +01:00
Asim Aslam
abc2ace409 Merge pull request #653 from micro/tunnel
Add back the old tunnel interface
2019-08-07 22:36:15 +01:00
Asim Aslam
243d43df92 Strip master from travis 2019-08-07 22:32:16 +01:00
Asim Aslam
9c2b882008 Bump travis go 2019-08-07 22:27:03 +01:00
Asim Aslam
4370f03e04 update go modules 2019-08-07 22:11:52 +01:00
Asim Aslam
a3b962f37b Fix travis test? 2019-08-07 22:02:58 +01:00
Asim Aslam
a894b4f354 add tunnel/transport package 2019-08-07 21:58:25 +01:00
Asim Aslam
fc379f2d2c Remove other accept 2019-08-07 19:03:45 +01:00
Asim Aslam
dcf4fed6a3 Add a second test for two tunnels 2019-08-07 18:56:21 +01:00
Asim Aslam
117376a922 Add back the old tunnel interface 2019-08-07 18:44:33 +01:00
Asim Aslam
380d9790e6 add io.ReadWriteCloser ontop of transport.Socket 2019-08-07 15:02:00 +01:00
magodo
0baea58938 wait nats drain since it's asynchronous
1. nats subscription draining is removed, since it is asynchronous,
   and there is no reliable way to detect when it is finished.
   Remove this option to avoid confusion.
2. nats connection draining is kept, and use 2 callbacks to detect
   draining timeout (timeout is set via `nats.Options`) or finish.
3. Also honour options passed in `broker.Init()` (previously only
   `broker.New()` is honoured).
2019-08-07 17:58:45 +08:00
Asim Aslam
edb0fe4b16 fix the consul setup code 2019-08-06 19:43:46 +01:00
Asim Aslam
eae32176c4 Monitor all services in the monitor 2019-08-06 19:02:57 +01:00
Asim Aslam
bc751c55fb Merge pull request #650 from micro/monitor
Add monitor/debug/service packages
2019-08-06 18:09:57 +01:00
Asim Aslam
91f2af91de Fix bugs in monitor 2019-08-06 18:05:05 +01:00
Asim Aslam
3adce58eb2 Add monitor/debug packages 2019-08-06 17:53:14 +01:00
Asim Aslam
bb01b3ed78 Don't extract repeated value 2019-08-06 14:52:15 +01:00
Asim Aslam
c3ea25225c Don't check value name on extraction 2019-08-06 14:49:42 +01:00
Asim Aslam
beffa625f8 fix broker log line 2019-08-06 12:25:51 +01:00
Asim Aslam
0d85e35da0 Merge pull request #649 from milosgajdos83/tun-types
Rough outline of tunnel types
2019-08-06 11:54:54 +01:00
Milos Gajdos
4074cce397 Rough outline of tunnel types 2019-08-06 11:46:47 +01:00
Asim Aslam
000431f489 Nats addr fix https://github.com/micro/go-micro/pull/648 2019-08-06 09:15:54 +01:00
Asim Aslam
e16420fdbd Consul config fix https://github.com/micro/go-micro/pull/641 2019-08-06 09:15:38 +01:00
Milos Gajdos
52d8d26018 Transport() will return tunnel (pseudo) Transport 2019-08-05 21:09:46 +01:00
Asim Aslam
6649012af3 Merge pull request #645 from milosgajdos83/transport-out
Tunnel no longer embeds transport
2019-08-05 19:57:22 +01:00
Milos Gajdos
6b5dcbf814 Tunnel no longer embeds transport 2019-08-05 19:41:48 +01:00
Asim Aslam
34381213e7 Package comment 2019-08-05 18:04:47 +01:00
Asim Aslam
767292906a Merge pull request #644 from milosgajdos83/tunnel
Adds outline of go-micro Tunnel interface
2019-08-05 17:54:40 +01:00
Milos Gajdos
e1ecd728c5 Adds outline of go-micro Tunnel interface 2019-08-05 17:52:57 +01:00
Asim Aslam
f1b6709722 Fix breaking api changes 2019-08-05 17:47:50 +01:00
Asim Aslam
4030ccc27b Move proxy/router 2019-08-05 17:44:33 +01:00
Asim Aslam
2e67e23a23 Update .travis.yml 2019-08-03 15:16:30 +01:00
Asim Aslam
be229438bc Merge pull request #640 from unistack-org/deadline
transport memory: add Send/Recv Timeout
2019-08-03 13:51:01 +01:00
e1709026e4 transport memory: add Send/Recv Timeout
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-08-03 15:39:44 +03:00
Asim Aslam
d250ac736f In the event watchRegistry or watchTable exit then close the go routines 2019-08-02 15:17:48 +01:00
Asim Aslam
6719f8d655 Remove the table watcher when stopped 2019-08-02 14:59:08 +01:00
Asim Aslam
d7929ef8f3 Stop the ticker when exiting 2019-08-02 14:44:11 +01:00
Asim Aslam
04404441a4 Merge pull request #634 from micro/rcache-stop
Stop a goroutine leak in registy
2019-08-01 23:17:39 +01:00
Asim Aslam
b806e7bdf5 Stop a goroutine leak in registy 2019-08-01 23:03:11 +01:00
Milos Gajdos
2720c6f28e Removed trailing white characters 2019-08-01 13:32:55 +01:00
Asim Aslam
cdf0f14d58 remove this code 2019-07-31 17:19:49 +01:00
Asim Aslam
679c5f0ccd Fix some connection bugs 2019-07-31 16:49:48 +01:00
Asim Aslam
873bfcc73c Process/Stop router 2019-07-31 16:46:55 +01:00
Asim Aslam
7884e889f4 Don't publish the process rpc call and embed the router handler in the network 2019-07-31 16:36:53 +01:00
Asim Aslam
b1c49a0ddc Add router handler 2019-07-31 16:10:04 +01:00
Asim Aslam
318367cd71 move NewNetwork 2019-07-31 15:37:12 +01:00
Asim Aslam
2d09e74b0e add address/advertise 2019-07-31 15:35:51 +01:00
Asim Aslam
3e90d32f29 Add proxy/router 2019-07-31 15:30:51 +01:00
Asim Aslam
fca89e06ef Some network inspiration 2019-07-31 15:22:57 +01:00
Asim Aslam
89fc142e47 Update to use mdns 0.2.0 2019-07-31 13:16:57 +01:00
Asim Aslam
0b2c8ee523 Add top level data package comment 2019-07-30 16:47:18 +01:00
Asim Aslam
852abcaaed yolo commit functioning router code. all credit to the milos gajdos 2019-07-29 18:57:40 +01:00
Asim Aslam
11f80708ce move lock 2019-07-29 12:52:52 +01:00
Asim Aslam
104778e5e5 move lock 2019-07-29 12:52:32 +01:00
Asim Aslam
ae99b9a887 syntactic changes 2019-07-29 12:44:59 +01:00
Asim Aslam
8fdc050e2e syntactic changes 2019-07-29 12:44:28 +01:00
Asim Aslam
8855beb62d syntactic changes 2019-07-29 12:43:20 +01:00
Asim Aslam
47acdf6a4b move Table to table 2019-07-29 12:40:13 +01:00
Asim Aslam
4fc9b9821a Merge pull request #621 from milosgajdos83/no-table-package
[WIP] No table package. router/service package introduced
2019-07-29 12:36:40 +01:00
Asim Aslam
a5fb124b22 update the mdns version 2019-07-29 12:34:00 +01:00
Asim Aslam
5b327ce723 change id to name in resolver 2019-07-28 20:00:09 +01:00
Asim Aslam
2b5bf1154a rename config tests 2019-07-28 19:52:01 +01:00
Asim Aslam
b7b8f8bf11 remove agent readme 2019-07-28 19:47:25 +01:00
Asim Aslam
a63dcda003 Strip the verbosity of the debug handler 2019-07-28 19:43:50 +01:00
Asim Aslam
1db98ee0f0 move all the buffer references to util/buf 2019-07-28 19:33:24 +01:00
Asim Aslam
f2669e7b1e Move connection pool to own package 2019-07-28 18:56:18 +01:00
Asim Aslam
adb6760e21 readd the resolver 2019-07-28 12:14:40 +01:00
Asim Aslam
2b3a87a212 Merge pull request #617 from three-zhang/master
fix bug
2019-07-27 18:08:32 +01:00
Milos Gajdos
3d2ec5dbb1 Regenerated proto because proto reasons. 2019-07-27 16:12:44 +01:00
Milos Gajdos
96f9ce1bd3 Proper router stopping. Printable router status. 2019-07-27 16:11:06 +01:00
Milos Gajdos
cb3052ce04 Proper stopping of service router 2019-07-27 16:11:06 +01:00
Milos Gajdos
2f1658c213 Table package is no more, hence removed references to it 2019-07-27 16:11:06 +01:00
Milos Gajdos
d8b00e801d Stop watcher when router stops. Drain advert channel when stopping. 2019-07-27 16:11:06 +01:00
Milos Gajdos
002abca61f Finished Advertise(). Implemented Process() 2019-07-27 16:11:06 +01:00
Milos Gajdos
c5740ae031 Outline of Advertise, Watch and start of the router. 2019-07-27 16:11:05 +01:00
Milos Gajdos
ddad43bd77 Added service.Router Route CRUD. Outlined watcher and run() 2019-07-27 16:11:05 +01:00
Milos Gajdos
b6fb969ab9 Add List and Lookup implementation. Default error for not implement. 2019-07-27 16:11:05 +01:00
Milos Gajdos
22d0f1f08f Changed documentation. 2019-07-27 16:08:14 +01:00
Milos Gajdos
c3a8146d99 Added outline of router/service package. 2019-07-27 16:08:14 +01:00
Milos Gajdos
2338780a61 Full router RPC coverage 2019-07-27 16:08:14 +01:00
Milos Gajdos
e22c4b4c07 table package is no more. Cleaned up unnecessary code, too. 2019-07-27 16:04:08 +01:00
张三
100cb9db6b fix bug
https://github.com/micro/micro/issues/293
Send request failed using micro Content-Type application/grpc+json
2019-07-27 11:11:16 +08:00
Asim Aslam
4e27aac398 regen router proto 2019-07-26 18:07:36 -07:00
Asim Aslam
7ca06f0c1d set router proto package name to go.micro.router 2019-07-26 18:07:14 -07:00
Asim Aslam
7ca8f8f0ab Merge pull request #611 from milosgajdos83/rpc-router
Adds new RPC methods to router service interface
2019-07-24 13:30:29 -07:00
Milos Gajdos
9ad5ae6644 Adds new RPC methods to router service interface
We have added Advertise() and Process() RPCs in this commit.
2019-07-24 21:07:04 +01:00
Asim Aslam
220a8fafb1 Merge pull request #610 from milosgajdos83/proxy-watch
Adds route watcher to mucp.Proxy
2019-07-24 11:19:52 -07:00
Milos Gajdos
809de7a052 Mutex Unlock when we fail to store route in cache. 2019-07-24 19:13:05 +01:00
Milos Gajdos
23f0231a09 Adds route watcher to mucp.Proxy 2019-07-24 19:03:13 +01:00
Asim Aslam
74cbce72df Merge pull request #609 from milosgajdos83/proxy-router-interface
mucp Proxy no longer uses RPC interface of router.Router directly
2019-07-24 10:40:33 -07:00
Milos Gajdos
b55adc0c30 mucp Proxy no longer uses RPC interface of router.Router directly 2019-07-24 18:32:39 +01:00
Asim Aslam
388ac34b7c Merge pull request #608 from milosgajdos83/router-cleanup
Small router refactoring
2019-07-24 09:46:48 -07:00
Milos Gajdos
13a8cfe7f3 Small function documentation update 2019-07-24 17:22:27 +01:00
Milos Gajdos
1e94d9fe5a Router cleanup and refactoring for win and profit.
This commit adds the following changes to router package:
* it refactors Advertise() function which now does only what
it claims to do: advertising
* various router packages functions/methods have been renamed to make
their functionality more obvious and more in line with what they actually do
* function documentation changes related to the above bullet points
2019-07-24 17:16:52 +01:00
Asim Aslam
49dcc3d1bd Remove readme and examples from web repo 2019-07-22 09:57:34 -07:00
Milos Gajdos
481ebe9d4f Merge pull request #604 from BruceWangNo1/patch-1
Update client.go
2019-07-22 10:55:55 +01:00
Bruce Wang
502f6d3e9f Update client.go
fixed one typo
2019-07-22 15:41:14 +08:00
Asim Aslam
8f2585724c Merge pull request #598 from unistack-org/ipv6fix
bunch of other ipv6 fixes
2019-07-18 07:24:47 -07:00
1217ca94b1 bunch of other ipv6 fixes
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-07-18 08:59:53 +03:00
Asim Aslam
96cf14ed53 Merge pull request #591 from milosgajdos83/advert-damp
[WIP] Fixes advert route event dampening behaviour
2019-07-17 08:12:35 -07:00
Asim Aslam
3a8edd705c Merge pull request #594 from unistack-org/ipv6
fix ipv6 addr parsing
2019-07-17 07:51:17 -07:00
Milos Gajdos
94b6455577 Increment WaitGroup before launching advertiseEvents goroutine 2019-07-17 13:02:47 +01:00
e688ab0a45 fix ipv6 addr parsing and using
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-07-17 12:20:29 +03:00
Milos Gajdos
2803146673 Renaming rampage
Addressing the comments in #591, router.String() now returns "default"

Furthermore, a tonne of other renaming has been included in this commit
as a result of running go vet ./... inside the router package.
2019-07-17 00:06:11 +01:00
Asim Aslam
d4fefc4b76 Merge pull request #592 from unistack-org/speedup
changes to minimize allocations and provide useful info
2019-07-16 14:41:11 -07:00
a3bddf5839 changes to minimize allocations and provide useful info
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-07-17 00:21:03 +03:00
Milos Gajdos
92495d22db Fixes advert dampening behaviour.
This commit adds the following changes:
* advert now stores a list of route events as opposed to just last one
* attempt to dedup route events before appending them to advert
* have max suppress threshold for long time suppressed adverts
* decaying events on every advert tick

Originally we werent decaying penalties on every advert tick.
That was incorrect behaviour. Furthermore some events would end up being
accumulated potentially causing memory leaks.

We were also overriding the last received router event which was causing
incorrect sequence of events to be applied when received by a receiver:
Create, Delete would be "squashed" into Delete only which would be
nonsensical since the Create event would never be delivered hence we
would be deleting nonexistent routes.

Not Decaying the events on every tick or not having the max suppression
threshold could lead to DoS by growing the router memory infinitely.
2019-07-16 19:00:25 +01:00
Asim Aslam
8c7e35c3c6 Merge pull request #587 from milosgajdos83/registry-copy-perf
Preallocate slices in registry.Copy() to avoid append() reallocations when copying data
2019-07-15 07:04:49 -07:00
Milos Gajdos
c108188d65 Preallocate nodes slice in addNodes before populating it 2019-07-15 14:47:33 +01:00
Milos Gajdos
609934ce99 Preallocate slices; avoide append() reallocations when copying data 2019-07-15 11:13:58 +01:00
Asim Aslam
aa79c41fc5 update tunnel comment 2019-07-14 18:34:32 -07:00
Asim Aslam
a549f92dec Merge pull request #585 from unistack-org/transport2
transport memory: fix races
2019-07-13 19:38:22 -07:00
81d2259fac transport memory: fix races
* fix race with rand.Intn for non default source
* increase random interval to avoid issues when many services
  running on the host

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-07-13 23:47:57 +03:00
Asim Aslam
2fecde1dbb Merge pull request #583 from unistack-org/broker
broker memory: fix issue with publish/subscribe
2019-07-13 00:16:28 +01:00
008749b2b0 broker memory: fix issue with publish/subscribe
mutex locking have errors, so when two service (one pub, other sub)
try to use this broker it waits for mutex release and nothing works

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-07-13 00:04:53 +03:00
Asim Aslam
3ccb900bca Merge pull request #582 from unistack-org/memory2
memory transport: use write mutex lock when close
2019-07-12 10:29:46 +01:00
a72e1185da memory transport: use write mutex lock when close
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-07-12 12:11:08 +03:00
Asim Aslam
5157241c88 Merge branch 'master' of ssh://github.com/micro/go-micro 2019-07-11 21:46:33 +01:00
Asim Aslam
70d811c47a don't use quic in the test 2019-07-11 21:46:27 +01:00
Asim Aslam
b371704444 Merge pull request #581 from milosgajdos83/proto-update
Added proto.Advert, proto.TableEvent is now proto.Event
2019-07-11 21:44:10 +01:00
Asim Aslam
a5f21e69ad Merge branch 'master' of ssh://github.com/micro/go-micro 2019-07-11 21:41:00 +01:00
Asim Aslam
6b984136f7 update go mod 2019-07-11 21:40:52 +01:00
Milos Gajdos
9c851f297b Added proto.Advert type to protobuf definitions 2019-07-11 21:14:34 +01:00
Asim Aslam
dac8a13a77 Merge pull request #580 from milosgajdos83/advertise-table
Advertise full table every minute.
2019-07-11 12:49:02 +01:00
Asim Aslam
360e193a01 update go mod 2019-07-11 12:47:50 +01:00
Milos Gajdos
35a1de91a9 Advertise full table every minute. 2019-07-11 12:39:20 +01:00
Asim Aslam
7631463b94 fix compilation errors 2019-07-11 10:47:02 +01:00
Asim Aslam
6581586226 Make tunnel test use quic 2019-07-11 10:34:01 +01:00
Asim Aslam
06c29302d7 Merge branch 'master' of ssh://github.com/micro/go-micro 2019-07-11 09:38:27 +01:00
Asim Aslam
dab0e9e9bc Set next protos in quic 2019-07-11 09:38:20 +01:00
Asim Aslam
47d91a1f64 Merge pull request #579 from magodo/magodo/store_get_reset_expiry
`memoryStore.Read()` returns honor `Record.Expiry`
2019-07-11 08:39:46 +01:00
magodo
bdeae91063 condense code 2019-07-11 14:13:58 +08:00
magodo
c8d57032bc update expiry only if it is non-zero 2019-07-11 12:58:20 +08:00
magodo
3abe3aa28b store.Read() returns honor Record.Expiry 2019-07-11 12:51:55 +08:00
Asim Aslam
9b1cb4ef0e functioning tunnel with test 2019-07-11 00:55:50 +01:00
Asim Aslam
b4796724d9 Merge branch 'master' of ssh://github.com/micro/go-micro 2019-07-11 00:14:43 +01:00
Asim Aslam
ae5376cc0e functioning tunnel/link code 2019-07-11 00:14:36 +01:00
Asim Aslam
7bee0629c2 Merge pull request #578 from unistack-org/memory
memory transport: fix race cond on channel close
2019-07-10 23:30:46 +01:00
29fa8de98e memory transport: fix race cond on channel close
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-07-11 01:21:03 +03:00
Asim Aslam
382fbecd40 Merge pull request #577 from milosgajdos83/update-events
Added update action to handle update registry events. Table.Update inserts when no route found.
2019-07-10 21:54:48 +01:00
Milos Gajdos
a0ee7d2092 Added update action to manageServiceRoutes. Table is embedded; skip opts 2019-07-10 21:28:32 +01:00
Asim Aslam
1f744b31a4 Return the dead node when deleting the service 2019-07-10 21:03:53 +01:00
Asim Aslam
998a23c963 Functional code for link 2019-07-10 20:04:01 +01:00
Asim Aslam
e17ecf66b1 Fix breaking code 2019-07-10 20:03:55 +01:00
Asim Aslam
c5dd737568 Add back in broker address 2019-07-10 19:58:30 +01:00
Asim Aslam
7c29be288b Update a tunnel top level comment 2019-07-10 19:33:34 +01:00
Asim Aslam
217f540601 The listener has no session id 2019-07-10 19:17:36 +01:00
Asim Aslam
ffae0f0fab Add a comment for tunnel processor 2019-07-10 19:13:50 +01:00
Asim Aslam
4cca2b43a3 Add further link comments 2019-07-10 19:11:32 +01:00
Asim Aslam
8c157c1d5f update link comments 2019-07-10 19:09:22 +01:00
Asim Aslam
1f218f7b48 Allow the socket to be specified 2019-07-10 19:07:18 +01:00
Asim Aslam
7e0d4fe0cf Merge branch 'master' of ssh://github.com/micro/go-micro 2019-07-10 19:01:38 +01:00
Asim Aslam
0a39fe39c3 Update tunnel to use id+session for the key 2019-07-10 19:01:24 +01:00
Milos Gajdos
163b917ec7 proto.EventType Insert is now Create to mirror table.Event 2019-07-10 18:37:46 +01:00
Asim Aslam
0f16eb2858 add further comments to tunnel 2019-07-10 18:35:10 +01:00
Asim Aslam
89231f701b Add comments and session 2019-07-10 18:26:11 +01:00
Asim Aslam
196e76e350 Merge branch 'master' of ssh://github.com/micro/go-micro 2019-07-10 18:24:12 +01:00
Asim Aslam
f3d9177233 Add sessions to tunnel 2019-07-10 18:24:03 +01:00
Asim Aslam
8b7ac8a3f9 Merge pull request #576 from milosgajdos83/router-rpc
Added List and Watch rpc calls.
2019-07-10 17:55:23 +01:00
Milos Gajdos
8f5aed707e Table.Add is now Table.Create. Insesrt event is now Create event. 2019-07-10 17:46:22 +01:00
Asim Aslam
c71576a538 Update link Id comment 2019-07-10 17:43:36 +01:00
Asim Aslam
27cfc06828 Cleanup and move around the link code 2019-07-10 17:42:41 +01:00
Asim Aslam
717ba4b3c0 Add tunnel comments 2019-07-10 17:41:17 +01:00
Asim Aslam
4e3a230356 top level package comment 2019-07-10 17:40:14 +01:00
Asim Aslam
66c2519696 Add Tunnel: an interface for stream duplexing over a link 2019-07-10 17:36:04 +01:00
Milos Gajdos
86dfa82dfa Added List and Watch rpc calls. 2019-07-10 17:21:55 +01:00
Asim Aslam
55f8045a70 Add link: a layer ontop of a transport socket 2019-07-10 17:12:51 +01:00
Asim Aslam
b23d955536 Use gateway if available 2019-07-10 08:26:33 +01:00
Asim Aslam
5b565f9f10 update comment 2019-07-10 07:56:52 +01:00
Asim Aslam
9955ed2034 move table 2019-07-10 07:56:18 +01:00
Asim Aslam
c36107e811 cleanup consts 2019-07-10 07:51:24 +01:00
Asim Aslam
a08b64c8ab remove the string methods 2019-07-10 07:50:33 +01:00
Asim Aslam
64ec0633a3 Fix breaks and go fmt 2019-07-10 07:47:17 +01:00
Asim Aslam
0a1b657221 visual cleanup of router code 2019-07-10 07:45:27 +01:00
Asim Aslam
34967e8e33 Merge pull request #573 from milosgajdos83/flap-detection
Router rework. Flap detection. Table package.
2019-07-10 07:12:18 +01:00
Asim Aslam
eda380284c remove network 2019-07-09 18:45:14 +01:00
Asim Aslam
0bf54c122f move transport back 2019-07-09 18:41:26 +01:00
Asim Aslam
97282a5377 remove resolver 2019-07-09 16:54:44 +01:00
Asim Aslam
b642d5e1c0 remove proto dir 2019-07-09 16:53:30 +01:00
Asim Aslam
c5a282ddd3 remove the tunnel 2019-07-09 16:52:44 +01:00
Milos Gajdos
6cf8bde612 Router selector and proxy modifications due to Route struct changes. 2019-07-09 16:45:31 +01:00
Asim Aslam
327029beff fix string method 2019-07-09 16:44:43 +01:00
Asim Aslam
c5214c931f reorder and reword 2019-07-09 16:38:44 +01:00
Asim Aslam
d725980444 add some initialisers 2019-07-09 16:37:59 +01:00
Milos Gajdos
23cb811f60 Removed fmt.Stringer artistry from all roouter and table structs 2019-07-09 16:17:18 +01:00
Milos Gajdos
c5fb409760 Removed debug logs 2019-07-09 15:55:39 +01:00
Milos Gajdos
70665e5a7d Route has changed to accomodate Link, Service and Address 2019-07-09 15:46:32 +01:00
Milos Gajdos
449aa0a339 Collect ANNOUNCE mesage events before adding default gateway. 2019-07-09 15:46:31 +01:00
Milos Gajdos
265271008e Simplified processEvents loop; Added router Announcement. 2019-07-09 15:46:31 +01:00
Milos Gajdos
b82245429e Simplified table logic. Lookup tests. mucp/cient update 2019-07-09 15:46:31 +01:00
Milos Gajdos
cc590f5f2c Table now has a dedicated package inside router package. 2019-07-09 15:46:31 +01:00
Milos Gajdos
0c1a28a9b6 Router routing table management. Table route hashes. Status codes changed.
We now manage routing table actions using dedicated functions run on
either registry or services in the registry.

Routing table now uses Route.Hash() instead of maintaining its own hash
struct filed which previously performed these operations.

Various names of variables have been changed to make them more concise.
2019-07-09 15:46:31 +01:00
Milos Gajdos
30d05e34a9 Read and remove routes based on registry event deltas 2019-07-09 15:46:31 +01:00
Milos Gajdos
b68f0e237f Removed event from eventMap once sent to be advertised 2019-07-09 15:46:31 +01:00
Milos Gajdos
72ef032162 First shot at flapping detection and event advertising.
This commit also adds Route hash function, lots of debug messages for
now and String() methods for various API objects.
2019-07-09 15:46:30 +01:00
Milos Gajdos
d6c07dfb16 Update is now Advert 2019-07-09 15:46:30 +01:00
Milos Gajdos
ea872f6900 Updated error statements; Update ships list of events. 2019-07-09 15:46:30 +01:00
Asim Aslam
6bdc23a3aa add comments 2019-07-08 16:32:12 +01:00
Asim Aslam
fa54db5ba5 rename network name to go.micro 2019-07-08 16:27:02 +01:00
Asim Aslam
8015a1daaf Merge branch 'master' of ssh://github.com/micro/go-micro 2019-07-08 16:25:41 +01:00
Asim Aslam
608a1f8add remove node code 2019-07-08 16:25:04 +01:00
Asim Aslam
4a02e1ff2f rewrite network interface 2019-07-08 16:24:57 +01:00
Asim Aslam
5cd1e81ba9 Merge pull request #570 from sunfuze/grpc-json-marshal
grpc: using jsonpb.Marshaler to do Marshal, map to jsonpb.Unmarsh
2019-07-08 08:44:51 +01:00
Asim Aslam
d3edad474e Merge pull request #571 from micro/remove-port
Remove Port from registry
2019-07-08 08:18:26 +01:00
Asim Aslam
e0bf1c2283 Remove Port from registry 2019-07-08 08:01:42 +01:00
Joe
b655f7f55a grpc: using jsonpb.Marshaler to do Marshal, map to jsonpb.Unmarsh 2019-07-08 10:32:10 +08:00
Asim Aslam
5b7454e5a8 update transport package comments 2019-07-07 15:04:07 +01:00
Asim Aslam
0b732b2c49 update transport package comments 2019-07-07 15:03:08 +01:00
Asim Aslam
be33d9204a Merge pull request #569 from micro/event
Change Publication to Event
2019-07-07 12:45:37 +01:00
Asim Aslam
4b4ad68eb9 Change Publication to Event 2019-07-07 12:44:09 +01:00
Asim Aslam
79b03a6825 add broker args 2019-07-07 12:36:14 +01:00
Asim Aslam
777a203f96 gofmt 2019-07-07 12:33:54 +01:00
Asim Aslam
c1097a4509 strip broker address 2019-07-07 12:33:47 +01:00
Asim Aslam
5f664faeba Add transport options comments 2019-07-07 12:23:03 +01:00
Asim Aslam
d2d6841f02 Move transport to network/transport 2019-07-07 10:37:34 +01:00
Asim Aslam
eafc930f84 Change network id to name 2019-07-07 10:10:38 +01:00
Asim Aslam
d1fc3c361e Merge pull request #566 from unistack-org/speed
codec grpc: fix extra allocations on message unmarshal
2019-07-04 17:29:32 +01:00
e40307c567 codec grpc: fix extra allocations on message unmarshal
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-07-04 14:06:29 +03:00
Asim Aslam
a412486c39 Update registry util semantics 2019-07-04 11:36:49 +01:00
Asim Aslam
59a0e727e4 Merge pull request #563 from unistack-org/race
export registry util function to safe copy registry data
2019-07-04 11:16:54 +01:00
Asim Aslam
b35f227f7a Merge pull request #565 from sunfuze/grpc-json-unmarshal
grpc: if unmarshal target is proto.Message, using jsonpb
2019-07-04 11:16:11 +01:00
Asim Aslam
00ba1655ca remove some readmes 2019-07-04 11:15:54 +01:00
Joe
e88041dc26 if unmarshal target is proto.Message, using jsonpb 2019-07-04 16:43:36 +08:00
0e34c572b4 export registry util function to safe copy registry data
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-07-04 11:39:43 +03:00
Asim Aslam
2644497ccb Fix some link connection logic 2019-07-03 19:51:40 +01:00
Asim Aslam
e54de56376 Functional loopback code 2019-07-03 19:26:24 +01:00
Asim Aslam
7008809eff Make the link use debug 2019-07-02 20:57:23 +01:00
Asim Aslam
f619e46def Some functioning network code 2019-07-02 20:54:21 +01:00
Asim Aslam
c3611aead2 go fmt 2019-07-02 20:53:42 +01:00
Asim Aslam
686aa3aa05 log levels 2019-07-02 19:21:43 +01:00
Asim Aslam
543dc0166c Restructure network things before moving 2019-07-02 08:45:00 +01:00
Asim Aslam
372ad949ff Rename to mucp transport 2019-07-02 00:48:15 +01:00
Asim Aslam
a0c2d18c40 Merge pull request #559 from milosgajdos83/table-tests
Default routing table tests
2019-07-02 00:28:52 +01:00
Asim Aslam
b4236f4430 Add network transport 2019-07-02 00:27:53 +01:00
Milos Gajdos
0e1fcc4f28 Stop hardcoding table sizes; increment as you move on. 2019-07-01 23:38:49 +01:00
Milos Gajdos
8f22e61a8b List test function properly named. 2019-07-01 23:38:48 +01:00
Milos Gajdos
956902f641 Added List tests. 2019-07-01 23:38:48 +01:00
Milos Gajdos
ffac0b9a18 First batch of Add/Del/Update tests. 2019-07-01 23:38:48 +01:00
Asim Aslam
c108b51d2a add network to Node proto 2019-07-01 23:12:05 +01:00
Asim Aslam
5fd798c9b6 add resolver comment 2019-07-01 23:11:55 +01:00
Asim Aslam
ebe3633082 move network initialiser code 2019-07-01 22:59:11 +01:00
Asim Aslam
032c3134c6 update comment 2019-07-01 22:54:26 +01:00
Asim Aslam
8ccf61ebaf Strip Link methods 2019-07-01 22:52:28 +01:00
Asim Aslam
fbbc33d0f9 Set Network() to string 2019-07-01 22:41:27 +01:00
Milos Gajdos
da299ea26b Simmplified RT Lookup. No more Metric in Query. 2019-07-01 20:33:08 +01:00
Asim Aslam
d3e200575c Merge branch 'master' of ssh://github.com/micro/go-micro 2019-07-01 18:37:45 +01:00
Asim Aslam
ddee8412ff Add tunnel interface 2019-07-01 18:37:39 +01:00
Asim Aslam
c84f101e17 Merge pull request #553 from milosgajdos83/router-network
Changed router interface. Added table watcher. Advertise routes
2019-07-01 16:17:02 +01:00
Milos Gajdos
f6e064cdbd Fixed router idempotency. Return registry.ErrWatchStopped from mdns reg 2019-07-01 15:46:26 +01:00
Milos Gajdos
cff46c3fd8 Added Init state. Recreate exit and advertise channels when recovering
In order to differentiate between intialized and other states we
introduced a new state: Init. The router is in this state only when it's
created.

We have cleaned up router status management which is now handled by
manageStatus function only.
2019-07-01 15:46:26 +01:00
Milos Gajdos
32300eadc1 Added Router Status which allows to track router status 2019-07-01 15:46:25 +01:00
Milos Gajdos
8ad2f73ad6 Advertisement is now Update; started bit is now running. 2019-07-01 15:46:25 +01:00
Milos Gajdos
9d7420658d Changed router interface. Added table watcher. Advertise routes
* Changed router interface to return Advertisement channel
* Added default gateway route to the routing table if supplied
* Watch table for updates and advertise to the network
* We hash the routes on 3-tuple (Destination, Gateway, Network)
2019-07-01 15:46:25 +01:00
Asim Aslam
0971deb9cc Merge pull request #558 from micro/network
Networking code
2019-07-01 12:12:23 +01:00
Asim Aslam
0899282277 Checkpoint networking code 2019-07-01 11:55:15 +01:00
Asim Aslam
d8e998ad85 add peer in context 2019-06-27 14:53:01 +01:00
Asim Aslam
b4b76d452a Call advertise 2019-06-27 14:38:12 +01:00
Asim Aslam
67e3d560fe Lookup every service. FML 2019-06-27 14:37:52 +01:00
Asim Aslam
9630e153a5 fix grpc proto wrapper 2019-06-27 13:08:06 +01:00
Asim Aslam
43297f731c Add default router 2019-06-27 12:57:23 +01:00
Asim Aslam
f6f6e1b561 Use the router to get routes 2019-06-27 12:56:52 +01:00
Asim Aslam
4bee5c1b2b Merge pull request #546 from lpxxn/master
pass parameter to anonymous function
2019-06-27 07:02:45 +01:00
lpxxn
3b0ef425b6 pass parameter to anonymous function 2019-06-27 13:06:53 +08:00
李鹏
5334203435 Merge pull request #4 from micro/master
pull
2019-06-27 13:01:14 +08:00
Asim Aslam
0da8256426 Accept a range of addresses 2019-06-26 20:51:13 +01:00
Asim Aslam
940ea94a96 Lookup router via registry 2019-06-26 19:56:40 +01:00
Asim Aslam
b904f383c1 go fmt 2019-06-26 19:28:30 +01:00
Asim Aslam
cedcef032d Add remote lookup via router selector 2019-06-26 19:27:38 +01:00
Milos Gajdos
76011b151d Bugfix: Set gateway to node.Address
gw has not been initialized; it was basically an empty string and only
got populated by Sprintf-ing the addr:port IF the port has been set.
This commit sets the gw to node.Address to it's never an empty string.
2019-06-26 16:28:33 +01:00
Asim Aslam
27b145f968 add router proto 2019-06-26 16:23:10 +01:00
Asim Aslam
ac098e4d78 add router selector and network defaults 2019-06-26 16:12:57 +01:00
Asim Aslam
1a62c11166 Merge pull request #544 from milosgajdos83/router-rework
Router rework
2019-06-26 16:08:12 +01:00
Milos Gajdos
fe84a2d726 Route per service node. No Network Registry for now. 2019-06-26 16:03:19 +01:00
李鹏
c282125f09 Merge pull request #3 from micro/master
update
2019-06-26 11:56:00 +08:00
Asim Aslam
4cad7697cc Merge pull request #542 from magodo/config_consul_source_opt
Add consul-specific option for config (as registry)
2019-06-25 16:14:03 +01:00
magodo
a8dbca756c rename stuff per feedback 2019-06-25 22:41:31 +08:00
magodo
8e4fd16aff Add consul-specific option for config (as registry) 2019-06-25 18:31:32 +08:00
Asim Aslam
68764ebafc Add registry resolver 2019-06-24 15:30:17 +01:00
Asim Aslam
4d08618517 fix typo 2019-06-24 15:22:12 +01:00
Asim Aslam
e5959f80d6 add http resolver 2019-06-24 15:21:24 +01:00
Asim Aslam
b89423bf37 add resolver 2019-06-24 15:11:11 +01:00
Asim Aslam
9a56c4e0b2 Merge branch 'master' of ssh://github.com/micro/go-micro 2019-06-24 14:49:26 +01:00
Asim Aslam
4f982bb9cd Default to json content-type in api 2019-06-24 14:49:19 +01:00
Asim Aslam
1277f2478d Merge pull request #541 from milosgajdos83/gossip-del-service-revert
Reverts c0a628d
2019-06-22 20:05:10 +01:00
Asim Aslam
dffbe045e4 move node functions 2019-06-22 19:02:57 +01:00
Milos Gajdos
c3d2043caf Reverts c0a628d65b
Fixes #540
2019-06-22 19:01:03 +01:00
Asim Aslam
79cc8e34b0 Merge branch 'master' of ssh://github.com/micro/go-micro 2019-06-22 16:51:28 +01:00
Asim Aslam
2d91ba411e update the network interface 2019-06-22 16:51:20 +01:00
Asim Aslam
5ee7140aa3 Merge pull request #536 from magodo/config_source_consul_support_array
Config source consul support 1st array
2019-06-22 08:39:17 +01:00
magodo
6ef838c9aa Merge branch 'master' of https://github.com/micro/go-micro into config_source_consul_support_array 2019-06-22 07:14:15 +08:00
Asim Aslam
1b4005e9a5 Go fmt everything 2019-06-21 17:20:41 +01:00
Asim Aslam
3f97743e34 Move router and proxy into network package 2019-06-21 17:20:31 +01:00
Asim Aslam
7936d74602 Update comments 2019-06-21 16:17:12 +01:00
Asim Aslam
6db720b197 Merge branch 'master' of ssh://github.com/micro/go-micro 2019-06-21 15:14:08 +01:00
Asim Aslam
ca5acba0c6 Move selector to client/selector 2019-06-21 15:13:54 +01:00
Asim Aslam
b4acb9bb58 Merge pull request #538 from magodo/consul_path_prefix_leading_slash
config consul source supports slash as prefix
2019-06-21 14:23:53 +01:00
Asim Aslam
c350e19552 Move cmd => config/cmd 2019-06-21 13:36:11 +01:00
Asim Aslam
4aa0192eba Update go mod 2019-06-21 12:55:31 +01:00
magodo
3c82b2e9e8 Merge branch 'consul_path_prefix_leading_slash' into dev 2019-06-21 16:53:21 +08:00
magodo
9514bd7b2a Merge branch 'config_source_consul_support_array' into dev 2019-06-21 16:52:01 +08:00
magodo
7acd249147 config consul source supports slash as prefix
`config.NewConfig()` with consul source will both read from consul
and watch consul for changes. Hence, the `prefix` is used in these
2 cases:

- read case: it is used to strip path based on the `KVPair` returned
from consul `kv.List()` method
- watch case: it is used as the `key` of watch query (`keyprefix` type)

So for *watch case*, the `key` is leagal to be `/` for watching change
on root. While for *read case*, because `KVPair.Key` is always stripped
off the leading slash, so if user specified some `prefix` with leading
slash, we should strip it also.

An extream case would be: user want's to read & watch node in root dir.
One would specify `prefix` as `/`, and it should work then.
2019-06-21 16:35:48 +08:00
magodo
1983b4ae92 variable rename to abstract encoder 2019-06-21 15:30:45 +08:00
magodo
92b998c3ab consul config source support 1st-level array
Check whetehr the 1st level encoded json is array or not, to
support 1st level array in consul config.

During debug, i suspected the incapability of arrray is caused by
json reader, so i added test for array. I think it makes no harm
to also check that in.
2019-06-21 00:25:39 +08:00
Milos Gajdos
1765be049b router.Start() is now router.Advertise(). Updated code documentation. 2019-06-20 13:04:58 +01:00
Asim Aslam
8d5d812e32 Fix a streaming bug 2019-06-20 12:44:51 +01:00
Asim Aslam
3f910038a3 Move store to data/store 2019-06-19 22:04:13 +01:00
Asim Aslam
a8042adac1 Merge pull request #528 from milosgajdos83/router
Adds router package
2019-06-19 21:33:39 +01:00
Milos Gajdos
10a3636a9f Renamed variables, options and functions 2019-06-19 21:22:14 +01:00
Milos Gajdos
4e5fbbf7eb Replaced the debug network string by the correct router local address. 2019-06-19 18:11:16 +01:00
Milos Gajdos
59035ab801 Removed debug logs. advertiseToNetwork() replaced watchTable().
Debug logs that were helpful when squashing bugs have been removed.

advertiseToNetwork replaced the watchTable which originally watched the
routing table entries. We now take a different approach to propagating
the local registry services into the network registry.
2019-06-19 18:03:43 +01:00
Milos Gajdos
d3525ebab3 Debug messages. Squashed Add Route bugs and few others. 2019-06-19 18:03:43 +01:00
Milos Gajdos
2674294cbe Delete route when no node is available. 2019-06-19 18:03:43 +01:00
Milos Gajdos
b20dd16f92 Watcher now emits events instead of results. 2019-06-19 18:03:43 +01:00
Milos Gajdos
5088c9d916 Increased Network registry TTL. Routing Table remove is now delete.
Remove has been renamed to Delete to be more in line with the framework.

A bunch of comments have been added/updated for the future generations

We have increased the Network Registry TTL to 2 minutes.
2019-06-19 18:03:42 +01:00
Milos Gajdos
f62fcaad76 Added router ID. Deregister remote services when router is stopped.
Added ID function to router interface.

Network registry addresses are deregistered when the router is stopped.

Query has been updated to search for particular GW in lookups.
2019-06-19 18:03:42 +01:00
Milos Gajdos
322eaae529 Small code refactoring. Added more comments and parseToNode func 2019-06-19 18:03:42 +01:00
Milos Gajdos
6a33b7576b Removed router watcher code duplication. Small code refactor. 2019-06-19 18:03:42 +01:00
Milos Gajdos
6e669d4611 Reorganised source. Renamed files. No Code change. 2019-06-19 18:03:42 +01:00
Milos Gajdos
95fc625e99 Big refactor. New Registry watchers. New options. New names. 2019-06-19 18:03:42 +01:00
Milos Gajdos
338e0fdf18 Lots of refactoring. We now have basic routing table watcher. 2019-06-19 18:03:42 +01:00
Milos Gajdos
5899134b66 Simplified API. Correct Router initialization. Debug printing. 2019-06-19 18:03:41 +01:00
Milos Gajdos
da18ea4ab5 Changed default router table modifications. Entry is now Route. 2019-06-19 18:03:41 +01:00
Milos Gajdos
459f4c8387 Added Router ID and query options to limit number of results 2019-06-19 18:03:41 +01:00
Milos Gajdos
9c57f32f58 Added Entry type. Basic implementation of Router and Table 2019-06-19 18:03:41 +01:00
Milos Gajdos
ad92e6821e Removed DefaultTable() from global vars
We will not initialize DefaultTable as global var unless the users asks
for it explicitly.
2019-06-19 18:03:41 +01:00
Milos Gajdos
d7f0db04ec Added network ID option. Added mutex to routing table. 2019-06-19 18:03:41 +01:00
Milos Gajdos
e4311c3a10 Redefined and polished some interfaces and data structures. 2019-06-19 18:03:41 +01:00
Milos Gajdos
ee8b6b3114 Redefeind interfaces; Added better modelled data strauctures
Router interface has been redefined which fits better with what we are
looking for.

Routing table now offers a comprehensive set of information about its
entries which will make up for rich queries in the future

Query interface has been defined to enable current basic and more
advanced queries in the future.
2019-06-19 18:03:41 +01:00
Milos Gajdos
08da7c1283 First commit: Outline of Router interface 2019-06-19 18:03:40 +01:00
Asim Aslam
6587ae07be Merge pull request #523 from micro/grpc
GRPC Proxy
2019-06-19 15:31:45 +01:00
Asim Aslam
1c1dae0642 Fix the grpc test 2019-06-19 12:34:45 +01:00
Asim Aslam
a0cb105cf6 Merge pull request #525 from magodo/consul_config_prefix_no_leading_slash
`prefix` in consul api starts with no leading slash
2019-06-19 08:12:35 +01:00
magodo
606b1ff7cf prefix in consul api starts with no leading slash
When `consul.StripPrefix(true)` is set, current impl. will pass the
specified prefix (or default prefix) when calling consul api.

However, `prefix` in consul api starts with no leading slash, so
the default prefix (`/micro/config`) doesn't actually work.

I avoid code changes (esp. the one in `util.go`) to eliminate
impact on users who already notice it.
2019-06-19 14:42:09 +08:00
Asim Aslam
73a8b14145 Merge pull request #524 from milosgajdos83/gosssip-remove-node
Properly delete service nodes
2019-06-19 07:11:27 +01:00
Milos Gajdos
c0a628d65b Simplified delService code; properly delete service nodes 2019-06-18 21:39:00 +01:00
Asim Aslam
e9c2df775a Merge branch 'master' into grpc 2019-06-18 18:51:55 +01:00
Asim Aslam
d3a6297b17 Add working grpc proxy config 2019-06-18 18:51:52 +01:00
Asim Aslam
7266c62d09 remove comment 2019-06-18 15:33:31 +01:00
Asim Aslam
6459cdfc21 propagate updates to local watchers 2019-06-18 14:42:56 +01:00
Asim Aslam
ed54384bf4 Update network 2019-06-18 11:56:11 +01:00
Asim Aslam
51560009d2 go fmt 2019-06-18 11:04:36 +01:00
Asim Aslam
cf2f8a9a55 Merge branch 'master' of ssh://github.com/micro/go-micro 2019-06-18 11:04:16 +01:00
Asim Aslam
97cf2cd7c3 go fmt 2019-06-18 11:04:06 +01:00
Asim Aslam
d9fe8f802b Merge pull request #522 from xpunch/grpcMessageIssue
grpc message should be able to set
2019-06-18 10:45:11 +01:00
johnson
b754c33549 grpc message should be able to set 2019-06-18 17:07:31 +08:00
Asim Aslam
59eaa89bac Node is a network 2019-06-17 21:11:39 +01:00
Asim Aslam
f65694670e add cruft 2019-06-17 20:05:58 +01:00
Asim Aslam
1a571b8c82 Add network transport 2019-06-17 18:25:42 +01:00
Asim Aslam
308673b393 add network package 2019-06-17 16:57:53 +01:00
Asim Aslam
3a454d870a Merge pull request #520 from xpunch/grpcSubscriberIssues
grpc server subscriber missing some bug fixings
2019-06-17 11:57:37 +01:00
johnson
baaa386e27 a. add default context type when header not found
b. return subscribe error after handler finished
2019-06-17 17:54:37 +08:00
Asim Aslam
a619321b64 Merge pull request #519 from xpunch/master
missing nil check for grpc WaitGroup
2019-06-17 10:30:28 +01:00
johnson
363fb551af missing nil check for grpc WaitGroup 2019-06-17 17:07:55 +08:00
Asim Aslam
7a87ae0efa Merge pull request #514 from unistack-org/cleanup
remove mock data from memory registry
2019-06-13 07:50:08 +01:00
ab692ff590 remove mock data from memory registry
memory registry can be used as fast inprocess registry,
so mock data needs to be in tests only

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-06-13 00:51:56 +03:00
Asim Aslam
2b18b11ab1 Merge pull request #513 from micro/crufting
Crufting
2019-06-12 13:03:17 +01:00
Asim Aslam
af096951fc update import names for mucp 2019-06-12 12:54:45 +01:00
Asim Aslam
97967cbe14 move options under config 2019-06-12 12:45:42 +01:00
Asim Aslam
a6e09c9249 Merge branch 'master' into crufting 2019-06-12 12:29:57 +01:00
Asim Aslam
000e25a4b2 use the router 2019-06-12 12:05:34 +01:00
Asim Aslam
7a1cef46b0 fix broken links 2019-06-12 07:50:04 +01:00
Asim Aslam
a5412dd4a0 Move data to store 2019-06-12 07:46:20 +01:00
Asim Aslam
f81f66c98b Move DB to Map 2019-06-11 18:21:33 +01:00
Asim Aslam
43ed8f58f0 change wording 2019-06-11 18:15:18 +01:00
Asim Aslam
7727b359c8 Add memory data store 2019-06-11 17:49:34 +01:00
Asim Aslam
8e4e710e15 Move data to top level 2019-06-11 17:20:52 +01:00
Asim Aslam
4d4686d9be Merge branch 'master' into crufting 2019-06-11 15:38:12 +01:00
Asim Aslam
6d06ee8078 Update go.mod to strip etcd 2019-06-11 11:40:37 +01:00
Asim Aslam
aec1ca6635 remove etcd source 2019-06-11 09:53:06 +01:00
Asim Aslam
235a653f78 check in cruft 2019-06-11 09:52:35 +01:00
Asim Aslam
d030c78d1c Merge pull request #509 from outshow/master
fix etcd error
2019-06-11 09:52:21 +01:00
outshow
90a9df9b8c 1. use github.com/coreos instead of go.etcd.io in etcd related import path; 2. add dialtimeout to etcd client 2019-06-11 16:18:37 +08:00
Asim Aslam
070bd40b4c Merge branch 'master' into crufting 2019-06-10 12:44:27 +01:00
Asim Aslam
46de3ae9a9 Fix text codec 2019-06-10 12:42:43 +01:00
Asim Aslam
b6833e478d Merge pull request #506 from milosgajdos83/consul-close-watcher
Return registry.ErrWatcherStopped when consul watcher stops
2019-06-09 16:03:06 +01:00
Milos Gajdos
73b0a0ed0e Return registry.ErrWatcherStopped when consul watcher stops.
The original code returns "result chan closed" errors.Error which does
not carry higher semantics signal to downstream despite go-micro having
a clearly defined Error for this behaviour. This commit fixes that and
lets the downstream i.e. consumer of this code to act based on different
errors.
2019-06-09 15:51:27 +01:00
Asim Aslam
7c4515d748 Merge pull request #504 from magodo/json_pb_support
unmarshal json with `jsonpb` if accepter is pb
2019-06-09 08:57:55 +01:00
magodo
748c20c979 use package level func for unmarshal 2019-06-09 11:55:36 +08:00
magodo
3573ac818f unmarshal json with jsonpb if accepter is pb 2019-06-09 11:50:50 +08:00
Asim Aslam
ed4bce3285 check in this cruft 2019-06-08 19:40:44 +01:00
Asim Aslam
95b8147fa1 Merge pull request #501 from micro/wrap
add the wrappers back into the core router
2019-06-07 15:22:16 +01:00
Asim Aslam
f5ac238231 Include the decoded body 2019-06-07 15:15:22 +01:00
Asim Aslam
bfdec9e2e3 add the wrappers back into the core router 2019-06-07 15:02:19 +01:00
Asim Aslam
a2fbf19341 Move sync deps, change uuid to google and update go.mod 2019-06-07 13:53:42 +01:00
Asim Aslam
9e23855c37 Fixup the proxy, strip down go.mod. Win bigly 2019-06-07 13:42:39 +01:00
Asim Aslam
d65393a799 add top level options comment 2019-06-07 11:18:08 +01:00
Asim Aslam
ef67dc7ceb Merge pull request #500 from leaxoy/clean-mod
cleanup go.mod remove replace section
2019-06-07 11:14:53 +01:00
Asim Aslam
c317daf6b8 update proxy/options 2019-06-06 21:45:28 +01:00
lixiaohui
1152c7cb03 cleanup go.mod remove replace section 2019-06-07 03:05:33 +08:00
Asim Aslam
2cc18d6edc fix errors 2019-06-06 17:58:21 +01:00
Asim Aslam
a58bc8e75c add proxy interface and move router packages 2019-06-06 17:55:32 +01:00
Asim Aslam
64459c54a1 move init to options 2019-06-06 17:54:30 +01:00
Asim Aslam
c60b5a45bb Add proxy interface 2019-06-06 17:49:41 +01:00
Asim Aslam
94772a8cc7 remove the proto from proxy package 2019-06-06 17:38:05 +01:00
Asim Aslam
52613190b0 remove micro.png 2019-06-06 17:08:04 +01:00
Milos Gajdos
a29ce20e31 Changed default NATS address to nats://127.0.0.1:4222 in nats test 2019-06-06 12:06:14 +01:00
Asim Aslam
d59b693fa6 update interface 2019-06-06 11:46:13 +01:00
Asim Aslam
deee4dcd6a Merge branch 'master' of ssh://github.com/micro/go-micro 2019-06-06 11:32:42 +01:00
Asim Aslam
ab7d036697 add init package 2019-06-06 11:32:38 +01:00
Milos Gajdos
de87dfb6a0 Added gitignore file to avoid committing unnecessary files 2019-06-06 10:56:20 +01:00
Asim Aslam
0f70281e28 remove swp file 2019-06-06 09:52:22 +01:00
Asim Aslam
9d5cde42a3 Add top level proxy comment 2019-06-06 09:50:25 +01:00
Asim Aslam
83f46d9c9d top level package comment for service 2019-06-06 09:02:00 +01:00
Asim Aslam
19de02646e Merge pull request #497 from unistack-org/logf
server fix log.Log -> log.Logf
2019-06-05 14:33:51 +01:00
695c546385 server fix log.Log -> log.Logf
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-06-05 15:09:26 +03:00
Asim Aslam
953f41aeab Fix go mod issues 2019-06-05 10:22:28 +01:00
Asim Aslam
512d719470 fix imports 2019-06-05 06:39:56 +01:00
Asim Aslam
319608ca7f update readme 2019-06-03 19:32:31 +01:00
Asim Aslam
d2857a7b16 Add web and update deps 2019-06-03 19:30:43 +01:00
Asim Aslam
49f669df66 update grpc readme 2019-06-03 19:16:43 +01:00
Asim Aslam
1cd844bea4 update go mod 2019-06-03 19:07:21 +01:00
Asim Aslam
44b17b7e4b strip use of cmd 2019-06-03 19:07:09 +01:00
Asim Aslam
056e7e3c32 Merge pull request #486 from micro/quic
add quic transport
2019-06-03 18:50:55 +01:00
Asim Aslam
eec9a95a42 Merge pull request #485 from micro/grpc
Add grpc transport
2019-06-03 18:48:13 +01:00
Asim Aslam
b30fcd6a0f remove travis files 2019-06-03 18:45:37 +01:00
Asim Aslam
b42b6fa0fc Further consolidate the libraries 2019-06-03 18:44:43 +01:00
Asim Aslam
fe060b2d0b gofmt 2019-06-03 15:56:22 +01:00
Asim Aslam
d864c98aca Merge branch 'master' of ssh://github.com/micro/go-micro 2019-06-03 15:55:54 +01:00
Asim Aslam
f80f0eb38e fix broken pipe error 2019-06-03 15:55:47 +01:00
Asim Aslam
e73ed88008 Merge pull request #492 from ZichooleLongGui/patch-1
Update marshaler.go of codec/proto.
2019-06-01 10:26:27 +01:00
Zich Liew
1948e8a0d7 Update marshaler.go
Modify "Name()" to "String()" of proto.Marshaler
2019-06-01 16:14:06 +08:00
Asim Aslam
850f8bafdf update go.mod 2019-05-31 16:19:38 +01:00
Asim Aslam
fcf11011b8 remove rcache 2019-05-31 16:19:31 +01:00
Asim Aslam
2aba26d4d1 change logger 2019-05-31 16:03:50 +01:00
Asim Aslam
7a3a7e2eaf remove rcache reference 2019-05-31 16:00:44 +01:00
Asim Aslam
f9f893fa85 update source 2019-05-31 15:59:21 +01:00
Asim Aslam
30627c32c9 the garbage commit of go.mod vault deps 2019-05-31 15:24:15 +01:00
Asim Aslam
fd9021ad6a update go.mod 2019-05-31 15:07:27 +01:00
Asim Aslam
1374c5b14a update syntax 2019-05-31 13:45:28 +01:00
Asim Aslam
082d0b9f05 add memory config source options for json/yaml 2019-05-31 13:44:28 +01:00
Asim Aslam
ca769444e7 set localhost for nats 2019-05-31 13:18:22 +01:00
Asim Aslam
aeeb2b0010 Merge pull request #489 from micro/nats
Add nats broker as a default
2019-05-31 13:12:38 +01:00
Asim Aslam
7e07c9bc23 Merge pull request #490 from micro/stdlib
The move to a standard library for microservices
2019-05-31 13:11:32 +01:00
Asim Aslam
d5f6f82d5c update travis 2019-05-31 13:05:03 +01:00
Asim Aslam
508d181f60 update go.mod 2019-05-31 12:38:55 +01:00
Asim Aslam
ef9c223ac8 add vault/etcd 2019-05-31 12:38:49 +01:00
Asim Aslam
f8c880c39e Merge branch 'master' of ssh://github.com/micro/go-micro into stdlib 2019-05-31 12:36:05 +01:00
Asim Aslam
0f47569714 update go.mod 2019-05-31 12:35:43 +01:00
Asim Aslam
e41a461c8b update agent readme 2019-05-31 12:10:41 +01:00
Asim Aslam
02d580600d remove debug for now 2019-05-31 11:52:43 +01:00
Asim Aslam
66e02d4ab8 Merge pull request #491 from lpxxn/master
loop goroutines need pass the variable as a parameter to the anonymous function
2019-05-31 10:33:44 +01:00
lpxxn
a86c26d485 fix bug need pass the variable as a parameter to the anonymous function 2019-05-31 14:24:37 +08:00
李鹏
9a1115001c Merge pull request #2 from micro/master
update
2019-05-31 14:16:22 +08:00
Asim Aslam
f2139e2a16 Add debug => go-debug 2019-05-31 01:22:19 +01:00
Asim Aslam
95d134b57e Add sync => go-sync 2019-05-31 00:43:23 +01:00
Asim Aslam
4035ab5c7b Change go-log links 2019-05-31 00:38:05 +01:00
Asim Aslam
5595a8e0e4 Add log => go-log 2019-05-31 00:35:04 +01:00
Asim Aslam
c90d0eff0a update links 2019-05-31 00:27:41 +01:00
Asim Aslam
c567d1ceb3 Add runtime => run 2019-05-31 00:26:34 +01:00
Asim Aslam
a353c83f47 Add rcache => cache 2019-05-31 00:22:43 +01:00
Asim Aslam
ddd08377e6 remove travis file from agent 2019-05-31 00:19:05 +01:00
Asim Aslam
7faab93f9e Add agent => bot 2019-05-31 00:18:41 +01:00
Asim Aslam
b4874806df Add util 2019-05-30 23:52:10 +01:00
Asim Aslam
8618183508 bump go.mod 2019-05-30 23:20:20 +01:00
Asim Aslam
5e6491b7b0 add config 2019-05-30 23:11:13 +01:00
Asim Aslam
1200386097 Add nats broker as a default 2019-05-29 16:46:57 +01:00
Asim Aslam
b4dc822ae3 Change context key to string 2019-05-29 10:58:41 +01:00
Asim Aslam
9f037eafd2 fix waitgroup bug which crashes subscriber 2019-05-29 09:28:04 +01:00
Asim Aslam
58a70562d8 Merge pull request #488 from magodo/wait_accept_custom_wg
`Wait()` option now accept *sync.WaitGroup
2019-05-27 15:02:09 +01:00
magodo
ebc479ef2c Wait() option now accept *sync.WaitGroup
The original signature accept a boolean, and it feel like a little
verbose, since when people pass in this option, he/she always want to
pass a `true`.

Now if input `wg` is nil, it has same effect as passing `true` in
original code. Furthermore, if user want's finer grained control during
shutdown, one can pass in a predefined `wg`, so that server will wait
against it during shutdown.
2019-05-27 21:17:57 +08:00
Asim Aslam
e035664a8c Merge pull request #487 from lpxxn/master
fix streamming error io.ErrUnexpectedEOF
2019-05-27 09:29:48 +01:00
lpxxn
7da6ff1c4b fix:# #476 need send error info 2019-05-27 13:14:31 +08:00
李鹏
de270314d9 Merge pull request #1 from micro/master
update
2019-05-27 13:09:34 +08:00
Asim Aslam
ff1c325391 remove commented lines 2019-05-24 18:44:57 +01:00
Asim Aslam
e1578e93c7 add quic transport 2019-05-24 18:39:26 +01:00
Asim Aslam
25a0d05ac9 Add grpc transport 2019-05-24 17:15:59 +01:00
Asim Aslam
b926ae81bb Merge branch 'master' of ssh://github.com/micro/go-micro 2019-05-24 17:07:32 +01:00
Asim Aslam
f5d37d92af set nextprotos 2019-05-24 17:05:31 +01:00
Asim Aslam
e7eb74bf09 Merge pull request #484 from printfcoder/master
add AutoAck support for Server
2019-05-24 15:13:06 +01:00
shu xian
fac42bc1a9 add AutoAck support for Server 2019-05-24 20:06:27 +08:00
Asim Aslam
0a3df1b2f3 Update README.md 2019-05-23 00:35:02 +01:00
Asim Aslam
6de3d9eb24 Update go mod 2019-05-22 16:11:06 +00:00
Asim Aslam
0016752fc1 accept publisher options 2019-05-21 07:49:30 +00:00
Asim Aslam
92ab814138 remove sponsors 2019-05-19 15:38:49 +00:00
Asim Aslam
dc5ec0cdb2 Merge pull request #478 from sneat/fix-watcher-across-datacenters
Use existing consul client for watcher
2019-05-16 08:12:40 +01:00
Blair McMillan
389d141c5a Use existing consul client for watcher 2019-05-16 12:37:48 +10:00
Asim Aslam
3dfe7d8703 Merge pull request #473 from unistack-org/health
add RegisterCheck server option for internal health checks
2019-05-15 15:11:27 +01:00
a13cdfcc34 add RegisterCheck server option for internal health checks
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-05-15 15:34:34 +03:00
Asim Aslam
4f5ff076d4 Merge pull request #472 from unistack-org/gossip2
fix race with rcache
2019-05-09 21:24:27 +01:00
58775249c5 fix race with rcache
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-05-09 23:02:32 +03:00
Asim Aslam
8d21dd456c Merge pull request #471 from unistack-org/gossip
fix data races in gossip registry
2019-05-09 20:37:04 +01:00
1a151a3348 fix data races in gossip registry
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-05-09 22:32:21 +03:00
Asim Aslam
dc2e150a58 Merge pull request #466 from Ak-Army/master
send requestBody to mock function if it can handle it
2019-05-07 14:16:04 +01:00
Hunyadvári Péter
aaf4a5c51a rename reqBody variable to request 2019-05-02 18:06:43 +02:00
Hunyadvári Péter
08d70c9d0a fix and add tests 2019-05-02 18:02:24 +02:00
Hunyadvári Péter
c1c0a8fb30 send requestBody to mock function if it can handle it 2019-05-02 17:14:41 +02:00
Asim Aslam
e4704a8f41 Merge pull request #461 from moorepatrick/patch-1
Update consul/watch import
2019-04-26 19:22:33 +01:00
Patrick Moore
afd1f9f50f Update consul/watch import
The watch package was moved from github.com/hashicorp/consul/watch to github.com/hashicorp/consul/api/watch to live in the API module.
Per: 6c885d383a
2019-04-26 10:40:10 -07:00
Asim Aslam
46f44fd8f8 update go mod 2019-04-23 07:15:03 +00:00
Asim Aslam
df6561165a gofmt 2019-04-23 07:13:21 +00:00
Asim Aslam
96ed20de7b Merge pull request #458 from leaxoy/master
cleanup deps
2019-04-22 15:02:04 +01:00
lixiaohui
c43d7137cf cleanup deps 2019-04-22 21:39:02 +08:00
Asim Aslam
a97a1009ae Merge pull request #455 from tongjichao/fix/client_retries
fix: client retries will be 0 when not set
2019-04-18 18:16:53 +01:00
tongjichao
fd2ca3a13a fix: client retries will be 0 when not set
fix: client retries will be 0 when not set
2019-04-19 00:05:02 +08:00
Asim Aslam
f824ba0779 non-blocking call chan when retries are 0 2019-04-18 09:05:22 +00:00
Asim Aslam
722a3682c8 Update go mod 2019-03-28 17:01:56 +00:00
Asim Aslam
ca77773fbf fix json tag parsing 2019-03-19 00:21:25 +00:00
Asim Aslam
dbe83c0fff bump travis 2019-03-07 20:29:40 +00:00
389 changed files with 30477 additions and 15754 deletions

View File

@@ -0,0 +1,18 @@
---
name: Bug report
about: For reporting bugs in micro
title: "[BUG]"
labels: ''
assignees: ''
---
**Describe the bug**
1. What are you trying to do?
2. What did you expect to happen?
3. What happens instead?
**How to reproduce the bug:**
If possible, please include a minimal code snippet here.

View File

@@ -0,0 +1,17 @@
---
name: Feature request / Enhancement
about: If you have a need not served by micro
title: "[FEATURE]"
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Additional context**
Add any other context or screenshots about the feature request here.

View File

@@ -0,0 +1,8 @@
---
name: Question
about: Ask a question about micro
title: ''
labels: ''
assignees: ''
---

View File

@@ -0,0 +1,9 @@
## Pull Request template
Please, go through these steps before clicking submit on this PR.
1. Give a descriptive title to your PR.
2. Provide a description of your changes.
3. Make sure you have some relevant tests.
4. Put `closes #XXXX` in your comment to auto-close the issue that your PR fixes (if applicable).
**PLEASE REMOVE THIS TEMPLATE BEFORE SUBMITTING**

28
.gitea/autoapprove.yml Normal file
View File

@@ -0,0 +1,28 @@
name: "autoapprove"
on:
pull_request_target:
types: [assigned, opened, synchronize, reopened]
workflow_run:
workflows: ["prbuild"]
types:
- completed
permissions:
pull-requests: write
contents: write
jobs:
autoapprove:
runs-on: ubuntu-latest
steps:
- name: approve
run: [ "curl -o tea https://dl.gitea.com/tea/main/tea-main-linux-amd64",
"chmod +x ./tea",
"./tea login add --name unistack --token ${{ secrets.GITHUB_TOKEN }} --url https://git.unistack.org",
"./tea pr --repo ${{ github.event.repository.name }}"
]
if: github.actor == 'vtolstov'
id: approve
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -0,0 +1,51 @@
name: coverage
on:
push:
branches: [ main, v3, v4 ]
pull_request:
branches: [ main, v3, v4 ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v4
with:
filter: 'blob:none'
- name: setup go
uses: actions/setup-go@v5
with:
cache-dependency-path: "**/*.sum"
go-version: 'stable'
- name: test coverage
run: |
go test -v -cover ./... -covermode=count -coverprofile coverage.out -coverpkg ./...
go tool cover -func coverage.out -o coverage.out
- name: coverage badge
uses: tj-actions/coverage-badge-go@v2
with:
green: 80
filename: coverage.out
- uses: stefanzweifel/git-auto-commit-action@v4
name: autocommit
with:
commit_message: Apply Code Coverage Badge
skip_fetch: true
skip_checkout: true
file_pattern: ./README.md
- name: push
if: steps.auto-commit-action.outputs.changes_detected == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ github.token }}
branch: ${{ github.ref }}

View File

@@ -0,0 +1,29 @@
name: lint
on:
pull_request:
types: [opened, reopened, synchronize]
branches:
- master
- v3
- v4
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v4
with:
filter: 'blob:none'
- name: setup go
uses: actions/setup-go@v5
with:
cache-dependency-path: "**/*.sum"
go-version: 'stable'
- name: setup deps
run: go get -v ./...
- name: run lint
uses: https://github.com/golangci/golangci-lint-action@v6
with:
version: 'latest'

View File

@@ -0,0 +1,34 @@
name: test
on:
pull_request:
types: [opened, reopened, synchronize]
branches:
- master
- v3
- v4
push:
branches:
- master
- v3
- v4
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v4
with:
filter: 'blob:none'
- name: setup go
uses: actions/setup-go@v5
with:
cache-dependency-path: "**/*.sum"
go-version: 'stable'
- name: setup deps
run: go get -v ./...
- name: run test
env:
INTEGRATION_TESTS: yes
run: go test -mod readonly -v ./...

View File

@@ -0,0 +1,53 @@
name: test
on:
pull_request:
types: [opened, reopened, synchronize]
branches:
- master
- v3
- v4
push:
branches:
- master
- v3
- v4
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v4
with:
filter: 'blob:none'
- name: checkout tests
uses: actions/checkout@v4
with:
ref: master
filter: 'blob:none'
repository: unistack-org/micro-tests
path: micro-tests
- name: setup go
uses: actions/setup-go@v5
with:
cache-dependency-path: "**/*.sum"
go-version: 'stable'
- name: setup go work
env:
GOWORK: /workspace/${{ github.repository_owner }}/go.work
run: |
go work init
go work use .
go work use micro-tests
- name: setup deps
env:
GOWORK: /workspace/${{ github.repository_owner }}/go.work
run: go get -v ./...
- name: run tests
env:
INTEGRATION_TESTS: yes
GOWORK: /workspace/${{ github.repository_owner }}/go.work
run: |
cd micro-tests
go test -mod readonly -v ./... || true

View File

@@ -0,0 +1,24 @@
---
name: Bug report
about: For reporting bugs in go-micro
title: "[BUG]"
labels: ''
assignees: ''
---
**Describe the bug**
1. What are you trying to do?
2. What did you expect to happen?
3. What happens instead?
**How to reproduce the bug:**
If possible, please include a minimal code snippet here.
**Environment:**
Go Version: please paste `go version` output here
```
please paste `go env` output here
```

View File

@@ -0,0 +1,17 @@
---
name: Feature request / Enhancement
about: If you have a need not served by go-micro
title: "[FEATURE]"
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Additional context**
Add any other context or screenshots about the feature request here.

View File

@@ -0,0 +1,14 @@
---
name: Question
about: Ask a question about go-micro
title: ''
labels: ''
assignees: ''
---
Before asking, please check if your question has already been answered:
1. Check the documentation - https://micro.mu/docs/
2. Check the examples and plugins - https://github.com/micro/examples & https://github.com/micro/go-plugins
3. Search existing issues

View File

@@ -0,0 +1,9 @@
## Pull Request template
Please, go through these steps before clicking submit on this PR.
1. Give a descriptive title to your PR.
2. Provide a description of your changes.
3. Make sure you have some relevant tests.
4. Put `closes #XXXX` in your comment to auto-close the issue that your PR fixes (if applicable).
**PLEASE REMOVE THIS TEMPLATE BEFORE SUBMITTING**

View File

@@ -0,0 +1,26 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
commit-message:
prefix: "chore"
include: "scope"
# Maintain dependencies for Golang
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"
commit-message:
prefix: "chore"
include: "scope"

View File

@@ -0,0 +1,24 @@
name: "autoapprove"
on:
pull_request_target:
types: [assigned, opened, synchronize, reopened]
workflow_run:
workflows: ["prbuild"]
types:
- completed
permissions:
pull-requests: write
contents: write
jobs:
autoapprove:
runs-on: ubuntu-latest
steps:
- name: approve
uses: hmarr/auto-approve-action@v3
if: github.actor == 'vtolstov' || github.actor == 'dependabot[bot]'
id: approve
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -0,0 +1,21 @@
name: "automerge"
on:
pull_request_target:
types: [assigned, opened, synchronize, reopened]
permissions:
pull-requests: write
contents: write
jobs:
automerge:
runs-on: ubuntu-latest
if: github.actor == 'vtolstov'
steps:
- name: merge
id: merge
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.TOKEN}}

View File

@@ -0,0 +1,47 @@
name: build
on:
push:
branches:
- master
- v3
jobs:
test:
name: test
runs-on: ubuntu-latest
steps:
- name: setup
uses: actions/setup-go@v3
with:
go-version: 1.17
- name: checkout
uses: actions/checkout@v3
- name: cache
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-
- name: deps
run: go get -v -t -d ./...
- name: test
env:
INTEGRATION_TESTS: yes
run: go test -mod readonly -v ./...
lint:
name: lint
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: lint
uses: golangci/golangci-lint-action@v3.4.0
continue-on-error: true
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.30
# Optional: working directory, useful for monorepos
# working-directory: somedir
# Optional: golangci-lint command line arguments.
# args: --issues-exit-code=0
# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

View File

@@ -0,0 +1,39 @@
name: "codecov"
on:
workflow_run:
workflows: ["build"]
types:
- completed
push:
branches: [ v3 ]
pull_request:
branches: [ v3 ]
schedule:
- cron: '34 1 * * 0'
jobs:
codecov:
name: codecov
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'go' ]
steps:
- name: checkout
uses: actions/checkout@v3
- name: setup
uses: actions/setup-go@v3
with:
go-version: 1.17
- name: Run coverage
run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
- name: codecov
uses: codecov/codecov-action@v3.1.1

View File

@@ -0,0 +1,78 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "codeql"
on:
workflow_run:
workflows: ["prbuild"]
types:
- completed
push:
branches: [ master, v3 ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master, v3 ]
schedule:
- cron: '34 1 * * 0'
jobs:
analyze:
name: analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'go' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
steps:
- name: checkout
uses: actions/checkout@v3
- name: setup
uses: actions/setup-go@v3
with:
go-version: 1.17
# Initializes the CodeQL tools for scanning.
- name: init
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: autobuild
uses: github/codeql-action/autobuild@v2
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: analyze
uses: github/codeql-action/analyze@v2

View File

@@ -0,0 +1,27 @@
name: "dependabot-automerge"
on:
pull_request_target:
types: [assigned, opened, synchronize, reopened]
permissions:
pull-requests: write
contents: write
jobs:
automerge:
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
steps:
- name: metadata
id: metadata
uses: dependabot/fetch-metadata@v1.3.6
with:
github-token: "${{ secrets.TOKEN }}"
- name: merge
id: merge
if: ${{contains(steps.metadata.outputs.dependency-names, 'go.unistack.org')}}
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.TOKEN}}

View File

@@ -0,0 +1,40 @@
name: prbuild
on:
pull_request:
branches:
- master
- v3
jobs:
test:
name: test
runs-on: ubuntu-latest
steps:
- name: setup
uses: actions/setup-go@v3
with:
go-version: 1.17
- name: checkout
uses: actions/checkout@v3
- name: cache
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-
- name: deps
run: go get -v -t -d ./...
- name: test
env:
INTEGRATION_TESTS: yes
run: go test -mod readonly -v ./...
lint:
name: lint
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: lint
uses: golangci/golangci-lint-action@v3.4.0
continue-on-error: true
with:
version: v1.30

39
.gitignore vendored Normal file
View File

@@ -0,0 +1,39 @@
# Develop tools
/.vscode/
/.idea/
.idea
.vscode
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
# Folders
_obj
_test
_build
.DS_Store
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
# Test binary, build with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# vim temp files
*~
*.swp
*.swo

5
.golangci.yml Normal file
View File

@@ -0,0 +1,5 @@
run:
concurrency: 8
deadline: 5m
issues-exit-code: 1
tests: true

View File

@@ -1,7 +0,0 @@
language: go
go:
- 1.10.x
- 1.11.x
notifications:
slack:
secure: aEvhLbhujaGaKSrOokiG3//PaVHTIrc3fBpoRbCRqfZpyq6WREoapJJhF+tIpWWOwaC9GmChbD6aHo/jMUgwKXVyPSaNjiEL87YzUUpL8B2zslNp1rgfTg/LrzthOx3Q1TYwpaAl3to0fuHUVFX4yMeC2vuThq7WSXgMMxFCtbc=

View File

@@ -176,7 +176,8 @@
END OF TERMS AND CONDITIONS
Copyright 2015 Asim Aslam.
Copyright 2015-2020 Asim Aslam.
Copyright 2019-2020 Unistack LLC.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@@ -1,54 +1,43 @@
# Go Micro [![License](https://img.shields.io/:license-apache-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![GoDoc](https://godoc.org/github.com/micro/go-micro?status.svg)](https://godoc.org/github.com/micro/go-micro) [![Travis CI](https://api.travis-ci.org/micro/go-micro.svg?branch=master)](https://travis-ci.org/micro/go-micro) [![Go Report Card](https://goreportcard.com/badge/micro/go-micro)](https://goreportcard.com/report/github.com/micro/go-micro)
# Micro
![Coverage](https://img.shields.io/badge/Coverage-44.6%25-yellow)
[![License](https://img.shields.io/:license-apache-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Doc](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat-square)](https://pkg.go.dev/go.unistack.org/micro/v3?tab=overview)
[![Status](https://git.unistack.org/unistack-org/micro/actions/workflows/job_tests.yml/badge.svg?branch=v3)](https://git.unistack.org/unistack-org/micro/actions?query=workflow%3Abuild+branch%3Av3+event%3Apush)
[![Lint](https://goreportcard.com/badge/go.unistack.org/micro/v3)](https://goreportcard.com/report/go.unistack.org/micro/v3)
Go Micro is a framework for micro service development.
Micro is a standard library for microservices.
## Overview
Go Micro provides the core requirements for distributed systems development including RPC and Event driven communication.
The **micro** philosophy is sane defaults with a pluggable architecture. We provide defaults to get you started quickly
but everything can be easily swapped out.
<img src="https://micro.mu/docs/images/go-micro.svg" />
Plugins are available at [github.com/micro/go-plugins](https://github.com/micro/go-plugins).
Follow us on [Twitter](https://twitter.com/microhq) or join the [Slack](http://slack.micro.mu/) community.
Micro provides the core requirements for distributed systems development including RPC and Event driven communication.
## Features
Go Micro abstracts away the details of distributed systems. Here are the main features.
Micro abstracts away the details of distributed systems. Here are the main features.
- **Dynamic Config** - Load and hot reload dynamic config from anywhere. The config interface provides a way to load application
level config from any source such as env vars, cmdline, file, consul, vault... You can merge the sources and even define fallbacks.
- **Data Storage** - A simple data store interface to read, write and delete records. It includes support for memory, file and
s3. State and persistence becomes a core requirement beyond prototyping and Micro looks to build that into the framework.
- **Service Discovery** - Automatic service registration and name resolution. Service discovery is at the core of micro service
development. When service A needs to speak to service B it needs the location of that service. The default discovery mechanism is
multicast DNS (mdns), a zeroconf system. You can optionally set gossip using the SWIM protocol for p2p networks or consul for a
resilient cloud-native setup.
- **Load Balancing** - Client side load balancing built on service discovery. Once we have the addresses of any number of instances
of a service we now need a way to decide which node to route to. We use random hashed load balancing to provide even distribution
across the services and retry a different node if there's a problem.
development. When service A needs to speak to service B it needs the location of that service.
- **Message Encoding** - Dynamic message encoding based on content-type. The client and server will use codecs along with content-type
to seamlessly encode and decode Go types for you. Any variety of messages could be encoded and sent from different clients. The client
and server handle this by default. This includes protobuf and json by default.
and server handle this by default.
- **Request/Response** - RPC based request/response with support for bidirectional streaming. We provide an abstraction for synchronous
communication. A request made to a service will be automatically resolved, load balanced, dialled and streamed. The default
transport is http/1.1 or http2 when tls is enabled.
- **Async Messaging** - Pub/Sub is built in as a first class citizen for asynchronous communication and event driven architectures.
Event notifications are a core pattern in micro service development.
- **Async Messaging** - PubSub is built in as a first class citizen for asynchronous communication and event driven architectures.
Event notifications are a core pattern in micro service development. The default messaging is point-to-point http/1.1 or http2 when tls
is enabled.
- **Synchronization** - Distributed systems are often built in an eventually consistent manner. Support for distributed locking and
leadership are built in as a Sync interface. When using an eventually consistent database or scheduling use the Sync interface.
- **Pluggable Interfaces** - Go Micro makes use of Go interfaces for each distributed system abstraction. Because of this these interfaces
are pluggable and allows Go Micro to be runtime agnostic. You can plugin any underlying technology. Find plugins in
[github.com/micro/go-plugins](https://github.com/micro/go-plugins).
- **Pluggable Interfaces** - Micro makes use of Go interfaces for each system abstraction. Because of this these interfaces
are pluggable and allows Micro to be runtime agnostic.
## Getting Started
## License
See the [docs](https://micro.mu/docs/go-micro.html) for detailed information on the architecture, installation and use of go-micro.
Micro is Apache 2.0 licensed.
## Sponsors
Sixt is an Enterprise Sponsor of Micro
<a href="https://micro.mu/blog/2016/04/25/announcing-sixt-sponsorship.html"><img src="https://micro.mu/sixt_logo.png" width=150px height="auto" /></a>

View File

@@ -1,41 +0,0 @@
# Go Micro [![License](https://img.shields.io/:license-apache-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![GoDoc](https://godoc.org/github.com/micro/go-micro?status.svg)](https://godoc.org/github.com/micro/go-micro) [![Travis CI](https://api.travis-ci.org/micro/go-micro.svg?branch=master)](https://travis-ci.org/micro/go-micro) [![Go Report Card](https://goreportcard.com/badge/micro/go-micro)](https://goreportcard.com/report/github.com/micro/go-micro)
Go Micro是基于Golang的微服务开发框架。
## 概览
Go Micro提供分布式系统开发的核心库包含RPC与事件驱动的通信机制。
**micro**的设计哲学是可插拔的架构理念,她提供可快速构建系统的组件,并且可以根据自身的需求剥离默认实现并自行定制。
<img src="https://micro.mu/docs/images/go-micro.svg" />
所有插件可在仓库[github.com/micro/go-plugins](https://github.com/micro/go-plugins)中找到。
可以订阅我们的[Twitter](https://twitter.com/microhq)或者加入[Slack](http://slack.micro.mu/)论坛。
## 特性
Go Micro把分布式系统的各种细节抽象出来。下面是它的主要特性。
- **服务发现Service Discovery** - 自动服务注册与名称解析。服务发现是微服务开发中的核心。当服务A要与服务B协作时它得知道B在哪里。默认的服务发现系统是Consul而multicast DNS (mdns组播)机制作为本地解决方案或者零依赖的P2P网络中的SWIM协议gossip
- **负载均衡Load Balancing** - 在服务发现之上构建了负载均衡机制。当我们得到一个服务的任意多个的实例节点时,我们要一个机制去决定要路由到哪一个节点。我们使用随机处理过的哈希负载均衡机制来保证对服务请求颁发的均匀分布,并且在发生问题时进行重试。
- **消息编码Message Encoding** - 支持基于内容类型content-type动态编码消息。客户端和服务端会一起使用content-type的格式来对Go进行无缝编/解码。各种各样的消息被编码会发送到不同的客户端客户端服服务端默认会处理这些消息。content-type默认包含proto-rpc和json-rpc。
- **Request/Response** - RPC通信基于支持双向流的请求/响应方式我们提供有抽象的同步通信机制。请求发送到服务时会自动解析、负载均衡、拨号、转成字节流。默认的传输协议是http/1.1而tls下使用http2协议。
- **异步消息Async Messaging** - 发布订阅PubSub头等功能内置在异步通信与事件驱动架构中。事件通知在微服务开发中处于核心位置。默认的消息传送使用点到点http/1.1激活tls时则使用http2。
- **可插拔接口Pluggable Interfaces** - Go Micro为每个分布式系统抽象出接口。因此Go Micro的接口都是可插拔的允许其在运行时不可知的情况下仍可支持。所以只要实现接口可以在内部使用任何的技术。更多插件请参考[github.com/micro/go-plugins](https://github.com/micro/go-plugins)。
## 快速上手
更多关于架构、安装的资料可以查看[文档](https://micro.mu/docs/go-micro_cn.html)。
## 赞助商
Sixt是我们的赞助商。
<a href="https://micro.mu/blog/2016/04/25/announcing-sixt-sponsorship.html"><img src="https://micro.mu/sixt_logo.png" width=150px height="auto" /></a>

15
SECURITY.md Normal file
View File

@@ -0,0 +1,15 @@
# Security Policy
## Supported Versions
Use this section to tell people about which versions of your project are
currently being supported with security updates.
| Version | Supported |
| ------- | ------------------ |
| 3.7.x | :white_check_mark: |
| < 3.7.0 | :x: |
## Reporting a Vulnerability
If you find any issue, please create github issue in this repo

View File

@@ -1,70 +1,134 @@
// Package broker is an interface used for asynchronous messaging
package broker
import (
"context"
"errors"
"time"
"go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v3/metadata"
)
// DefaultBroker default memory broker
var DefaultBroker Broker = NewBroker()
var (
// ErrNotConnected returns when broker used but not connected yet
ErrNotConnected = errors.New("broker not connected")
// ErrDisconnected returns when broker disconnected
ErrDisconnected = errors.New("broker disconnected")
// DefaultGracefulTimeout
DefaultGracefulTimeout = 5 * time.Second
)
// Broker is an interface used for asynchronous messaging.
type Broker interface {
// Name returns broker instance name
Name() string
// Init initilize broker
Init(opts ...Option) error
// Options returns broker options
Options() Options
// Address return configured address
Address() string
Connect() error
Disconnect() error
Init(...Option) error
Publish(string, *Message, ...PublishOption) error
Subscribe(string, Handler, ...SubscribeOption) (Subscriber, error)
// Connect connects to broker
Connect(ctx context.Context) error
// Disconnect disconnect from broker
Disconnect(ctx context.Context) error
// Publish message to broker topic
Publish(ctx context.Context, topic string, msg *Message, opts ...PublishOption) error
// Subscribe subscribes to topic message via handler
Subscribe(ctx context.Context, topic string, h Handler, opts ...SubscribeOption) (Subscriber, error)
// BatchPublish messages to broker with multiple topics
BatchPublish(ctx context.Context, msgs []*Message, opts ...PublishOption) error
// BatchSubscribe subscribes to topic messages via handler
BatchSubscribe(ctx context.Context, topic string, h BatchHandler, opts ...SubscribeOption) (Subscriber, error)
// String type of broker
String() string
// Live returns broker liveness
Live() bool
// Ready returns broker readiness
Ready() bool
// Health returns broker health
Health() bool
}
type (
FuncPublish func(ctx context.Context, topic string, msg *Message, opts ...PublishOption) error
HookPublish func(next FuncPublish) FuncPublish
FuncBatchPublish func(ctx context.Context, msgs []*Message, opts ...PublishOption) error
HookBatchPublish func(next FuncBatchPublish) FuncBatchPublish
FuncSubscribe func(ctx context.Context, topic string, h Handler, opts ...SubscribeOption) (Subscriber, error)
HookSubscribe func(next FuncSubscribe) FuncSubscribe
FuncBatchSubscribe func(ctx context.Context, topic string, h BatchHandler, opts ...SubscribeOption) (Subscriber, error)
HookBatchSubscribe func(next FuncBatchSubscribe) FuncBatchSubscribe
)
// Handler is used to process messages via a subscription of a topic.
// The handler is passed a publication interface which contains the
// message and optional Ack method to acknowledge receipt of the message.
type Handler func(Publication) error
type Handler func(Event) error
type Message struct {
Header map[string]string
Body []byte
// Events contains multiple events
type Events []Event
// Ack try to ack all events and return
func (evs Events) Ack() error {
var err error
for _, ev := range evs {
if err = ev.Ack(); err != nil {
return err
}
}
return nil
}
// Publication is given to a subscription handler for processing
type Publication interface {
// SetError sets error on event
func (evs Events) SetError(err error) {
for _, ev := range evs {
ev.SetError(err)
}
}
// BatchHandler is used to process messages in batches via a subscription of a topic.
type BatchHandler func(Events) error
// Event is given to a subscription handler for processing
type Event interface {
// Context return context.Context for event
Context() context.Context
// Topic returns event topic
Topic() string
// Message returns broker message
Message() *Message
// Ack acknowledge message
Ack() error
// Error returns message error (like decoding errors or some other)
Error() error
// SetError set event processing error
SetError(err error)
}
// Message is used to transfer data
type Message struct {
// Header contains message metadata
Header metadata.Metadata
// Body contains message body
Body codec.RawMessage
}
// NewMessage create broker message with topic filled
func NewMessage(topic string) *Message {
m := &Message{Header: metadata.New(2)}
m.Header.Set(metadata.HeaderTopic, topic)
return m
}
// Subscriber is a convenience return type for the Subscribe method
type Subscriber interface {
// Options returns subscriber options
Options() SubscribeOptions
// Topic returns topic for subscription
Topic() string
Unsubscribe() error
}
var (
DefaultBroker Broker = newHttpBroker()
)
func NewBroker(opts ...Option) Broker {
return newHttpBroker(opts...)
}
func Init(opts ...Option) error {
return DefaultBroker.Init(opts...)
}
func Connect() error {
return DefaultBroker.Connect()
}
func Disconnect() error {
return DefaultBroker.Disconnect()
}
func Publish(topic string, msg *Message, opts ...PublishOption) error {
return DefaultBroker.Publish(topic, msg, opts...)
}
func Subscribe(topic string, handler Handler, opts ...SubscribeOption) (Subscriber, error) {
return DefaultBroker.Subscribe(topic, handler, opts...)
}
func String() string {
return DefaultBroker.String()
// Unsubscribe from topic
Unsubscribe(ctx context.Context) error
}

63
broker/context.go Normal file
View File

@@ -0,0 +1,63 @@
package broker
import (
"context"
)
type brokerKey struct{}
// FromContext returns broker from passed context
func FromContext(ctx context.Context) (Broker, bool) {
if ctx == nil {
return nil, false
}
c, ok := ctx.Value(brokerKey{}).(Broker)
return c, ok
}
// MustContext returns broker from passed context
func MustContext(ctx context.Context) Broker {
b, ok := FromContext(ctx)
if !ok {
panic("missing broker")
}
return b
}
// NewContext savess broker in context
func NewContext(ctx context.Context, s Broker) context.Context {
if ctx == nil {
ctx = context.Background()
}
return context.WithValue(ctx, brokerKey{}, s)
}
// SetSubscribeOption returns a function to setup a context with given value
func SetSubscribeOption(k, v interface{}) SubscribeOption {
return func(o *SubscribeOptions) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, k, v)
}
}
// SetOption returns a function to setup a context with given value
func SetOption(k, v interface{}) Option {
return func(o *Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, k, v)
}
}
// SetPublishOption returns a function to setup a context with given value
func SetPublishOption(k, v interface{}) PublishOption {
return func(o *PublishOptions) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, k, v)
}
}

72
broker/context_test.go Normal file
View File

@@ -0,0 +1,72 @@
package broker
import (
"context"
"testing"
)
func TestFromContext(t *testing.T) {
ctx := context.WithValue(context.TODO(), brokerKey{}, NewBroker())
c, ok := FromContext(ctx)
if c == nil || !ok {
t.Fatal("FromContext not works")
}
}
func TestFromNilContext(t *testing.T) {
// nolint: staticcheck
c, ok := FromContext(nil)
if ok || c != nil {
t.Fatal("FromContext not works")
}
}
func TestNewContext(t *testing.T) {
ctx := NewContext(context.TODO(), NewBroker())
c, ok := FromContext(ctx)
if c == nil || !ok {
t.Fatal("NewContext not works")
}
}
func TestNewNilContext(t *testing.T) {
// nolint: staticcheck
ctx := NewContext(nil, NewBroker())
c, ok := FromContext(ctx)
if c == nil || !ok {
t.Fatal("NewContext not works")
}
}
func TestSetSubscribeOption(t *testing.T) {
type key struct{}
o := SetSubscribeOption(key{}, "test")
opts := &SubscribeOptions{}
o(opts)
if v, ok := opts.Context.Value(key{}).(string); !ok || v == "" {
t.Fatal("SetSubscribeOption not works")
}
}
func TestSetPublishOption(t *testing.T) {
type key struct{}
o := SetPublishOption(key{}, "test")
opts := &PublishOptions{}
o(opts)
if v, ok := opts.Context.Value(key{}).(string); !ok || v == "" {
t.Fatal("SetPublishOption not works")
}
}
func TestSetOption(t *testing.T) {
type key struct{}
o := SetOption(key{}, "test")
opts := &Options{}
o(opts)
if v, ok := opts.Context.Value(key{}).(string); !ok || v == "" {
t.Fatal("SetOption not works")
}
}

View File

@@ -1,11 +0,0 @@
// Package http provides a http based message broker
package http
import (
"github.com/micro/go-micro/broker"
)
// NewBroker returns a new http broker
func NewBroker(opts ...broker.Option) broker.Broker {
return broker.NewBroker(opts...)
}

View File

@@ -1,23 +0,0 @@
package http
import (
"context"
"net/http"
"github.com/micro/go-micro/broker"
)
// Handle registers the handler for the given pattern.
func Handle(pattern string, handler http.Handler) broker.Option {
return func(o *broker.Options) {
if o.Context == nil {
o.Context = context.Background()
}
handlers, ok := o.Context.Value("http_handlers").(map[string]http.Handler)
if !ok {
handlers = make(map[string]http.Handler)
}
handlers[pattern] = handler
o.Context = context.WithValue(o.Context, "http_handlers", handlers)
}
}

View File

@@ -1,680 +0,0 @@
package broker
import (
"bytes"
"context"
"crypto/tls"
"errors"
"fmt"
"io"
"io/ioutil"
"math/rand"
"net"
"net/http"
"net/url"
"runtime"
"strconv"
"strings"
"sync"
"time"
"github.com/google/uuid"
"github.com/micro/go-micro/codec/json"
merr "github.com/micro/go-micro/errors"
"github.com/micro/go-micro/registry"
"github.com/micro/go-rcache"
maddr "github.com/micro/util/go/lib/addr"
mnet "github.com/micro/util/go/lib/net"
mls "github.com/micro/util/go/lib/tls"
"golang.org/x/net/http2"
)
// HTTP Broker is a point to point async broker
type httpBroker struct {
id string
address string
opts Options
mux *http.ServeMux
c *http.Client
r registry.Registry
sync.RWMutex
subscribers map[string][]*httpSubscriber
running bool
exit chan chan error
// offline message inbox
mtx sync.RWMutex
inbox map[string][][]byte
}
type httpSubscriber struct {
opts SubscribeOptions
id string
topic string
fn Handler
svc *registry.Service
hb *httpBroker
}
type httpPublication struct {
m *Message
t string
}
var (
DefaultSubPath = "/_sub"
broadcastVersion = "ff.http.broadcast"
registerTTL = time.Minute
registerInterval = time.Second * 30
)
func init() {
rand.Seed(time.Now().Unix())
}
func newTransport(config *tls.Config) *http.Transport {
if config == nil {
config = &tls.Config{
InsecureSkipVerify: true,
}
}
dialTLS := func(network string, addr string) (net.Conn, error) {
return tls.Dial(network, addr, config)
}
t := &http.Transport{
Proxy: http.ProxyFromEnvironment,
Dial: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
}).Dial,
TLSHandshakeTimeout: 10 * time.Second,
DialTLS: dialTLS,
}
runtime.SetFinalizer(&t, func(tr **http.Transport) {
(*tr).CloseIdleConnections()
})
// setup http2
http2.ConfigureTransport(t)
return t
}
func newHttpBroker(opts ...Option) Broker {
options := Options{
Codec: json.Marshaler{},
Context: context.TODO(),
}
for _, o := range opts {
o(&options)
}
// set address
addr := ":0"
if len(options.Addrs) > 0 && len(options.Addrs[0]) > 0 {
addr = options.Addrs[0]
}
// get registry
reg, ok := options.Context.Value(registryKey).(registry.Registry)
if !ok {
reg = registry.DefaultRegistry
}
h := &httpBroker{
id: "broker-" + uuid.New().String(),
address: addr,
opts: options,
r: reg,
c: &http.Client{Transport: newTransport(options.TLSConfig)},
subscribers: make(map[string][]*httpSubscriber),
exit: make(chan chan error),
mux: http.NewServeMux(),
inbox: make(map[string][][]byte),
}
// specify the message handler
h.mux.Handle(DefaultSubPath, h)
// get optional handlers
if h.opts.Context != nil {
handlers, ok := h.opts.Context.Value("http_handlers").(map[string]http.Handler)
if ok {
for pattern, handler := range handlers {
h.mux.Handle(pattern, handler)
}
}
}
return h
}
func (h *httpPublication) Ack() error {
return nil
}
func (h *httpPublication) Message() *Message {
return h.m
}
func (h *httpPublication) Topic() string {
return h.t
}
func (h *httpSubscriber) Options() SubscribeOptions {
return h.opts
}
func (h *httpSubscriber) Topic() string {
return h.topic
}
func (h *httpSubscriber) Unsubscribe() error {
return h.hb.unsubscribe(h)
}
func (h *httpBroker) saveMessage(topic string, msg []byte) {
h.mtx.Lock()
defer h.mtx.Unlock()
// get messages
c := h.inbox[topic]
// save message
c = append(c, msg)
// max length 64
if len(c) > 64 {
c = c[:64]
}
// save inbox
h.inbox[topic] = c
}
func (h *httpBroker) getMessage(topic string, num int) [][]byte {
h.mtx.Lock()
defer h.mtx.Unlock()
// get messages
c, ok := h.inbox[topic]
if !ok {
return nil
}
// more message than requests
if len(c) >= num {
msg := c[:num]
h.inbox[topic] = c[num:]
return msg
}
// reset inbox
h.inbox[topic] = nil
// return all messages
return c
}
func (h *httpBroker) subscribe(s *httpSubscriber) error {
h.Lock()
defer h.Unlock()
if err := h.r.Register(s.svc, registry.RegisterTTL(registerTTL)); err != nil {
return err
}
h.subscribers[s.topic] = append(h.subscribers[s.topic], s)
return nil
}
func (h *httpBroker) unsubscribe(s *httpSubscriber) error {
h.Lock()
defer h.Unlock()
var subscribers []*httpSubscriber
// look for subscriber
for _, sub := range h.subscribers[s.topic] {
// deregister and skip forward
if sub.id == s.id {
_ = h.r.Deregister(sub.svc)
continue
}
// keep subscriber
subscribers = append(subscribers, sub)
}
// set subscribers
h.subscribers[s.topic] = subscribers
return nil
}
func (h *httpBroker) run(l net.Listener) {
t := time.NewTicker(registerInterval)
defer t.Stop()
for {
select {
// heartbeat for each subscriber
case <-t.C:
h.RLock()
for _, subs := range h.subscribers {
for _, sub := range subs {
_ = h.r.Register(sub.svc, registry.RegisterTTL(registerTTL))
}
}
h.RUnlock()
// received exit signal
case ch := <-h.exit:
ch <- l.Close()
h.RLock()
for _, subs := range h.subscribers {
for _, sub := range subs {
_ = h.r.Deregister(sub.svc)
}
}
h.RUnlock()
return
}
}
}
func (h *httpBroker) ServeHTTP(w http.ResponseWriter, req *http.Request) {
if req.Method != "POST" {
err := merr.BadRequest("go.micro.broker", "Method not allowed")
http.Error(w, err.Error(), http.StatusMethodNotAllowed)
return
}
defer req.Body.Close()
req.ParseForm()
b, err := ioutil.ReadAll(req.Body)
if err != nil {
errr := merr.InternalServerError("go.micro.broker", "Error reading request body: %v", err)
w.WriteHeader(500)
w.Write([]byte(errr.Error()))
return
}
var m *Message
if err = h.opts.Codec.Unmarshal(b, &m); err != nil {
errr := merr.InternalServerError("go.micro.broker", "Error parsing request body: %v", err)
w.WriteHeader(500)
w.Write([]byte(errr.Error()))
return
}
topic := m.Header[":topic"]
delete(m.Header, ":topic")
if len(topic) == 0 {
errr := merr.InternalServerError("go.micro.broker", "Topic not found")
w.WriteHeader(500)
w.Write([]byte(errr.Error()))
return
}
p := &httpPublication{m: m, t: topic}
id := req.Form.Get("id")
h.RLock()
for _, subscriber := range h.subscribers[topic] {
if id == subscriber.id {
// sub is sync; crufty rate limiting
// so we don't hose the cpu
subscriber.fn(p)
}
}
h.RUnlock()
}
func (h *httpBroker) Address() string {
h.RLock()
defer h.RUnlock()
return h.address
}
func (h *httpBroker) Connect() error {
h.RLock()
if h.running {
h.RUnlock()
return nil
}
h.RUnlock()
h.Lock()
defer h.Unlock()
var l net.Listener
var err error
if h.opts.Secure || h.opts.TLSConfig != nil {
config := h.opts.TLSConfig
fn := func(addr string) (net.Listener, error) {
if config == nil {
hosts := []string{addr}
// check if its a valid host:port
if host, _, err := net.SplitHostPort(addr); err == nil {
if len(host) == 0 {
hosts = maddr.IPs()
} else {
hosts = []string{host}
}
}
// generate a certificate
cert, err := mls.Certificate(hosts...)
if err != nil {
return nil, err
}
config = &tls.Config{Certificates: []tls.Certificate{cert}}
}
return tls.Listen("tcp", addr, config)
}
l, err = mnet.Listen(h.address, fn)
} else {
fn := func(addr string) (net.Listener, error) {
return net.Listen("tcp", addr)
}
l, err = mnet.Listen(h.address, fn)
}
if err != nil {
return err
}
addr := h.address
h.address = l.Addr().String()
go http.Serve(l, h.mux)
go func() {
h.run(l)
h.Lock()
h.address = addr
h.Unlock()
}()
// get registry
reg, ok := h.opts.Context.Value(registryKey).(registry.Registry)
if !ok {
reg = registry.DefaultRegistry
}
// set rcache
h.r = rcache.New(reg)
// set running
h.running = true
return nil
}
func (h *httpBroker) Disconnect() error {
h.RLock()
if !h.running {
h.RUnlock()
return nil
}
h.RUnlock()
h.Lock()
defer h.Unlock()
// stop rcache
rc, ok := h.r.(rcache.Cache)
if ok {
rc.Stop()
}
// exit and return err
ch := make(chan error)
h.exit <- ch
err := <-ch
// set not running
h.running = false
return err
}
func (h *httpBroker) Init(opts ...Option) error {
h.RLock()
if h.running {
h.RUnlock()
return errors.New("cannot init while connected")
}
h.RUnlock()
h.Lock()
defer h.Unlock()
for _, o := range opts {
o(&h.opts)
}
if len(h.opts.Addrs) > 0 && len(h.opts.Addrs[0]) > 0 {
h.address = h.opts.Addrs[0]
}
if len(h.id) == 0 {
h.id = "broker-" + uuid.New().String()
}
// get registry
reg, ok := h.opts.Context.Value(registryKey).(registry.Registry)
if !ok {
reg = registry.DefaultRegistry
}
// get rcache
if rc, ok := h.r.(rcache.Cache); ok {
rc.Stop()
}
// set registry
h.r = rcache.New(reg)
// reconfigure tls config
if c := h.opts.TLSConfig; c != nil {
h.c = &http.Client{
Transport: newTransport(c),
}
}
return nil
}
func (h *httpBroker) Options() Options {
return h.opts
}
func (h *httpBroker) Publish(topic string, msg *Message, opts ...PublishOption) error {
// create the message first
m := &Message{
Header: make(map[string]string),
Body: msg.Body,
}
for k, v := range msg.Header {
m.Header[k] = v
}
m.Header[":topic"] = topic
// encode the message
b, err := h.opts.Codec.Marshal(m)
if err != nil {
return err
}
// save the message
h.saveMessage(topic, b)
// now attempt to get the service
h.RLock()
s, err := h.r.GetService("topic:" + topic)
if err != nil {
h.RUnlock()
// ignore error
return nil
}
h.RUnlock()
pub := func(node *registry.Node, t string, b []byte) error {
scheme := "http"
// check if secure is added in metadata
if node.Metadata["secure"] == "true" {
scheme = "https"
}
vals := url.Values{}
vals.Add("id", node.Id)
uri := fmt.Sprintf("%s://%s:%d%s?%s", scheme, node.Address, node.Port, DefaultSubPath, vals.Encode())
r, err := h.c.Post(uri, "application/json", bytes.NewReader(b))
if err != nil {
return err
}
// discard response body
io.Copy(ioutil.Discard, r.Body)
r.Body.Close()
return nil
}
srv := func(s []*registry.Service, b []byte) {
for _, service := range s {
// only process if we have nodes
if len(service.Nodes) == 0 {
continue
}
switch service.Version {
// broadcast version means broadcast to all nodes
case broadcastVersion:
var success bool
// publish to all nodes
for _, node := range service.Nodes {
// publish async
if err := pub(node, topic, b); err == nil {
success = true
}
}
// save if it failed to publish at least once
if !success {
h.saveMessage(topic, b)
}
default:
// select node to publish to
node := service.Nodes[rand.Int()%len(service.Nodes)]
// publish async to one node
if err := pub(node, topic, b); err != nil {
// if failed save it
h.saveMessage(topic, b)
}
}
}
}
// do the rest async
go func() {
// get a third of the backlog
messages := h.getMessage(topic, 8)
delay := (len(messages) > 1)
// publish all the messages
for _, msg := range messages {
// serialize here
srv(s, msg)
// sending a backlog of messages
if delay {
time.Sleep(time.Millisecond * 100)
}
}
}()
return nil
}
func (h *httpBroker) Subscribe(topic string, handler Handler, opts ...SubscribeOption) (Subscriber, error) {
options := NewSubscribeOptions(opts...)
// parse address for host, port
parts := strings.Split(h.Address(), ":")
host := strings.Join(parts[:len(parts)-1], ":")
port, _ := strconv.Atoi(parts[len(parts)-1])
addr, err := maddr.Extract(host)
if err != nil {
return nil, err
}
// create unique id
id := h.id + "." + uuid.New().String()
var secure bool
if h.opts.Secure || h.opts.TLSConfig != nil {
secure = true
}
// register service
node := &registry.Node{
Id: id,
Address: addr,
Port: port,
Metadata: map[string]string{
"secure": fmt.Sprintf("%t", secure),
},
}
// check for queue group or broadcast queue
version := options.Queue
if len(version) == 0 {
version = broadcastVersion
}
service := &registry.Service{
Name: "topic:" + topic,
Version: version,
Nodes: []*registry.Node{node},
}
// generate subscriber
subscriber := &httpSubscriber{
opts: options,
hb: h,
id: id,
topic: topic,
fn: handler,
svc: service,
}
// subscribe now
if err := h.subscribe(subscriber); err != nil {
return nil, err
}
// return the subscriber
return subscriber, nil
}
func (h *httpBroker) String() string {
return "http"
}

View File

@@ -1,351 +0,0 @@
package broker
import (
"sync"
"testing"
"time"
glog "github.com/go-log/log"
"github.com/google/uuid"
"github.com/micro/go-log"
"github.com/micro/go-micro/registry/memory"
)
func newTestRegistry() *memory.Registry {
r := memory.NewRegistry()
m := r.(*memory.Registry)
m.Setup()
return m
}
func sub(be *testing.B, c int) {
// set no op logger
log.SetLogger(glog.DefaultLogger)
be.StopTimer()
m := newTestRegistry()
b := NewBroker(Registry(m))
topic := uuid.New().String()
if err := b.Init(); err != nil {
be.Fatalf("Unexpected init error: %v", err)
}
if err := b.Connect(); err != nil {
be.Fatalf("Unexpected connect error: %v", err)
}
msg := &Message{
Header: map[string]string{
"Content-Type": "application/json",
},
Body: []byte(`{"message": "Hello World"}`),
}
var subs []Subscriber
done := make(chan bool, c)
for i := 0; i < c; i++ {
sub, err := b.Subscribe(topic, func(p Publication) error {
done <- true
m := p.Message()
if string(m.Body) != string(msg.Body) {
be.Fatalf("Unexpected msg %s, expected %s", string(m.Body), string(msg.Body))
}
return nil
}, Queue("shared"))
if err != nil {
be.Fatalf("Unexpected subscribe error: %v", err)
}
subs = append(subs, sub)
}
for i := 0; i < be.N; i++ {
be.StartTimer()
if err := b.Publish(topic, msg); err != nil {
be.Fatalf("Unexpected publish error: %v", err)
}
<-done
be.StopTimer()
}
for _, sub := range subs {
sub.Unsubscribe()
}
if err := b.Disconnect(); err != nil {
be.Fatalf("Unexpected disconnect error: %v", err)
}
}
func pub(be *testing.B, c int) {
// set no op logger
log.SetLogger(glog.DefaultLogger)
be.StopTimer()
m := newTestRegistry()
b := NewBroker(Registry(m))
topic := uuid.New().String()
if err := b.Init(); err != nil {
be.Fatalf("Unexpected init error: %v", err)
}
if err := b.Connect(); err != nil {
be.Fatalf("Unexpected connect error: %v", err)
}
msg := &Message{
Header: map[string]string{
"Content-Type": "application/json",
},
Body: []byte(`{"message": "Hello World"}`),
}
done := make(chan bool, c*4)
sub, err := b.Subscribe(topic, func(p Publication) error {
done <- true
m := p.Message()
if string(m.Body) != string(msg.Body) {
be.Fatalf("Unexpected msg %s, expected %s", string(m.Body), string(msg.Body))
}
return nil
}, Queue("shared"))
if err != nil {
be.Fatalf("Unexpected subscribe error: %v", err)
}
var wg sync.WaitGroup
ch := make(chan int, c*4)
be.StartTimer()
for i := 0; i < c; i++ {
go func() {
for _ = range ch {
if err := b.Publish(topic, msg); err != nil {
be.Fatalf("Unexpected publish error: %v", err)
}
select {
case <-done:
case <-time.After(time.Second):
}
wg.Done()
}
}()
}
for i := 0; i < be.N; i++ {
wg.Add(1)
ch <- i
}
wg.Wait()
be.StopTimer()
sub.Unsubscribe()
close(ch)
close(done)
if err := b.Disconnect(); err != nil {
be.Fatalf("Unexpected disconnect error: %v", err)
}
}
func TestBroker(t *testing.T) {
m := newTestRegistry()
b := NewBroker(Registry(m))
if err := b.Init(); err != nil {
t.Fatalf("Unexpected init error: %v", err)
}
if err := b.Connect(); err != nil {
t.Fatalf("Unexpected connect error: %v", err)
}
msg := &Message{
Header: map[string]string{
"Content-Type": "application/json",
},
Body: []byte(`{"message": "Hello World"}`),
}
done := make(chan bool)
sub, err := b.Subscribe("test", func(p Publication) error {
m := p.Message()
if string(m.Body) != string(msg.Body) {
t.Fatalf("Unexpected msg %s, expected %s", string(m.Body), string(msg.Body))
}
close(done)
return nil
})
if err != nil {
t.Fatalf("Unexpected subscribe error: %v", err)
}
if err := b.Publish("test", msg); err != nil {
t.Fatalf("Unexpected publish error: %v", err)
}
<-done
sub.Unsubscribe()
if err := b.Disconnect(); err != nil {
t.Fatalf("Unexpected disconnect error: %v", err)
}
}
func TestConcurrentSubBroker(t *testing.T) {
m := newTestRegistry()
b := NewBroker(Registry(m))
if err := b.Init(); err != nil {
t.Fatalf("Unexpected init error: %v", err)
}
if err := b.Connect(); err != nil {
t.Fatalf("Unexpected connect error: %v", err)
}
msg := &Message{
Header: map[string]string{
"Content-Type": "application/json",
},
Body: []byte(`{"message": "Hello World"}`),
}
var subs []Subscriber
var wg sync.WaitGroup
for i := 0; i < 10; i++ {
sub, err := b.Subscribe("test", func(p Publication) error {
defer wg.Done()
m := p.Message()
if string(m.Body) != string(msg.Body) {
t.Fatalf("Unexpected msg %s, expected %s", string(m.Body), string(msg.Body))
}
return nil
})
if err != nil {
t.Fatalf("Unexpected subscribe error: %v", err)
}
wg.Add(1)
subs = append(subs, sub)
}
if err := b.Publish("test", msg); err != nil {
t.Fatalf("Unexpected publish error: %v", err)
}
wg.Wait()
for _, sub := range subs {
sub.Unsubscribe()
}
if err := b.Disconnect(); err != nil {
t.Fatalf("Unexpected disconnect error: %v", err)
}
}
func TestConcurrentPubBroker(t *testing.T) {
m := newTestRegistry()
b := NewBroker(Registry(m))
if err := b.Init(); err != nil {
t.Fatalf("Unexpected init error: %v", err)
}
if err := b.Connect(); err != nil {
t.Fatalf("Unexpected connect error: %v", err)
}
msg := &Message{
Header: map[string]string{
"Content-Type": "application/json",
},
Body: []byte(`{"message": "Hello World"}`),
}
var wg sync.WaitGroup
sub, err := b.Subscribe("test", func(p Publication) error {
defer wg.Done()
m := p.Message()
if string(m.Body) != string(msg.Body) {
t.Fatalf("Unexpected msg %s, expected %s", string(m.Body), string(msg.Body))
}
return nil
})
if err != nil {
t.Fatalf("Unexpected subscribe error: %v", err)
}
for i := 0; i < 10; i++ {
wg.Add(1)
if err := b.Publish("test", msg); err != nil {
t.Fatalf("Unexpected publish error: %v", err)
}
}
wg.Wait()
sub.Unsubscribe()
if err := b.Disconnect(); err != nil {
t.Fatalf("Unexpected disconnect error: %v", err)
}
}
func BenchmarkSub1(b *testing.B) {
sub(b, 1)
}
func BenchmarkSub8(b *testing.B) {
sub(b, 8)
}
func BenchmarkSub32(b *testing.B) {
sub(b, 32)
}
func BenchmarkSub64(b *testing.B) {
sub(b, 64)
}
func BenchmarkSub128(b *testing.B) {
sub(b, 128)
}
func BenchmarkPub1(b *testing.B) {
pub(b, 1)
}
func BenchmarkPub8(b *testing.B) {
pub(b, 8)
}
func BenchmarkPub32(b *testing.B) {
pub(b, 32)
}
func BenchmarkPub64(b *testing.B) {
pub(b, 64)
}
func BenchmarkPub128(b *testing.B) {
pub(b, 128)
}

View File

@@ -1,33 +1,46 @@
// Package memory provides a memory broker
package memory
package broker
import (
"errors"
"context"
"sync"
"github.com/google/uuid"
"github.com/micro/go-micro/broker"
"go.unistack.org/micro/v3/broker"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/metadata"
"go.unistack.org/micro/v3/options"
maddr "go.unistack.org/micro/v3/util/addr"
"go.unistack.org/micro/v3/util/id"
mnet "go.unistack.org/micro/v3/util/net"
"go.unistack.org/micro/v3/util/rand"
)
type memoryBroker struct {
opts broker.Options
funcPublish broker.FuncPublish
funcBatchPublish broker.FuncBatchPublish
funcSubscribe broker.FuncSubscribe
funcBatchSubscribe broker.FuncBatchSubscribe
subscribers map[string][]*memorySubscriber
addr string
opts broker.Options
sync.RWMutex
connected bool
Subscribers map[string][]*memorySubscriber
connected bool
}
type memoryPublication struct {
type memoryEvent struct {
err error
message interface{}
topic string
message *broker.Message
opts broker.Options
}
type memorySubscriber struct {
id string
topic string
exit chan bool
handler broker.Handler
opts broker.SubscribeOptions
ctx context.Context
exit chan bool
handler broker.Handler
batchhandler broker.BatchHandler
id string
topic string
opts broker.SubscribeOptions
}
func (m *memoryBroker) Options() broker.Options {
@@ -35,10 +48,16 @@ func (m *memoryBroker) Options() broker.Options {
}
func (m *memoryBroker) Address() string {
return ""
return m.addr
}
func (m *memoryBroker) Connect() error {
func (m *memoryBroker) Connect(ctx context.Context) error {
select {
case <-ctx.Done():
return ctx.Err()
default:
}
m.Lock()
defer m.Unlock()
@@ -46,12 +65,29 @@ func (m *memoryBroker) Connect() error {
return nil
}
// use 127.0.0.1 to avoid scan of all network interfaces
addr, err := maddr.Extract("127.0.0.1")
if err != nil {
return err
}
var rng rand.Rand
i := rng.Intn(20000)
// set addr with port
addr = mnet.HostPort(addr, 10000+i)
m.addr = addr
m.connected = true
return nil
}
func (m *memoryBroker) Disconnect() error {
func (m *memoryBroker) Disconnect(ctx context.Context) error {
select {
case <-ctx.Done():
return ctx.Err()
default:
}
m.Lock()
defer m.Unlock()
@@ -60,7 +96,6 @@ func (m *memoryBroker) Disconnect() error {
}
m.connected = false
return nil
}
@@ -68,70 +103,228 @@ func (m *memoryBroker) Init(opts ...broker.Option) error {
for _, o := range opts {
o(&m.opts)
}
m.funcPublish = m.fnPublish
m.funcBatchPublish = m.fnBatchPublish
m.funcSubscribe = m.fnSubscribe
m.funcBatchSubscribe = m.fnBatchSubscribe
m.opts.Hooks.EachPrev(func(hook options.Hook) {
switch h := hook.(type) {
case broker.HookPublish:
m.funcPublish = h(m.funcPublish)
case broker.HookBatchPublish:
m.funcBatchPublish = h(m.funcBatchPublish)
case broker.HookSubscribe:
m.funcSubscribe = h(m.funcSubscribe)
case broker.HookBatchSubscribe:
m.funcBatchSubscribe = h(m.funcBatchSubscribe)
}
})
return nil
}
func (m *memoryBroker) Publish(topic string, message *broker.Message, opts ...broker.PublishOption) error {
m.Lock()
defer m.Unlock()
func (m *memoryBroker) Publish(ctx context.Context, topic string, msg *broker.Message, opts ...broker.PublishOption) error {
return m.funcPublish(ctx, topic, msg, opts...)
}
func (m *memoryBroker) fnPublish(ctx context.Context, topic string, msg *broker.Message, opts ...broker.PublishOption) error {
msg.Header.Set(metadata.HeaderTopic, topic)
return m.publish(ctx, []*broker.Message{msg}, opts...)
}
func (m *memoryBroker) BatchPublish(ctx context.Context, msgs []*broker.Message, opts ...broker.PublishOption) error {
return m.funcBatchPublish(ctx, msgs, opts...)
}
func (m *memoryBroker) fnBatchPublish(ctx context.Context, msgs []*broker.Message, opts ...broker.PublishOption) error {
return m.publish(ctx, msgs, opts...)
}
func (m *memoryBroker) publish(ctx context.Context, msgs []*broker.Message, opts ...broker.PublishOption) error {
m.RLock()
if !m.connected {
return errors.New("not connected")
m.RUnlock()
return broker.ErrNotConnected
}
m.RUnlock()
subs, ok := m.Subscribers[topic]
if !ok {
return nil
}
var err error
p := &memoryPublication{
topic: topic,
message: message,
}
select {
case <-ctx.Done():
return ctx.Err()
default:
options := broker.NewPublishOptions(opts...)
for _, sub := range subs {
if err := sub.handler(p); err != nil {
return err
msgTopicMap := make(map[string]broker.Events)
for _, v := range msgs {
p := &memoryEvent{opts: m.opts}
if m.opts.Codec == nil || options.BodyOnly {
p.topic, _ = v.Header.Get(metadata.HeaderTopic)
p.message = v.Body
} else {
p.topic, _ = v.Header.Get(metadata.HeaderTopic)
p.message, err = m.opts.Codec.Marshal(v)
if err != nil {
return err
}
}
msgTopicMap[p.topic] = append(msgTopicMap[p.topic], p)
}
beh := m.opts.BatchErrorHandler
eh := m.opts.ErrorHandler
for t, ms := range msgTopicMap {
m.RLock()
subs, ok := m.subscribers[t]
m.RUnlock()
if !ok {
continue
}
for _, sub := range subs {
if sub.opts.BatchErrorHandler != nil {
beh = sub.opts.BatchErrorHandler
}
if sub.opts.ErrorHandler != nil {
eh = sub.opts.ErrorHandler
}
switch {
// batch processing
case sub.batchhandler != nil:
if err = sub.batchhandler(ms); err != nil {
ms.SetError(err)
if beh != nil {
_ = beh(ms)
} else if m.opts.Logger.V(logger.ErrorLevel) {
m.opts.Logger.Error(m.opts.Context, err.Error())
}
} else if sub.opts.AutoAck {
if err = ms.Ack(); err != nil {
m.opts.Logger.Error(m.opts.Context, "broker ack error", err)
}
}
// single processing
case sub.handler != nil:
for _, p := range ms {
if err = sub.handler(p); err != nil {
p.SetError(err)
if eh != nil {
_ = eh(p)
} else if m.opts.Logger.V(logger.ErrorLevel) {
m.opts.Logger.Error(m.opts.Context, "broker handler error", err)
}
} else if sub.opts.AutoAck {
if err = p.Ack(); err != nil {
m.opts.Logger.Error(m.opts.Context, "broker ack error", err)
}
}
}
}
}
}
}
return nil
}
func (m *memoryBroker) Subscribe(topic string, handler broker.Handler, opts ...broker.SubscribeOption) (broker.Subscriber, error) {
m.Lock()
defer m.Unlock()
func (m *memoryBroker) BatchSubscribe(ctx context.Context, topic string, handler broker.BatchHandler, opts ...broker.SubscribeOption) (broker.Subscriber, error) {
return m.funcBatchSubscribe(ctx, topic, handler, opts...)
}
func (m *memoryBroker) fnBatchSubscribe(ctx context.Context, topic string, handler broker.BatchHandler, opts ...broker.SubscribeOption) (broker.Subscriber, error) {
m.RLock()
if !m.connected {
return nil, errors.New("not connected")
m.RUnlock()
return nil, broker.ErrNotConnected
}
m.RUnlock()
sid, err := id.New()
if err != nil {
return nil, err
}
var options broker.SubscribeOptions
for _, o := range opts {
o(&options)
}
options := broker.NewSubscribeOptions(opts...)
sub := &memorySubscriber{
exit: make(chan bool, 1),
id: uuid.New().String(),
topic: topic,
handler: handler,
opts: options,
exit: make(chan bool, 1),
id: sid,
topic: topic,
batchhandler: handler,
opts: options,
ctx: ctx,
}
m.Subscribers[topic] = append(m.Subscribers[topic], sub)
m.Lock()
m.subscribers[topic] = append(m.subscribers[topic], sub)
m.Unlock()
go func() {
<-sub.exit
m.Lock()
var newSubscribers []*memorySubscriber
for _, sb := range m.Subscribers[topic] {
newSubscribers := make([]*memorySubscriber, 0, len(m.subscribers)-1)
for _, sb := range m.subscribers[topic] {
if sb.id == sub.id {
continue
}
newSubscribers = append(newSubscribers, sb)
}
m.Subscribers[topic] = newSubscribers
m.subscribers[topic] = newSubscribers
m.Unlock()
}()
return sub, nil
}
func (m *memoryBroker) Subscribe(ctx context.Context, topic string, handler broker.Handler, opts ...broker.SubscribeOption) (broker.Subscriber, error) {
return m.funcSubscribe(ctx, topic, handler, opts...)
}
func (m *memoryBroker) fnSubscribe(ctx context.Context, topic string, handler broker.Handler, opts ...broker.SubscribeOption) (broker.Subscriber, error) {
m.RLock()
if !m.connected {
m.RUnlock()
return nil, broker.ErrNotConnected
}
m.RUnlock()
sid, err := id.New()
if err != nil {
return nil, err
}
options := broker.NewSubscribeOptions(opts...)
sub := &memorySubscriber{
exit: make(chan bool, 1),
id: sid,
topic: topic,
handler: handler,
opts: options,
ctx: ctx,
}
m.Lock()
m.subscribers[topic] = append(m.subscribers[topic], sub)
m.Unlock()
go func() {
<-sub.exit
m.Lock()
newSubscribers := make([]*memorySubscriber, 0, len(m.subscribers)-1)
for _, sb := range m.subscribers[topic] {
if sb.id == sub.id {
continue
}
newSubscribers = append(newSubscribers, sb)
}
m.subscribers[topic] = newSubscribers
m.Unlock()
}()
@@ -142,18 +335,60 @@ func (m *memoryBroker) String() string {
return "memory"
}
func (m *memoryPublication) Topic() string {
func (m *memoryBroker) Name() string {
return m.opts.Name
}
func (m *memoryBroker) Live() bool {
return true
}
func (m *memoryBroker) Ready() bool {
return true
}
func (m *memoryBroker) Health() bool {
return true
}
func (m *memoryEvent) Topic() string {
return m.topic
}
func (m *memoryPublication) Message() *broker.Message {
return m.message
func (m *memoryEvent) Message() *broker.Message {
switch v := m.message.(type) {
case *broker.Message:
return v
case []byte:
msg := &broker.Message{}
if err := m.opts.Codec.Unmarshal(v, msg); err != nil {
if m.opts.Logger.V(logger.ErrorLevel) {
m.opts.Logger.Error(m.opts.Context, "[memory]: failed to unmarshal: %v", err)
}
return nil
}
return msg
}
return nil
}
func (m *memoryPublication) Ack() error {
func (m *memoryEvent) Ack() error {
return nil
}
func (m *memoryEvent) Error() error {
return m.err
}
func (m *memoryEvent) SetError(err error) {
m.err = err
}
func (m *memoryEvent) Context() context.Context {
return m.opts.Context
}
func (m *memorySubscriber) Options() broker.SubscribeOptions {
return m.opts
}
@@ -162,19 +397,15 @@ func (m *memorySubscriber) Topic() string {
return m.topic
}
func (m *memorySubscriber) Unsubscribe() error {
func (m *memorySubscriber) Unsubscribe(ctx context.Context) error {
m.exit <- true
return nil
}
// NewBroker return new memory broker
func NewBroker(opts ...broker.Option) broker.Broker {
var options broker.Options
for _, o := range opts {
o(&options)
}
return &memoryBroker{
opts: options,
Subscribers: make(map[string][]*memorySubscriber),
opts: broker.NewOptions(opts...),
subscribers: make(map[string][]*memorySubscriber),
}
}

View File

@@ -1,50 +1,114 @@
package memory
package broker
import (
"context"
"fmt"
"testing"
"github.com/micro/go-micro/broker"
"go.unistack.org/micro/v3/broker"
"go.unistack.org/micro/v3/metadata"
)
func TestMemoryBroker(t *testing.T) {
func TestMemoryBatchBroker(t *testing.T) {
b := NewBroker()
ctx := context.Background()
if err := b.Connect(); err != nil {
if err := b.Init(); err != nil {
t.Fatalf("Unexpected init error %v", err)
}
if err := b.Connect(ctx); err != nil {
t.Fatalf("Unexpected connect error %v", err)
}
topic := "test"
count := 10
fn := func(p broker.Publication) error {
return nil
fn := func(evts broker.Events) error {
return evts.Ack()
}
sub, err := b.Subscribe(topic, fn)
sub, err := b.BatchSubscribe(ctx, topic, fn)
if err != nil {
t.Fatalf("Unexpected error subscribing %v", err)
}
msgs := make([]*broker.Message, 0, count)
for i := 0; i < count; i++ {
message := &broker.Message{
Header: map[string]string{
"foo": "bar",
"id": fmt.Sprintf("%d", i),
metadata.HeaderTopic: topic,
"foo": "bar",
"id": fmt.Sprintf("%d", i),
},
Body: []byte(`hello world`),
}
if err := b.Publish(topic, message); err != nil {
t.Fatalf("Unexpected error publishing %d", i)
Body: []byte(`"hello world"`),
}
msgs = append(msgs, message)
}
if err := sub.Unsubscribe(); err != nil {
if err := b.BatchPublish(ctx, msgs); err != nil {
t.Fatalf("Unexpected error publishing %v", err)
}
if err := sub.Unsubscribe(ctx); err != nil {
t.Fatalf("Unexpected error unsubscribing from %s: %v", topic, err)
}
if err := b.Disconnect(); err != nil {
if err := b.Disconnect(ctx); err != nil {
t.Fatalf("Unexpected connect error %v", err)
}
}
func TestMemoryBroker(t *testing.T) {
b := NewBroker()
ctx := context.Background()
if err := b.Init(); err != nil {
t.Fatalf("Unexpected init error %v", err)
}
if err := b.Connect(ctx); err != nil {
t.Fatalf("Unexpected connect error %v", err)
}
topic := "test"
count := 10
fn := func(_ broker.Event) error {
return nil
}
sub, err := b.Subscribe(ctx, topic, fn)
if err != nil {
t.Fatalf("Unexpected error subscribing %v", err)
}
msgs := make([]*broker.Message, 0, count)
for i := 0; i < count; i++ {
message := &broker.Message{
Header: map[string]string{
metadata.HeaderTopic: topic,
"foo": "bar",
"id": fmt.Sprintf("%d", i),
},
Body: []byte(`"hello world"`),
}
msgs = append(msgs, message)
if err := b.Publish(ctx, topic, message); err != nil {
t.Fatalf("Unexpected error publishing %d err: %v", i, err)
}
}
if err := b.BatchPublish(ctx, msgs); err != nil {
t.Fatalf("Unexpected error publishing %v", err)
}
if err := sub.Unsubscribe(ctx); err != nil {
t.Fatalf("Unexpected error unsubscribing from %s: %v", topic, err)
}
if err := b.Disconnect(ctx); err != nil {
t.Fatalf("Unexpected connect error %v", err)
}
}

140
broker/noop.go Normal file
View File

@@ -0,0 +1,140 @@
package broker
import (
"context"
"strings"
"go.unistack.org/micro/v3/options"
)
type NoopBroker struct {
funcPublish FuncPublish
funcBatchPublish FuncBatchPublish
funcSubscribe FuncSubscribe
funcBatchSubscribe FuncBatchSubscribe
opts Options
}
func NewBroker(opts ...Option) *NoopBroker {
b := &NoopBroker{opts: NewOptions(opts...)}
b.funcPublish = b.fnPublish
b.funcBatchPublish = b.fnBatchPublish
b.funcSubscribe = b.fnSubscribe
b.funcBatchSubscribe = b.fnBatchSubscribe
return b
}
func (b *NoopBroker) Health() bool {
return true
}
func (b *NoopBroker) Live() bool {
return true
}
func (b *NoopBroker) Ready() bool {
return true
}
func (b *NoopBroker) Name() string {
return b.opts.Name
}
func (b *NoopBroker) String() string {
return "noop"
}
func (b *NoopBroker) Options() Options {
return b.opts
}
func (b *NoopBroker) Init(opts ...Option) error {
for _, opt := range opts {
opt(&b.opts)
}
b.funcPublish = b.fnPublish
b.funcBatchPublish = b.fnBatchPublish
b.funcSubscribe = b.fnSubscribe
b.funcBatchSubscribe = b.fnBatchSubscribe
b.opts.Hooks.EachPrev(func(hook options.Hook) {
switch h := hook.(type) {
case HookPublish:
b.funcPublish = h(b.funcPublish)
case HookBatchPublish:
b.funcBatchPublish = h(b.funcBatchPublish)
case HookSubscribe:
b.funcSubscribe = h(b.funcSubscribe)
case HookBatchSubscribe:
b.funcBatchSubscribe = h(b.funcBatchSubscribe)
}
})
return nil
}
func (b *NoopBroker) Connect(_ context.Context) error {
return nil
}
func (b *NoopBroker) Disconnect(_ context.Context) error {
return nil
}
func (b *NoopBroker) Address() string {
return strings.Join(b.opts.Addrs, ",")
}
func (b *NoopBroker) fnBatchPublish(_ context.Context, _ []*Message, _ ...PublishOption) error {
return nil
}
func (b *NoopBroker) BatchPublish(ctx context.Context, msgs []*Message, opts ...PublishOption) error {
return b.funcBatchPublish(ctx, msgs, opts...)
}
func (b *NoopBroker) fnPublish(_ context.Context, _ string, _ *Message, _ ...PublishOption) error {
return nil
}
func (b *NoopBroker) Publish(ctx context.Context, topic string, msg *Message, opts ...PublishOption) error {
return b.funcPublish(ctx, topic, msg, opts...)
}
type NoopSubscriber struct {
ctx context.Context
topic string
handler Handler
batchHandler BatchHandler
opts SubscribeOptions
}
func (b *NoopBroker) fnBatchSubscribe(ctx context.Context, topic string, handler BatchHandler, opts ...SubscribeOption) (Subscriber, error) {
return &NoopSubscriber{ctx: ctx, topic: topic, opts: NewSubscribeOptions(opts...), batchHandler: handler}, nil
}
func (b *NoopBroker) BatchSubscribe(ctx context.Context, topic string, handler BatchHandler, opts ...SubscribeOption) (Subscriber, error) {
return b.funcBatchSubscribe(ctx, topic, handler, opts...)
}
func (b *NoopBroker) fnSubscribe(ctx context.Context, topic string, handler Handler, opts ...SubscribeOption) (Subscriber, error) {
return &NoopSubscriber{ctx: ctx, topic: topic, opts: NewSubscribeOptions(opts...), handler: handler}, nil
}
func (b *NoopBroker) Subscribe(ctx context.Context, topic string, handler Handler, opts ...SubscribeOption) (Subscriber, error) {
return b.funcSubscribe(ctx, topic, handler, opts...)
}
func (s *NoopSubscriber) Options() SubscribeOptions {
return s.opts
}
func (s *NoopSubscriber) Topic() string {
return s.topic
}
func (s *NoopSubscriber) Unsubscribe(_ context.Context) error {
return nil
}

35
broker/noop_test.go Normal file
View File

@@ -0,0 +1,35 @@
package broker
import (
"context"
"testing"
)
type testHook struct {
f bool
}
func (t *testHook) Publish1(fn FuncPublish) FuncPublish {
return func(ctx context.Context, topic string, msg *Message, opts ...PublishOption) error {
t.f = true
return fn(ctx, topic, msg, opts...)
}
}
func TestNoopHook(t *testing.T) {
h := &testHook{}
b := NewBroker(Hooks(HookPublish(h.Publish1)))
if err := b.Init(); err != nil {
t.Fatal(err)
}
if err := b.Publish(context.TODO(), "", nil); err != nil {
t.Fatal(err)
}
if !h.f {
t.Fatal("hook not works")
}
}

View File

@@ -3,63 +3,136 @@ package broker
import (
"context"
"crypto/tls"
"time"
"github.com/micro/go-micro/codec"
"github.com/micro/go-micro/registry"
"go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/meter"
"go.unistack.org/micro/v3/options"
"go.unistack.org/micro/v3/register"
"go.unistack.org/micro/v3/sync"
"go.unistack.org/micro/v3/tracer"
)
// Options struct
type Options struct {
Addrs []string
Secure bool
Codec codec.Marshaler
// Name holds the broker name
Name string
// Tracer used for tracing
Tracer tracer.Tracer
// Register can be used for clustering
Register register.Register
// Codec holds the codec for marshal/unmarshal
Codec codec.Codec
// Logger used for logging
Logger logger.Logger
// Meter used for metrics
Meter meter.Meter
// Context holds external options
Context context.Context
// Wait waits for a collection of goroutines to finish
Wait *sync.WaitGroup
// TLSConfig holds tls.TLSConfig options
TLSConfig *tls.Config
// Other options for implementations of the interface
// can be stored in a context
Context context.Context
// ErrorHandler used when broker can't unmarshal incoming message
ErrorHandler Handler
// BatchErrorHandler used when broker can't unmashal incoming messages
BatchErrorHandler BatchHandler
// Addrs holds the broker address
Addrs []string
// Hooks can be run before broker Publish/BatchPublish and
// Subscribe/BatchSubscribe methods
Hooks options.Hooks
// GracefulTimeout contains time to wait to finish in flight requests
GracefulTimeout time.Duration
}
// NewOptions create new Options
func NewOptions(opts ...Option) Options {
options := Options{
Register: register.DefaultRegister,
Logger: logger.DefaultLogger,
Context: context.Background(),
Meter: meter.DefaultMeter,
Codec: codec.DefaultCodec,
Tracer: tracer.DefaultTracer,
GracefulTimeout: DefaultGracefulTimeout,
}
for _, o := range opts {
o(&options)
}
return options
}
// Context sets the context option
func Context(ctx context.Context) Option {
return func(o *Options) {
o.Context = ctx
}
}
// PublishOptions struct
type PublishOptions struct {
// Other options for implementations of the interface
// can be stored in a context
// Context holds external options
Context context.Context
// BodyOnly flag says the message contains raw body bytes
BodyOnly bool
}
// NewPublishOptions creates PublishOptions struct
func NewPublishOptions(opts ...PublishOption) PublishOptions {
options := PublishOptions{
Context: context.Background(),
}
for _, o := range opts {
o(&options)
}
return options
}
// SubscribeOptions struct
type SubscribeOptions struct {
// AutoAck defaults to true. When a handler returns
// with a nil error the message is acked.
AutoAck bool
// Subscribers with the same queue name
// will create a shared subscription where each
// receives a subset of messages.
Queue string
// Other options for implementations of the interface
// can be stored in a context
// Context holds external options
Context context.Context
// ErrorHandler used when broker can't unmarshal incoming message
ErrorHandler Handler
// BatchErrorHandler used when broker can't unmashal incoming messages
BatchErrorHandler BatchHandler
// Group holds consumer group
Group string
// AutoAck flag specifies auto ack of incoming message when no error happens
AutoAck bool
// BodyOnly flag specifies that message contains only body bytes without header
BodyOnly bool
// BatchSize flag specifies max batch size
BatchSize int
// BatchWait flag specifies max wait time for batch filling
BatchWait time.Duration
}
// Option func
type Option func(*Options)
// PublishOption func
type PublishOption func(*PublishOptions)
type SubscribeOption func(*SubscribeOptions)
type contextKeyT string
var (
registryKey = contextKeyT("github.com/micro/go-micro/registry")
)
func NewSubscribeOptions(opts ...SubscribeOption) SubscribeOptions {
opt := SubscribeOptions{
AutoAck: true,
// PublishBodyOnly publish only body of the message
func PublishBodyOnly(b bool) PublishOption {
return func(o *PublishOptions) {
o.BodyOnly = b
}
}
for _, o := range opts {
o(&opt)
// PublishContext sets the context
func PublishContext(ctx context.Context) PublishOption {
return func(o *PublishOptions) {
o.Context = ctx
}
return opt
}
// Addrs sets the host addresses to be used by the broker
@@ -71,50 +144,163 @@ func Addrs(addrs ...string) Option {
// Codec sets the codec used for encoding/decoding used where
// a broker does not support headers
func Codec(c codec.Marshaler) Option {
func Codec(c codec.Codec) Option {
return func(o *Options) {
o.Codec = c
}
}
// DisableAutoAck will disable auto acking of messages
// after they have been handled.
func DisableAutoAck() SubscribeOption {
return func(o *SubscribeOptions) {
o.AutoAck = false
// ErrorHandler will catch all broker errors that cant be handled
// in normal way, for example Codec errors
func ErrorHandler(h Handler) Option {
return func(o *Options) {
o.ErrorHandler = h
}
}
// Queue sets the name of the queue to share messages on
// BatchErrorHandler will catch all broker errors that cant be handled
// in normal way, for example Codec errors
func BatchErrorHandler(h BatchHandler) Option {
return func(o *Options) {
o.BatchErrorHandler = h
}
}
// SubscribeErrorHandler will catch all broker errors that cant be handled
// in normal way, for example Codec errors
func SubscribeErrorHandler(h Handler) SubscribeOption {
return func(o *SubscribeOptions) {
o.ErrorHandler = h
}
}
// SubscribeBatchErrorHandler will catch all broker errors that cant be handled
// in normal way, for example Codec errors
func SubscribeBatchErrorHandler(h BatchHandler) SubscribeOption {
return func(o *SubscribeOptions) {
o.BatchErrorHandler = h
}
}
// Queue sets the subscribers queue
// Deprecated
func Queue(name string) SubscribeOption {
return func(o *SubscribeOptions) {
o.Queue = name
o.Group = name
}
}
func Registry(r registry.Registry) Option {
// SubscribeGroup sets the name of the queue to share messages on
func SubscribeGroup(name string) SubscribeOption {
return func(o *SubscribeOptions) {
o.Group = name
}
}
// Register sets register option
func Register(r register.Register) Option {
return func(o *Options) {
o.Context = context.WithValue(o.Context, registryKey, r)
o.Register = r
}
}
// Secure communication with the broker
func Secure(b bool) Option {
return func(o *Options) {
o.Secure = b
}
}
// Specify TLS Config
// TLSConfig sets the TLS Config
func TLSConfig(t *tls.Config) Option {
return func(o *Options) {
o.TLSConfig = t
}
}
// Logger sets the logger
func Logger(l logger.Logger) Option {
return func(o *Options) {
o.Logger = l
}
}
// Tracer to be used for tracing
func Tracer(t tracer.Tracer) Option {
return func(o *Options) {
o.Tracer = t
}
}
// Meter sets the meter
func Meter(m meter.Meter) Option {
return func(o *Options) {
o.Meter = m
}
}
// Name sets the name
func Name(n string) Option {
return func(o *Options) {
o.Name = n
}
}
// Hooks sets hook runs before action
func Hooks(h ...options.Hook) Option {
return func(o *Options) {
o.Hooks = append(o.Hooks, h...)
}
}
// SubscribeContext set context
func SubscribeContext(ctx context.Context) SubscribeOption {
return func(o *SubscribeOptions) {
o.Context = ctx
}
}
// DisableAutoAck disables auto ack
// Deprecated
func DisableAutoAck() SubscribeOption {
return func(o *SubscribeOptions) {
o.AutoAck = false
}
}
// SubscribeAutoAck contol auto acking of messages
// after they have been handled.
func SubscribeAutoAck(b bool) SubscribeOption {
return func(o *SubscribeOptions) {
o.AutoAck = b
}
}
// SubscribeBodyOnly consumes only body of the message
func SubscribeBodyOnly(b bool) SubscribeOption {
return func(o *SubscribeOptions) {
o.BodyOnly = b
}
}
// SubscribeBatchSize specifies max batch size
func SubscribeBatchSize(n int) SubscribeOption {
return func(o *SubscribeOptions) {
o.BatchSize = n
}
}
// SubscribeBatchWait specifies max batch wait time
func SubscribeBatchWait(td time.Duration) SubscribeOption {
return func(o *SubscribeOptions) {
o.BatchWait = td
}
}
// SubscribeOption func
type SubscribeOption func(*SubscribeOptions)
// NewSubscribeOptions creates new SubscribeOptions
func NewSubscribeOptions(opts ...SubscribeOption) SubscribeOptions {
options := SubscribeOptions{
AutoAck: true,
Context: context.Background(),
}
for _, o := range opts {
o(&options)
}
return options
}

View File

@@ -4,14 +4,27 @@ import (
"context"
"math"
"time"
"go.unistack.org/micro/v3/util/backoff"
)
// BackoffFunc is the backoff call func
type BackoffFunc func(ctx context.Context, req Request, attempts int) (time.Duration, error)
// exponential backoff
func exponentialBackoff(ctx context.Context, req Request, attempts int) (time.Duration, error) {
if attempts == 0 {
return time.Duration(0), nil
}
return time.Duration(math.Pow(10, float64(attempts))) * time.Millisecond, nil
// BackoffExp using exponential backoff func
func BackoffExp(_ context.Context, _ Request, attempts int) (time.Duration, error) {
return backoff.Do(attempts), nil
}
// BackoffInterval specifies randomization interval for backoff func
func BackoffInterval(minTime time.Duration, maxTime time.Duration) BackoffFunc {
return func(_ context.Context, _ Request, attempts int) (time.Duration, error) {
td := time.Duration(math.Pow(float64(attempts), math.E)) * time.Millisecond * 100
if td < minTime {
return minTime, nil
} else if td > maxTime {
return maxTime, nil
}
return td, nil
}
}

View File

@@ -2,26 +2,55 @@ package client
import (
"context"
"math"
"testing"
"time"
)
func TestBackoff(t *testing.T) {
delta := time.Duration(0)
func TestBackoffExp(t *testing.T) {
results := []time.Duration{
0 * time.Second,
100 * time.Millisecond,
600 * time.Millisecond,
1900 * time.Millisecond,
4300 * time.Millisecond,
7900 * time.Millisecond,
}
c := NewClient()
r := &testRequest{
service: "test",
method: "test",
}
for i := 0; i < 5; i++ {
d, err := exponentialBackoff(context.TODO(), c.NewRequest("test", "test", nil), i)
d, err := BackoffExp(context.TODO(), r, i)
if err != nil {
t.Fatal(err)
}
if d < delta {
t.Fatalf("Expected greater than %v, got %v", delta, d)
if d != results[i] {
t.Fatalf("Expected equal than %v, got %v", results[i], d)
}
}
}
func TestBackoffInterval(t *testing.T) {
minTime := 100 * time.Millisecond
maxTime := 300 * time.Millisecond
r := &testRequest{
service: "test",
method: "test",
}
fn := BackoffInterval(minTime, maxTime)
for i := 0; i < 5; i++ {
d, err := fn(context.TODO(), r, i)
if err != nil {
t.Fatal(err)
}
if d < minTime || d > maxTime {
t.Fatalf("Expected %v < %v < %v", minTime, d, maxTime)
}
delta = time.Millisecond * time.Duration(math.Pow(10, float64(i+1)))
}
}

View File

@@ -1,14 +0,0 @@
package client
import (
"bytes"
)
type buffer struct {
*bytes.Buffer
}
func (b *buffer) Close() error {
b.Buffer.Reset()
return nil
}

View File

@@ -5,33 +5,62 @@ import (
"context"
"time"
"github.com/micro/go-micro/codec"
"go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v3/metadata"
)
var (
// DefaultClient is the global default client
DefaultClient = NewClient()
// DefaultContentType is the default content-type if not specified
DefaultContentType = ""
// DefaultBackoff is the default backoff function for retries (minimum 10 millisecond and maximum 5 second)
DefaultBackoff = BackoffInterval(10*time.Millisecond, 5*time.Second)
// DefaultRetry is the default check-for-retry function for retries
DefaultRetry = RetryNever
// DefaultRetries is the default number of times a request is tried
DefaultRetries = 0
// DefaultRequestTimeout is the default request timeout
DefaultRequestTimeout = time.Second * 5
// DefaultPoolSize sets the connection pool size
DefaultPoolSize = 100
// DefaultPoolTTL sets the connection pool ttl
DefaultPoolTTL = time.Minute
)
// Client is the interface used to make requests to services.
// It supports Request/Response via Transport and Publishing via the Broker.
// It also supports bidiectional streaming of requests.
// It also supports bidirectional streaming of requests.
type Client interface {
Init(...Option) error
Name() string
Init(opts ...Option) error
Options() Options
NewMessage(topic string, msg interface{}, opts ...MessageOption) Message
NewRequest(service, endpoint string, req interface{}, reqOpts ...RequestOption) Request
NewRequest(service string, endpoint string, req interface{}, opts ...RequestOption) Request
Call(ctx context.Context, req Request, rsp interface{}, opts ...CallOption) error
Stream(ctx context.Context, req Request, opts ...CallOption) (Stream, error)
Publish(ctx context.Context, msg Message, opts ...PublishOption) error
BatchPublish(ctx context.Context, msg []Message, opts ...PublishOption) error
String() string
}
// Router manages request routing
type Router interface {
SendRequest(context.Context, Request) (Response, error)
}
type (
FuncCall func(ctx context.Context, req Request, rsp interface{}, opts ...CallOption) error
HookCall func(next FuncCall) FuncCall
FuncStream func(ctx context.Context, req Request, opts ...CallOption) (Stream, error)
HookStream func(next FuncStream) FuncStream
FuncPublish func(ctx context.Context, msg Message, opts ...PublishOption) error
HookPublish func(next FuncPublish) FuncPublish
FuncBatchPublish func(ctx context.Context, msg []Message, opts ...PublishOption) error
HookBatchPublish func(next FuncBatchPublish) FuncBatchPublish
)
// Message is the interface for publishing asynchronously
type Message interface {
Topic() string
Payload() interface{}
ContentType() string
Metadata() metadata.Metadata
}
// Request is the interface for a synchronous request used by Call or Stream
@@ -47,7 +76,7 @@ type Request interface {
// The unencoded request body
Body() interface{}
// Write to the encoded request writer. This is nil before a call is made
Codec() codec.Writer
Codec() codec.Codec
// indicates whether the request will be a streaming one rather than unary
Stream() bool
}
@@ -55,14 +84,14 @@ type Request interface {
// Response is the response received from a service
type Response interface {
// Read the response
Codec() codec.Reader
// read the header
Header() map[string]string
Codec() codec.Codec
// Header data
Header() metadata.Metadata
// Read the undecoded response
Read() ([]byte, error)
}
// Stream is the inteface for a bidirectional synchronous stream
// Stream is the interface for a bidirectional synchronous stream
type Stream interface {
// Context for the stream
Context() context.Context
@@ -71,13 +100,19 @@ type Stream interface {
// The response read
Response() Response
// Send will encode and send a request
Send(interface{}) error
Send(msg interface{}) error
// Recv will decode and read a response
Recv(interface{}) error
Recv(msg interface{}) error
// SendMsg will encode and send a request
SendMsg(msg interface{}) error
// RecvMsg will decode and read a response
RecvMsg(msg interface{}) error
// Error returns the stream error
Error() error
// Close closes the stream
Close() error
// CloseSend closes the send direction of the stream
CloseSend() error
}
// Option used by the Client
@@ -94,57 +129,3 @@ type MessageOption func(*MessageOptions)
// RequestOption used by NewRequest
type RequestOption func(*RequestOptions)
var (
// DefaultClient is a default client to use out of the box
DefaultClient Client = newRpcClient()
// DefaultBackoff is the default backoff function for retries
DefaultBackoff = exponentialBackoff
// DefaultRetry is the default check-for-retry function for retries
DefaultRetry = RetryOnError
// DefaultRetries is the default number of times a request is tried
DefaultRetries = 1
// DefaultRequestTimeout is the default request timeout
DefaultRequestTimeout = time.Second * 5
// DefaultPoolSize sets the connection pool size
DefaultPoolSize = 100
// DefaultPoolTTL sets the connection pool ttl
DefaultPoolTTL = time.Minute
)
// Makes a synchronous call to a service using the default client
func Call(ctx context.Context, request Request, response interface{}, opts ...CallOption) error {
return DefaultClient.Call(ctx, request, response, opts...)
}
// Publishes a publication using the default client. Using the underlying broker
// set within the options.
func Publish(ctx context.Context, msg Message, opts ...PublishOption) error {
return DefaultClient.Publish(ctx, msg, opts...)
}
// Creates a new message using the default client
func NewMessage(topic string, payload interface{}, opts ...MessageOption) Message {
return DefaultClient.NewMessage(topic, payload, opts...)
}
// Creates a new client with the options passed in
func NewClient(opt ...Option) Client {
return newRpcClient(opt...)
}
// Creates a new request using the default client. Content Type will
// be set to the default within options and use the appropriate codec
func NewRequest(service, endpoint string, request interface{}, reqOpts ...RequestOption) Request {
return DefaultClient.NewRequest(service, endpoint, request, reqOpts...)
}
// Creates a streaming connection with a service and returns responses on the
// channel passed in. It's up to the user to close the streamer.
func NewStream(ctx context.Context, request Request, opts ...CallOption) (Stream, error) {
return DefaultClient.Stream(ctx, request, opts...)
}
func String() string {
return DefaultClient.String()
}

View File

@@ -0,0 +1,23 @@
package client
import (
"context"
)
type clientCallOptions struct {
Client
opts []CallOption
}
func (s *clientCallOptions) Call(ctx context.Context, req Request, rsp interface{}, opts ...CallOption) error {
return s.Client.Call(ctx, req, rsp, append(s.opts, opts...)...)
}
func (s *clientCallOptions) Stream(ctx context.Context, req Request, opts ...CallOption) (Stream, error) {
return s.Client.Stream(ctx, req, append(s.opts, opts...)...)
}
// NewClientCallOptions add CallOption to every call
func NewClientCallOptions(c Client, opts ...CallOption) Client {
return &clientCallOptions{c, opts}
}

View File

@@ -6,11 +6,58 @@ import (
type clientKey struct{}
// FromContext get client from context
func FromContext(ctx context.Context) (Client, bool) {
if ctx == nil {
return nil, false
}
c, ok := ctx.Value(clientKey{}).(Client)
return c, ok
}
// MustContext get client from context
func MustContext(ctx context.Context) Client {
c, ok := FromContext(ctx)
if !ok {
panic("missing client")
}
return c
}
// NewContext put client in context
func NewContext(ctx context.Context, c Client) context.Context {
if ctx == nil {
ctx = context.Background()
}
return context.WithValue(ctx, clientKey{}, c)
}
// SetPublishOption returns a function to setup a context with given value
func SetPublishOption(k, v interface{}) PublishOption {
return func(o *PublishOptions) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, k, v)
}
}
// SetCallOption returns a function to setup a context with given value
func SetCallOption(k, v interface{}) CallOption {
return func(o *CallOptions) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, k, v)
}
}
// SetOption returns a function to setup a context with given value
func SetOption(k, v interface{}) Option {
return func(o *Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, k, v)
}
}

73
client/context_test.go Normal file
View File

@@ -0,0 +1,73 @@
package client
import (
"context"
"testing"
)
func TestFromContext(t *testing.T) {
ctx := context.WithValue(context.TODO(), clientKey{}, NewClient())
c, ok := FromContext(ctx)
if c == nil || !ok {
t.Fatal("FromContext not works")
}
}
func TestFromNilContext(t *testing.T) {
// nolint: staticcheck
c, ok := FromContext(nil)
if ok || c != nil {
t.Fatal("FromContext not works")
}
}
func TestNewContext(t *testing.T) {
ctx := NewContext(context.TODO(), NewClient())
c, ok := FromContext(ctx)
if c == nil || !ok {
t.Fatal("NewContext not works")
}
}
func TestNewNilContext(t *testing.T) {
// nolint: staticcheck
ctx := NewContext(nil, NewClient())
c, ok := FromContext(ctx)
if c == nil || !ok {
t.Fatal("NewContext not works")
}
}
func TestSetPublishOption(t *testing.T) {
type key struct{}
o := SetPublishOption(key{}, "test")
opts := &PublishOptions{}
o(opts)
if v, ok := opts.Context.Value(key{}).(string); !ok || v == "" {
t.Fatal("SetPublishOption not works")
}
}
func TestSetCallOption(t *testing.T) {
type key struct{}
o := SetCallOption(key{}, "test")
opts := &CallOptions{}
o(opts)
if v, ok := opts.Context.Value(key{}).(string); !ok || v == "" {
t.Fatal("SetCallOption not works")
}
}
func TestSetOption(t *testing.T) {
type key struct{}
o := SetOption(key{}, "test")
opts := &Options{}
o(opts)
if v, ok := opts.Context.Value(key{}).(string); !ok || v == "" {
t.Fatal("SetOption not works")
}
}

53
client/lookup.go Normal file
View File

@@ -0,0 +1,53 @@
package client
import (
"context"
"sort"
"go.unistack.org/micro/v3/errors"
"go.unistack.org/micro/v3/router"
)
// LookupFunc is used to lookup routes for a service
type LookupFunc func(context.Context, Request, CallOptions) ([]string, error)
// LookupRoute for a request using the router and then choose one using the selector
func LookupRoute(_ context.Context, req Request, opts CallOptions) ([]string, error) {
// check to see if an address was provided as a call option
if len(opts.Address) > 0 {
return opts.Address, nil
}
if opts.Router == nil {
return nil, router.ErrRouteNotFound
}
// construct the router query
query := []router.QueryOption{router.QueryService(req.Service())}
// if a custom network was requested, pass this to the router. By default the router will use it's
// own network, which is set during initialisation.
if len(opts.Network) > 0 {
query = append(query, router.QueryNetwork(opts.Network))
}
// lookup the routes which can be used to execute the request
routes, err := opts.Router.Lookup(query...)
if err == router.ErrRouteNotFound {
return nil, errors.InternalServerError("go.micro.client", "service %s: %s", req.Service(), err.Error())
} else if err != nil {
return nil, errors.InternalServerError("go.micro.client", "error getting next %s node: %s", req.Service(), err.Error())
}
// sort by lowest metric first
sort.Slice(routes, func(i, j int) bool {
return routes[i].Metric < routes[j].Metric
})
addrs := make([]string, 0, len(routes))
for _, route := range routes {
addrs = append(addrs, route.Address)
}
return addrs, nil
}

View File

@@ -1,16 +0,0 @@
package mock
import (
"context"
)
type responseKey struct{}
func fromContext(ctx context.Context) (map[string][]MockResponse, bool) {
r, ok := ctx.Value(responseKey{}).(map[string][]MockResponse)
return r, ok
}
func newContext(ctx context.Context, r map[string][]MockResponse) context.Context {
return context.WithValue(ctx, responseKey{}, r)
}

View File

@@ -1,132 +0,0 @@
// Package mock provides a mock client for testing
package mock
import (
"context"
"fmt"
"reflect"
"sync"
"github.com/micro/go-micro/client"
"github.com/micro/go-micro/errors"
)
var (
_ client.Client = NewClient()
)
type MockResponse struct {
Endpoint string
Response interface{}
Error error
}
type MockClient struct {
Client client.Client
Opts client.Options
sync.Mutex
Response map[string][]MockResponse
}
func (m *MockClient) Init(opts ...client.Option) error {
m.Lock()
defer m.Unlock()
for _, opt := range opts {
opt(&m.Opts)
}
r, ok := fromContext(m.Opts.Context)
if !ok {
r = make(map[string][]MockResponse)
}
m.Response = r
return nil
}
func (m *MockClient) Options() client.Options {
return m.Opts
}
func (m *MockClient) NewMessage(topic string, msg interface{}, opts ...client.MessageOption) client.Message {
return m.Client.NewMessage(topic, msg, opts...)
}
func (m *MockClient) NewRequest(service, endpoint string, req interface{}, reqOpts ...client.RequestOption) client.Request {
return m.Client.NewRequest(service, endpoint, req, reqOpts...)
}
func (m *MockClient) Call(ctx context.Context, req client.Request, rsp interface{}, opts ...client.CallOption) error {
m.Lock()
defer m.Unlock()
response, ok := m.Response[req.Service()]
if !ok {
return errors.NotFound("go.micro.client.mock", "service not found")
}
for _, r := range response {
if r.Endpoint != req.Endpoint() {
continue
}
if r.Error != nil {
return r.Error
}
v := reflect.ValueOf(rsp)
if t := reflect.TypeOf(rsp); t.Kind() == reflect.Ptr {
v = reflect.Indirect(v)
}
response := r.Response
if t := reflect.TypeOf(r.Response); t.Kind() == reflect.Func {
response = reflect.ValueOf(r.Response).Call([]reflect.Value{})[0].Interface()
}
v.Set(reflect.ValueOf(response))
return nil
}
return fmt.Errorf("rpc: can't find service %s", req.Endpoint())
}
func (m *MockClient) Stream(ctx context.Context, req client.Request, opts ...client.CallOption) (client.Stream, error) {
m.Lock()
defer m.Unlock()
// TODO: mock stream
return nil, nil
}
func (m *MockClient) Publish(ctx context.Context, p client.Message, opts ...client.PublishOption) error {
return nil
}
func (m *MockClient) String() string {
return "mock"
}
func NewClient(opts ...client.Option) *MockClient {
options := client.Options{
Context: context.TODO(),
}
for _, opt := range opts {
opt(&options)
}
r, ok := fromContext(options.Context)
if !ok {
r = make(map[string][]MockResponse)
}
return &MockClient{
Client: client.DefaultClient,
Opts: options,
Response: r,
}
}

View File

@@ -1,38 +0,0 @@
package mock
import (
"context"
"testing"
"github.com/micro/go-micro/errors"
)
func TestClient(t *testing.T) {
type TestResponse struct {
Param string
}
response := []MockResponse{
{Endpoint: "Foo.Bar", Response: map[string]interface{}{"foo": "bar"}},
{Endpoint: "Foo.Struct", Response: &TestResponse{Param: "aparam"}},
{Endpoint: "Foo.Fail", Error: errors.InternalServerError("go.mock", "failed")},
{Endpoint: "Foo.Func", Response: func() string { return "string" }},
{Endpoint: "Foo.FuncStruct", Response: func() *TestResponse { return &TestResponse{Param: "aparam"} }},
}
c := NewClient(Response("go.mock", response))
for _, r := range response {
req := c.NewRequest("go.mock", r.Endpoint, map[string]interface{}{"foo": "bar"})
var rsp interface{}
err := c.Call(context.TODO(), req, &rsp)
if err != r.Error {
t.Fatalf("Expecter error %v got %v", r.Error, err)
}
t.Log(rsp)
}
}

View File

@@ -1,17 +0,0 @@
package mock
import (
"github.com/micro/go-micro/client"
)
// Response sets the response methods for a service
func Response(service string, response []MockResponse) client.Option {
return func(o *client.Options) {
r, ok := fromContext(o.Context)
if !ok {
r = make(map[string][]MockResponse)
}
r[service] = response
o.Context = newContext(o.Context, r)
}
}

638
client/noop.go Normal file
View File

@@ -0,0 +1,638 @@
package client
import (
"context"
"fmt"
"os"
"strconv"
"time"
"go.unistack.org/micro/v3/broker"
"go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v3/errors"
"go.unistack.org/micro/v3/metadata"
"go.unistack.org/micro/v3/options"
"go.unistack.org/micro/v3/selector"
"go.unistack.org/micro/v3/semconv"
"go.unistack.org/micro/v3/tracer"
)
// DefaultCodecs will be used to encode/decode data
var DefaultCodecs = map[string]codec.Codec{
"application/octet-stream": codec.NewCodec(),
}
type noopClient struct {
funcPublish FuncPublish
funcBatchPublish FuncBatchPublish
funcCall FuncCall
funcStream FuncStream
opts Options
}
type noopMessage struct {
topic string
payload interface{}
opts MessageOptions
}
type noopRequest struct {
body interface{}
codec codec.Codec
service string
method string
endpoint string
contentType string
stream bool
}
// NewClient returns new noop client
func NewClient(opts ...Option) Client {
n := &noopClient{opts: NewOptions(opts...)}
n.funcCall = n.fnCall
n.funcStream = n.fnStream
n.funcPublish = n.fnPublish
n.funcBatchPublish = n.fnBatchPublish
return n
}
func (n *noopClient) Name() string {
return n.opts.Name
}
func (n *noopRequest) Service() string {
return n.service
}
func (n *noopRequest) Method() string {
return n.method
}
func (n *noopRequest) Endpoint() string {
return n.endpoint
}
func (n *noopRequest) ContentType() string {
return n.contentType
}
func (n *noopRequest) Body() interface{} {
return n.body
}
func (n *noopRequest) Codec() codec.Codec {
return n.codec
}
func (n *noopRequest) Stream() bool {
return n.stream
}
type noopResponse struct {
codec codec.Codec
header metadata.Metadata
}
func (n *noopResponse) Codec() codec.Codec {
return n.codec
}
func (n *noopResponse) Header() metadata.Metadata {
return n.header
}
func (n *noopResponse) Read() ([]byte, error) {
return nil, nil
}
type noopStream struct {
err error
ctx context.Context
}
func (n *noopStream) Context() context.Context {
return n.ctx
}
func (n *noopStream) Request() Request {
return &noopRequest{}
}
func (n *noopStream) Response() Response {
return &noopResponse{}
}
func (n *noopStream) Send(interface{}) error {
return nil
}
func (n *noopStream) Recv(interface{}) error {
return nil
}
func (n *noopStream) SendMsg(interface{}) error {
return nil
}
func (n *noopStream) RecvMsg(interface{}) error {
return nil
}
func (n *noopStream) Error() error {
return n.err
}
func (n *noopStream) Close() error {
if sp, ok := tracer.SpanFromContext(n.ctx); ok && sp != nil {
if n.err != nil {
sp.SetStatus(tracer.SpanStatusError, n.err.Error())
}
sp.Finish()
}
return n.err
}
func (n *noopStream) CloseSend() error {
return n.err
}
func (n *noopMessage) Topic() string {
return n.topic
}
func (n *noopMessage) Payload() interface{} {
return n.payload
}
func (n *noopMessage) ContentType() string {
return n.opts.ContentType
}
func (n *noopMessage) Metadata() metadata.Metadata {
return n.opts.Metadata
}
func (n *noopClient) newCodec(contentType string) (codec.Codec, error) {
if cf, ok := n.opts.Codecs[contentType]; ok {
return cf, nil
}
if cf, ok := DefaultCodecs[contentType]; ok {
return cf, nil
}
return nil, codec.ErrUnknownContentType
}
func (n *noopClient) Init(opts ...Option) error {
for _, o := range opts {
o(&n.opts)
}
n.funcCall = n.fnCall
n.funcStream = n.fnStream
n.funcPublish = n.fnPublish
n.funcBatchPublish = n.fnBatchPublish
n.opts.Hooks.EachPrev(func(hook options.Hook) {
switch h := hook.(type) {
case HookCall:
n.funcCall = h(n.funcCall)
case HookStream:
n.funcStream = h(n.funcStream)
case HookPublish:
n.funcPublish = h(n.funcPublish)
case HookBatchPublish:
n.funcBatchPublish = h(n.funcBatchPublish)
}
})
return nil
}
func (n *noopClient) Options() Options {
return n.opts
}
func (n *noopClient) String() string {
return "noop"
}
func (n *noopClient) Call(ctx context.Context, req Request, rsp interface{}, opts ...CallOption) error {
ts := time.Now()
n.opts.Meter.Counter(semconv.ClientRequestInflight, "endpoint", req.Endpoint()).Inc()
var sp tracer.Span
ctx, sp = n.opts.Tracer.Start(ctx, "rpc-client",
tracer.WithSpanKind(tracer.SpanKindClient),
tracer.WithSpanLabels("endpoint", req.Endpoint()),
)
err := n.funcCall(ctx, req, rsp, opts...)
n.opts.Meter.Counter(semconv.ClientRequestInflight, "endpoint", req.Endpoint()).Dec()
te := time.Since(ts)
n.opts.Meter.Summary(semconv.ClientRequestLatencyMicroseconds, "endpoint", req.Endpoint()).Update(te.Seconds())
n.opts.Meter.Histogram(semconv.ClientRequestDurationSeconds, "endpoint", req.Endpoint()).Update(te.Seconds())
if me := errors.FromError(err); me == nil {
sp.Finish()
n.opts.Meter.Counter(semconv.ClientRequestTotal, "endpoint", req.Endpoint(), "status", "success", "code", strconv.Itoa(int(200))).Inc()
} else {
sp.SetStatus(tracer.SpanStatusError, err.Error())
n.opts.Meter.Counter(semconv.ClientRequestTotal, "endpoint", req.Endpoint(), "status", "failure", "code", strconv.Itoa(int(me.Code))).Inc()
}
return err
}
func (n *noopClient) fnCall(ctx context.Context, req Request, rsp interface{}, opts ...CallOption) error {
// make a copy of call opts
callOpts := n.opts.CallOptions
for _, opt := range opts {
opt(&callOpts)
}
// check if we already have a deadline
d, ok := ctx.Deadline()
if !ok {
var cancel context.CancelFunc
// no deadline so we create a new one
ctx, cancel = context.WithTimeout(ctx, callOpts.RequestTimeout)
defer cancel()
} else {
// got a deadline so no need to setup context
// but we need to set the timeout we pass along
opt := WithRequestTimeout(time.Until(d))
opt(&callOpts)
}
// should we noop right here?
select {
case <-ctx.Done():
return errors.New("go.micro.client", fmt.Sprintf("%v", ctx.Err()), 408)
default:
}
// make copy of call method
hcall := func(ctx context.Context, addr string, req Request, rsp interface{}, opts CallOptions) error {
return nil
}
// use the router passed as a call option, or fallback to the rpc clients router
if callOpts.Router == nil {
callOpts.Router = n.opts.Router
}
if callOpts.Selector == nil {
callOpts.Selector = n.opts.Selector
}
// inject proxy address
// TODO: don't even bother using Lookup/Select in this case
if len(n.opts.Proxy) > 0 {
callOpts.Address = []string{n.opts.Proxy}
}
var next selector.Next
// return errors.New("go.micro.client", "request timeout", 408)
call := func(i int) error {
// call backoff first. Someone may want an initial start delay
t, err := callOpts.Backoff(ctx, req, i)
if err != nil {
return errors.InternalServerError("go.micro.client", "%s", err)
}
// only sleep if greater than 0
if t.Seconds() > 0 {
time.Sleep(t)
}
if next == nil {
var routes []string
// lookup the route to send the reques to
// TODO apply any filtering here
routes, err = n.opts.Lookup(ctx, req, callOpts)
if err != nil {
return errors.InternalServerError("go.micro.client", "%s", err)
}
// balance the list of nodes
next, err = callOpts.Selector.Select(routes)
if err != nil {
return err
}
}
node := next()
// make the call
err = hcall(ctx, node, req, rsp, callOpts)
// record the result of the call to inform future routing decisions
if verr := n.opts.Selector.Record(node, err); verr != nil {
return verr
}
// try and transform the error to a go-micro error
if verr, ok := err.(*errors.Error); ok {
return verr
}
return err
}
ch := make(chan error, callOpts.Retries)
var gerr error
for i := 0; i <= callOpts.Retries; i++ {
go func() {
ch <- call(i)
}()
select {
case <-ctx.Done():
return errors.New("go.micro.client", fmt.Sprintf("%v", ctx.Err()), 408)
case err := <-ch:
// if the call succeeded lets bail early
if err == nil {
return nil
}
retry, rerr := callOpts.Retry(ctx, req, i, err)
if rerr != nil {
return rerr
}
if !retry {
return err
}
gerr = err
}
}
return gerr
}
func (n *noopClient) NewRequest(service, endpoint string, _ interface{}, _ ...RequestOption) Request {
return &noopRequest{service: service, endpoint: endpoint}
}
func (n *noopClient) NewMessage(topic string, msg interface{}, opts ...MessageOption) Message {
options := NewMessageOptions(append([]MessageOption{MessageContentType(n.opts.ContentType)}, opts...)...)
return &noopMessage{topic: topic, payload: msg, opts: options}
}
func (n *noopClient) Stream(ctx context.Context, req Request, opts ...CallOption) (Stream, error) {
ts := time.Now()
n.opts.Meter.Counter(semconv.ClientRequestInflight, "endpoint", req.Endpoint()).Inc()
var sp tracer.Span
ctx, sp = n.opts.Tracer.Start(ctx, "rpc-client",
tracer.WithSpanKind(tracer.SpanKindClient),
tracer.WithSpanLabels("endpoint", req.Endpoint()),
)
stream, err := n.funcStream(ctx, req, opts...)
n.opts.Meter.Counter(semconv.ClientRequestInflight, "endpoint", req.Endpoint()).Dec()
te := time.Since(ts)
n.opts.Meter.Summary(semconv.ClientRequestLatencyMicroseconds, "endpoint", req.Endpoint()).Update(te.Seconds())
n.opts.Meter.Histogram(semconv.ClientRequestDurationSeconds, "endpoint", req.Endpoint()).Update(te.Seconds())
if me := errors.FromError(err); me == nil {
sp.Finish()
n.opts.Meter.Counter(semconv.ClientRequestTotal, "endpoint", req.Endpoint(), "status", "success", "code", strconv.Itoa(int(200))).Inc()
} else {
sp.SetStatus(tracer.SpanStatusError, err.Error())
n.opts.Meter.Counter(semconv.ClientRequestTotal, "endpoint", req.Endpoint(), "status", "failure", "code", strconv.Itoa(int(me.Code))).Inc()
}
return stream, err
}
func (n *noopClient) fnStream(ctx context.Context, req Request, opts ...CallOption) (Stream, error) {
var err error
// make a copy of call opts
callOpts := n.opts.CallOptions
for _, o := range opts {
o(&callOpts)
}
// check if we already have a deadline
d, ok := ctx.Deadline()
if !ok && callOpts.StreamTimeout > time.Duration(0) {
var cancel context.CancelFunc
// no deadline so we create a new one
ctx, cancel = context.WithTimeout(ctx, callOpts.StreamTimeout)
defer cancel()
} else {
// got a deadline so no need to setup context
// but we need to set the timeout we pass along
o := WithStreamTimeout(time.Until(d))
o(&callOpts)
}
// should we noop right here?
select {
case <-ctx.Done():
return nil, errors.New("go.micro.client", fmt.Sprintf("%v", ctx.Err()), 408)
default:
}
/*
// make copy of call method
hstream := h.stream
// wrap the call in reverse
for i := len(callOpts.CallWrappers); i > 0; i-- {
hstream = callOpts.CallWrappers[i-1](hstream)
}
*/
// use the router passed as a call option, or fallback to the rpc clients router
if callOpts.Router == nil {
callOpts.Router = n.opts.Router
}
if callOpts.Selector == nil {
callOpts.Selector = n.opts.Selector
}
// inject proxy address
// TODO: don't even bother using Lookup/Select in this case
if len(n.opts.Proxy) > 0 {
callOpts.Address = []string{n.opts.Proxy}
}
var next selector.Next
call := func(i int) (Stream, error) {
// call backoff first. Someone may want an initial start delay
t, cerr := callOpts.Backoff(ctx, req, i)
if cerr != nil {
return nil, errors.InternalServerError("go.micro.client", "%s", cerr)
}
// only sleep if greater than 0
if t.Seconds() > 0 {
time.Sleep(t)
}
if next == nil {
var routes []string
// lookup the route to send the reques to
// TODO apply any filtering here
routes, err = n.opts.Lookup(ctx, req, callOpts)
if err != nil {
return nil, errors.InternalServerError("go.micro.client", "%s", err)
}
// balance the list of nodes
next, err = callOpts.Selector.Select(routes)
if err != nil {
return nil, err
}
}
node := next()
stream, cerr := n.stream(ctx, node, req, callOpts)
// record the result of the call to inform future routing decisions
if verr := n.opts.Selector.Record(node, cerr); verr != nil {
return nil, verr
}
// try and transform the error to a go-micro error
if verr, ok := cerr.(*errors.Error); ok {
return nil, verr
}
return stream, cerr
}
type response struct {
stream Stream
err error
}
ch := make(chan response, callOpts.Retries)
var grr error
for i := 0; i <= callOpts.Retries; i++ {
go func() {
s, cerr := call(i)
ch <- response{s, cerr}
}()
select {
case <-ctx.Done():
return nil, errors.New("go.micro.client", fmt.Sprintf("%v", ctx.Err()), 408)
case rsp := <-ch:
// if the call succeeded lets bail early
if rsp.err == nil {
return rsp.stream, nil
}
retry, rerr := callOpts.Retry(ctx, req, i, err)
if rerr != nil {
return nil, rerr
}
if !retry {
return nil, rsp.err
}
grr = rsp.err
}
}
return nil, grr
}
func (n *noopClient) stream(ctx context.Context, _ string, _ Request, _ CallOptions) (Stream, error) {
return &noopStream{ctx: ctx}, nil
}
func (n *noopClient) BatchPublish(ctx context.Context, ps []Message, opts ...PublishOption) error {
return n.funcBatchPublish(ctx, ps, opts...)
}
func (n *noopClient) fnBatchPublish(ctx context.Context, ps []Message, opts ...PublishOption) error {
return n.publish(ctx, ps, opts...)
}
func (n *noopClient) Publish(ctx context.Context, p Message, opts ...PublishOption) error {
return n.funcPublish(ctx, p, opts...)
}
func (n *noopClient) fnPublish(ctx context.Context, p Message, opts ...PublishOption) error {
return n.publish(ctx, []Message{p}, opts...)
}
func (n *noopClient) publish(ctx context.Context, ps []Message, opts ...PublishOption) error {
options := NewPublishOptions(opts...)
msgs := make([]*broker.Message, 0, len(ps))
// get proxy
exchange := ""
if v, ok := os.LookupEnv("MICRO_PROXY"); ok {
exchange = v
}
// get the exchange
if len(options.Exchange) > 0 {
exchange = options.Exchange
}
omd, ok := metadata.FromOutgoingContext(ctx)
if !ok {
omd = metadata.New(0)
}
for _, p := range ps {
md := metadata.Copy(omd)
topic := p.Topic()
if len(exchange) > 0 {
topic = exchange
}
md[metadata.HeaderTopic] = topic
iter := p.Metadata().Iterator()
var k, v string
for iter.Next(&k, &v) {
md.Set(k, v)
}
md[metadata.HeaderContentType] = p.ContentType()
var body []byte
// passed in raw data
if d, ok := p.Payload().(*codec.Frame); ok {
body = d.Data
} else {
// use codec for payload
cf, err := n.newCodec(p.ContentType())
if err != nil {
return errors.InternalServerError("go.micro.client", "%s", err)
}
// set the body
b, err := cf.Marshal(p.Payload())
if err != nil {
return errors.InternalServerError("go.micro.client", "%s", err)
}
body = b
}
msgs = append(msgs, &broker.Message{Header: md, Body: body})
}
if len(msgs) == 1 {
return n.opts.Broker.Publish(ctx, msgs[0].Header[metadata.HeaderTopic], msgs[0],
broker.PublishContext(options.Context),
broker.PublishBodyOnly(options.BodyOnly),
)
}
return n.opts.Broker.BatchPublish(ctx, msgs,
broker.PublishContext(options.Context),
broker.PublishBodyOnly(options.BodyOnly),
)
}

35
client/noop_test.go Normal file
View File

@@ -0,0 +1,35 @@
package client
import (
"context"
"testing"
)
type testHook struct {
f bool
}
func (t *testHook) Publish(fn FuncPublish) FuncPublish {
return func(ctx context.Context, msg Message, opts ...PublishOption) error {
t.f = true
return fn(ctx, msg, opts...)
}
}
func TestNoopHook(t *testing.T) {
h := &testHook{}
c := NewClient(Hooks(HookPublish(h.Publish)))
if err := c.Init(); err != nil {
t.Fatal(err)
}
if err := c.Publish(context.TODO(), c.NewMessage("", nil, MessageContentType("application/octet-stream"))); err != nil {
t.Fatal(err)
}
if !h.f {
t.Fatal("hook not works")
}
}

View File

@@ -2,130 +2,226 @@ package client
import (
"context"
"crypto/tls"
"net"
"time"
"github.com/micro/go-micro/broker"
"github.com/micro/go-micro/codec"
"github.com/micro/go-micro/registry"
"github.com/micro/go-micro/selector"
"github.com/micro/go-micro/transport"
"go.unistack.org/micro/v3/broker"
"go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/metadata"
"go.unistack.org/micro/v3/meter"
"go.unistack.org/micro/v3/options"
"go.unistack.org/micro/v3/register"
"go.unistack.org/micro/v3/router"
"go.unistack.org/micro/v3/selector"
"go.unistack.org/micro/v3/selector/random"
"go.unistack.org/micro/v3/tracer"
)
// Options holds client options
type Options struct {
// Used to select codec
// Codecs map
Codecs map[string]codec.Codec
// Proxy is used for proxy requests
Proxy string
// ContentType is used to select codec
ContentType string
// Name is the client name
Name string
// Plugged interfaces
Broker broker.Broker
Codecs map[string]codec.NewCodec
Registry registry.Registry
Selector selector.Selector
Transport transport.Transport
// Selector used to select needed address
Selector selector.Selector
// Logger used to log messages
Logger logger.Logger
// Tracer used for tracing
Tracer tracer.Tracer
// Broker used to publish messages
Broker broker.Broker
// Meter used for metrics
Meter meter.Meter
// Context is used for external options
Context context.Context
// Router used to get route
Router router.Router
// Router sets the router
Router Router
// TLSConfig specifies tls.Config for secure connection
TLSConfig *tls.Config
// Connection Pool
PoolSize int
PoolTTL time.Duration
// Lookup func used to get destination addr
Lookup LookupFunc
// ContextDialer used to connect
ContextDialer func(context.Context, string) (net.Conn, error)
// Middleware for client
// Wrappers contains wrappers
Wrappers []Wrapper
// Hooks can be run before broker Publish/BatchPublish and
// Subscribe/BatchSubscribe methods
Hooks options.Hooks
// Default Call Options
// CallOptions contains default CallOptions
CallOptions CallOptions
// Other options for implementations of the interface
// can be stored in a context
Context context.Context
// PoolSize connection pool size
PoolSize int
// PoolTTL connection pool ttl
PoolTTL time.Duration
}
// NewCallOptions creates new call options struct
func NewCallOptions(opts ...CallOption) CallOptions {
options := CallOptions{}
for _, o := range opts {
o(&options)
}
return options
}
// CallOptions holds client call options
type CallOptions struct {
// RequestMetadata holds additional metadata for call
RequestMetadata metadata.Metadata
// Network name
Network string
// Content-Type
ContentType string
// AuthToken string
AuthToken string
// Selector selects addr
Selector selector.Selector
// Context used for deadline
Context context.Context
// Router used for route
Router router.Router
// Retry func used for retries
// ResponseMetadata holds additional metadata from call
ResponseMetadata *metadata.Metadata
Retry RetryFunc
// Backoff func used for backoff when retry
Backoff BackoffFunc
// ContextDialer used to connect
ContextDialer func(context.Context, string) (net.Conn, error)
// Address specifies static addr list
Address []string
// SelectOptions selector options
SelectOptions []selector.SelectOption
// Address of remote host
Address string
// Backoff func
Backoff BackoffFunc
// Check if retriable func
Retry RetryFunc
// Transport Dial Timeout
DialTimeout time.Duration
// Number of Call attempts
Retries int
// Request/Response timeout
// StreamTimeout stream timeout
StreamTimeout time.Duration
// RequestTimeout request timeout
RequestTimeout time.Duration
// Middleware for low level call func
CallWrappers []CallWrapper
// Other options for implementations of the interface
// can be stored in a context
Context context.Context
// DialTimeout dial timeout
DialTimeout time.Duration
// Retries specifies retries num
Retries int
}
// ContextDialer pass ContextDialer to client
func ContextDialer(fn func(context.Context, string) (net.Conn, error)) Option {
return func(o *Options) {
o.ContextDialer = fn
}
}
// Context pass context to client
func Context(ctx context.Context) Option {
return func(o *Options) {
o.Context = ctx
}
}
// NewPublishOptions create new PublishOptions struct from option
func NewPublishOptions(opts ...PublishOption) PublishOptions {
options := PublishOptions{}
for _, o := range opts {
o(&options)
}
return options
}
// PublishOptions holds publish options
type PublishOptions struct {
// Exchange is the routing exchange for the message
// Context used for external options
Context context.Context
// Exchange topic exchange name
Exchange string
// Other options for implementations of the interface
// can be stored in a context
Context context.Context
// BodyOnly will publish only message body
BodyOnly bool
}
// NewMessageOptions creates message options struct
func NewMessageOptions(opts ...MessageOption) MessageOptions {
options := MessageOptions{Metadata: metadata.New(1)}
for _, o := range opts {
o(&options)
}
return options
}
// MessageOptions holds client message options
type MessageOptions struct {
// Metadata additional metadata
Metadata metadata.Metadata
// ContentType specify content-type of message
// deprecated
ContentType string
}
// NewRequestOptions creates new RequestOptions struct
func NewRequestOptions(opts ...RequestOption) RequestOptions {
options := RequestOptions{}
for _, o := range opts {
o(&options)
}
return options
}
// RequestOptions holds client request options
type RequestOptions struct {
ContentType string
Stream bool
// Other options for implementations of the interface
// can be stored in a context
// Context used for external options
Context context.Context
// ContentType specify content-type of message
ContentType string
// Stream flag
Stream bool
}
func newOptions(options ...Option) Options {
opts := Options{
Codecs: make(map[string]codec.NewCodec),
// NewOptions creates new options struct
func NewOptions(opts ...Option) Options {
options := Options{
Context: context.Background(),
ContentType: DefaultContentType,
Codecs: DefaultCodecs,
CallOptions: CallOptions{
Context: context.Background(),
Backoff: DefaultBackoff,
Retry: DefaultRetry,
Retries: DefaultRetries,
RequestTimeout: DefaultRequestTimeout,
DialTimeout: transport.DefaultDialTimeout,
},
Lookup: LookupRoute,
PoolSize: DefaultPoolSize,
PoolTTL: DefaultPoolTTL,
Selector: random.NewSelector(),
Logger: logger.DefaultLogger,
Broker: broker.DefaultBroker,
Meter: meter.DefaultMeter,
Tracer: tracer.DefaultTracer,
Router: router.DefaultRouter,
}
for _, o := range options {
o(&opts)
for _, o := range opts {
o(&options)
}
if len(opts.ContentType) == 0 {
opts.ContentType = DefaultContentType
}
if opts.Broker == nil {
opts.Broker = broker.DefaultBroker
}
if opts.Registry == nil {
opts.Registry = registry.DefaultRegistry
}
if opts.Selector == nil {
opts.Selector = selector.NewSelector(
selector.Registry(opts.Registry),
)
}
if opts.Transport == nil {
opts.Transport = transport.DefaultTransport
}
return opts
return options
}
// Broker to be used for pub/sub
@@ -135,20 +231,48 @@ func Broker(b broker.Broker) Option {
}
}
// Tracer to be used for tracing
func Tracer(t tracer.Tracer) Option {
return func(o *Options) {
o.Tracer = t
}
}
// Logger to be used for log mesages
func Logger(l logger.Logger) Option {
return func(o *Options) {
o.Logger = l
}
}
// Meter to be used for metrics
func Meter(m meter.Meter) Option {
return func(o *Options) {
o.Meter = m
}
}
// Codec to be used to encode/decode requests for a given content type
func Codec(contentType string, c codec.NewCodec) Option {
func Codec(contentType string, c codec.Codec) Option {
return func(o *Options) {
o.Codecs[contentType] = c
}
}
// Default content type of the client
// ContentType used by default if not specified
func ContentType(ct string) Option {
return func(o *Options) {
o.ContentType = ct
}
}
// Proxy sets the proxy address
func Proxy(addr string) Option {
return func(o *Options) {
o.Proxy = addr
}
}
// PoolSize sets the connection pool size
func PoolSize(d int) Option {
return func(o *Options) {
@@ -156,58 +280,66 @@ func PoolSize(d int) Option {
}
}
// PoolSize sets the connection pool size
// PoolTTL sets the connection pool ttl
func PoolTTL(d time.Duration) Option {
return func(o *Options) {
o.PoolTTL = d
}
}
// Registry to find nodes for a given service
func Registry(r registry.Registry) Option {
// Register sets the routers register
func Register(r register.Register) Option {
return func(o *Options) {
o.Registry = r
if o.Router != nil {
_ = o.Router.Init(router.Register(r))
}
}
}
// Transport to use for communication e.g http, rabbitmq, etc
func Transport(t transport.Transport) Option {
// Router is used to lookup routes for a service
func Router(r router.Router) Option {
return func(o *Options) {
o.Transport = t
o.Router = r
}
}
// Select is used to select a node to route a request to
// Selector is used to select a route
func Selector(s selector.Selector) Option {
return func(o *Options) {
o.Selector = s
}
}
// Adds a Wrapper to a list of options passed into the client
func Wrap(w Wrapper) Option {
return func(o *Options) {
o.Wrappers = append(o.Wrappers, w)
}
}
// Adds a Wrapper to the list of CallFunc wrappers
func WrapCall(cw ...CallWrapper) Option {
return func(o *Options) {
o.CallOptions.CallWrappers = append(o.CallOptions.CallWrappers, cw...)
}
}
// Backoff is used to set the backoff function used
// when retrying Calls
// Backoff is used to set the backoff function used when retrying Calls
func Backoff(fn BackoffFunc) Option {
return func(o *Options) {
o.CallOptions.Backoff = fn
}
}
// Number of retries when making the request.
// Should this be a Call Option?
// Name sets the client name
func Name(n string) Option {
return func(o *Options) {
o.Name = n
}
}
// Lookup sets the lookup function to use for resolving service names
func Lookup(l LookupFunc) Option {
return func(o *Options) {
o.Lookup = l
}
}
// TLSConfig specifies a *tls.Config
func TLSConfig(t *tls.Config) Option {
return func(o *Options) {
// set the internal tls
o.TLSConfig = t
}
}
// Retries sets the retry count when making the request.
func Retries(i int) Option {
return func(o *Options) {
o.CallOptions.Retries = i
@@ -221,50 +353,85 @@ func Retry(fn RetryFunc) Option {
}
}
// The request timeout.
// Should this be a Call Option?
// RequestTimeout is the request timeout.
func RequestTimeout(d time.Duration) Option {
return func(o *Options) {
o.CallOptions.RequestTimeout = d
}
}
// Transport dial timeout
// StreamTimeout sets the stream timeout
func StreamTimeout(d time.Duration) Option {
return func(o *Options) {
o.CallOptions.StreamTimeout = d
}
}
// DialTimeout sets the dial timeout
func DialTimeout(d time.Duration) Option {
return func(o *Options) {
o.CallOptions.DialTimeout = d
}
}
// Call Options
// WithExchange sets the exchange to route a message through
// Deprecated
func WithExchange(e string) PublishOption {
return func(o *PublishOptions) {
o.Exchange = e
}
}
// WithAddress sets the remote address to use rather than using service discovery
func WithAddress(a string) CallOption {
// PublishExchange sets the exchange to route a message through
func PublishExchange(e string) PublishOption {
return func(o *PublishOptions) {
o.Exchange = e
}
}
// WithBodyOnly publish only message body
// DERECATED
func WithBodyOnly(b bool) PublishOption {
return func(o *PublishOptions) {
o.BodyOnly = b
}
}
// PublishBodyOnly publish only message body
func PublishBodyOnly(b bool) PublishOption {
return func(o *PublishOptions) {
o.BodyOnly = b
}
}
// PublishContext sets the context in publish options
func PublishContext(ctx context.Context) PublishOption {
return func(o *PublishOptions) {
o.Context = ctx
}
}
// WithContextDialer pass ContextDialer to client call
func WithContextDialer(fn func(context.Context, string) (net.Conn, error)) CallOption {
return func(o *CallOptions) {
o.ContextDialer = fn
}
}
// WithContentType specifies call content type
func WithContentType(ct string) CallOption {
return func(o *CallOptions) {
o.ContentType = ct
}
}
// WithAddress sets the remote addresses to use rather than using service discovery
func WithAddress(a ...string) CallOption {
return func(o *CallOptions) {
o.Address = a
}
}
func WithSelectOption(so ...selector.SelectOption) CallOption {
return func(o *CallOptions) {
o.SelectOptions = append(o.SelectOptions, so...)
}
}
// WithCallWrapper is a CallOption which adds to the existing CallFunc wrappers
func WithCallWrapper(cw ...CallWrapper) CallOption {
return func(o *CallOptions) {
o.CallWrappers = append(o.CallWrappers, cw...)
}
}
// WithBackoff is a CallOption which overrides that which
// set in Options.CallOptions
func WithBackoff(fn BackoffFunc) CallOption {
@@ -289,6 +456,20 @@ func WithRetries(i int) CallOption {
}
}
// WithResponseMetadata is a CallOption which adds metadata.Metadata to Options.CallOptions
func WithResponseMetadata(md *metadata.Metadata) CallOption {
return func(o *CallOptions) {
o.ResponseMetadata = md
}
}
// WithRequestMetadata is a CallOption which adds metadata.Metadata to Options.CallOptions
func WithRequestMetadata(md metadata.Metadata) CallOption {
return func(o *CallOptions) {
o.RequestMetadata = md
}
}
// WithRequestTimeout is a CallOption which overrides that which
// set in Options.CallOptions
func WithRequestTimeout(d time.Duration) CallOption {
@@ -297,6 +478,13 @@ func WithRequestTimeout(d time.Duration) CallOption {
}
}
// WithStreamTimeout sets the stream timeout
func WithStreamTimeout(d time.Duration) CallOption {
return func(o *CallOptions) {
o.StreamTimeout = d
}
}
// WithDialTimeout is a CallOption which overrides that which
// set in Options.CallOptions
func WithDialTimeout(d time.Duration) CallOption {
@@ -305,23 +493,76 @@ func WithDialTimeout(d time.Duration) CallOption {
}
}
// Request Options
// WithAuthToken is a CallOption which overrides the
// authorization header with the services own auth token
func WithAuthToken(t string) CallOption {
return func(o *CallOptions) {
o.AuthToken = t
}
}
func WithContentType(ct string) RequestOption {
// WithRouter sets the router to use for this call
func WithRouter(r router.Router) CallOption {
return func(o *CallOptions) {
o.Router = r
}
}
// WithSelector sets the selector to use for this call
func WithSelector(s selector.Selector) CallOption {
return func(o *CallOptions) {
o.Selector = s
}
}
// WithSelectOptions sets the options to pass to the selector for this call
func WithSelectOptions(sops ...selector.SelectOption) CallOption {
return func(o *CallOptions) {
o.SelectOptions = sops
}
}
// WithMessageContentType sets the message content type
// Deprecated
func WithMessageContentType(ct string) MessageOption {
return func(o *MessageOptions) {
o.Metadata.Set(metadata.HeaderContentType, ct)
o.ContentType = ct
}
}
// MessageContentType sets the message content type
func MessageContentType(ct string) MessageOption {
return func(o *MessageOptions) {
o.Metadata.Set(metadata.HeaderContentType, ct)
o.ContentType = ct
}
}
// MessageMetadata sets the message metadata
func MessageMetadata(k, v string) MessageOption {
return func(o *MessageOptions) {
o.Metadata.Set(k, v)
}
}
// StreamingRequest specifies that request is streaming
func StreamingRequest(b bool) RequestOption {
return func(o *RequestOptions) {
o.Stream = b
}
}
// RequestContentType specifies request content type
func RequestContentType(ct string) RequestOption {
return func(o *RequestOptions) {
o.ContentType = ct
}
}
func StreamingRequest() RequestOption {
return func(o *RequestOptions) {
o.Stream = true
}
}
// WithRouter sets the client router
func WithRouter(r Router) Option {
// Hooks sets hook runs before action
func Hooks(h ...options.Hook) Option {
return func(o *Options) {
o.Router = r
o.Hooks = append(o.Hooks, h...)
}
}

View File

@@ -1,85 +0,0 @@
package client
import (
"testing"
"time"
"github.com/micro/go-micro/transport"
)
func TestCallOptions(t *testing.T) {
testData := []struct {
set bool
retries int
rtimeout time.Duration
dtimeout time.Duration
}{
{false, DefaultRetries, DefaultRequestTimeout, transport.DefaultDialTimeout},
{true, 10, time.Second, time.Second * 2},
}
for _, d := range testData {
var opts Options
var cl Client
if d.set {
opts = newOptions(
Retries(d.retries),
RequestTimeout(d.rtimeout),
DialTimeout(d.dtimeout),
)
cl = NewClient(
Retries(d.retries),
RequestTimeout(d.rtimeout),
DialTimeout(d.dtimeout),
)
} else {
opts = newOptions()
cl = NewClient()
}
// test options and those set in client
for _, o := range []Options{opts, cl.Options()} {
if o.CallOptions.Retries != d.retries {
t.Fatalf("Expected retries %v got %v", d.retries, o.CallOptions.Retries)
}
if o.CallOptions.RequestTimeout != d.rtimeout {
t.Fatalf("Expected request timeout %v got %v", d.rtimeout, o.CallOptions.RequestTimeout)
}
if o.CallOptions.DialTimeout != d.dtimeout {
t.Fatalf("Expected %v got %v", d.dtimeout, o.CallOptions.DialTimeout)
}
// copy CallOptions
callOpts := o.CallOptions
// create new opts
cretries := WithRetries(o.CallOptions.Retries * 10)
crtimeout := WithRequestTimeout(o.CallOptions.RequestTimeout * (time.Second * 10))
cdtimeout := WithDialTimeout(o.CallOptions.DialTimeout * (time.Second * 10))
// set call options
for _, opt := range []CallOption{cretries, crtimeout, cdtimeout} {
opt(&callOpts)
}
// check call options
if e := o.CallOptions.Retries * 10; callOpts.Retries != e {
t.Fatalf("Expected retries %v got %v", e, callOpts.Retries)
}
if e := o.CallOptions.RequestTimeout * (time.Second * 10); callOpts.RequestTimeout != e {
t.Fatalf("Expected request timeout %v got %v", e, callOpts.RequestTimeout)
}
if e := o.CallOptions.DialTimeout * (time.Second * 10); callOpts.DialTimeout != e {
t.Fatalf("Expected %v got %v", e, callOpts.DialTimeout)
}
}
}
}

View File

@@ -3,10 +3,10 @@ package client
import (
"context"
"github.com/micro/go-micro/errors"
"go.unistack.org/micro/v3/errors"
)
// note that returning either false or a non-nil error will result in the call not being retried
// RetryFunc that returning either false or a non-nil error will result in the call not being retried
type RetryFunc func(ctx context.Context, req Request, retryCount int, err error) (bool, error)
// RetryAlways always retry on error
@@ -14,22 +14,37 @@ func RetryAlways(ctx context.Context, req Request, retryCount int, err error) (b
return true, nil
}
// RetryOnError retries a request on a 500 or timeout error
func RetryOnError(ctx context.Context, req Request, retryCount int, err error) (bool, error) {
// RetryNever never retry on error
func RetryNever(ctx context.Context, req Request, retryCount int, err error) (bool, error) {
return false, nil
}
// RetryOnError retries a request on a 500 or 408 (timeout) error
func RetryOnError(_ context.Context, _ Request, _ int, err error) (bool, error) {
if err == nil {
return false, nil
}
e := errors.Parse(err.Error())
if e == nil {
return false, nil
}
switch e.Code {
me := errors.FromError(err)
switch me.Code {
// retry on timeout or internal server error
case 408, 500:
return true, nil
default:
}
return false, nil
}
// RetryOnErrors retries a request on specified error codes
func RetryOnErrors(codes ...int32) RetryFunc {
return func(_ context.Context, _ Request, _ int, err error) (bool, error) {
if err == nil {
return false, nil
}
me := errors.FromError(err)
for _, code := range codes {
if me.Code == code {
return true, nil
}
}
return false, nil
}
}

70
client/retry_test.go Normal file
View File

@@ -0,0 +1,70 @@
package client
import (
"context"
"fmt"
"testing"
"go.unistack.org/micro/v3/errors"
)
func TestRetryAlways(t *testing.T) {
tests := []error{
nil,
errors.InternalServerError("test", "%s", "test"),
fmt.Errorf("test"),
}
for _, e := range tests {
ok, er := RetryAlways(context.TODO(), nil, 1, e)
if !ok || er != nil {
t.Fatal("RetryAlways not works properly")
}
}
}
func TestRetryNever(t *testing.T) {
tests := []error{
nil,
errors.InternalServerError("test", "%s", "test"),
fmt.Errorf("test"),
}
for _, e := range tests {
ok, er := RetryNever(context.TODO(), nil, 1, e)
if ok || er != nil {
t.Fatal("RetryNever not works properly")
}
}
}
func TestRetryOnError(t *testing.T) {
tests := []error{
fmt.Errorf("test"),
errors.NotFound("test", "%s", "test"),
errors.Timeout("test", "%s", "test"),
}
for i, e := range tests {
ok, er := RetryOnError(context.TODO(), nil, 1, e)
if i == 2 && (!ok || er != nil) {
t.Fatal("RetryOnError not works properly")
}
}
}
func TestRetryOnErrors(t *testing.T) {
tests := []error{
fmt.Errorf("test"),
errors.NotFound("test", "%s", "test"),
errors.Timeout("test", "%s", "test"),
}
fn := RetryOnErrors(404)
for i, e := range tests {
ok, er := fn(context.TODO(), nil, 1, e)
if i == 1 && (!ok || er != nil) {
t.Fatal("RetryOnErrors not works properly")
}
}
}

View File

@@ -1,11 +0,0 @@
// Package rpc provides an rpc client
package rpc
import (
"github.com/micro/go-micro/client"
)
// NewClient returns a new micro client interface
func NewClient(opts ...client.Option) client.Client {
return client.NewClient(opts...)
}

View File

@@ -1,567 +0,0 @@
package client
import (
"bytes"
"context"
"fmt"
"net"
"os"
"strconv"
"sync"
"sync/atomic"
"time"
"github.com/google/uuid"
"github.com/micro/go-micro/broker"
"github.com/micro/go-micro/codec"
"github.com/micro/go-micro/errors"
"github.com/micro/go-micro/metadata"
"github.com/micro/go-micro/registry"
"github.com/micro/go-micro/selector"
"github.com/micro/go-micro/transport"
)
type rpcClient struct {
once sync.Once
opts Options
pool *pool
seq uint64
}
func newRpcClient(opt ...Option) Client {
opts := newOptions(opt...)
rc := &rpcClient{
once: sync.Once{},
opts: opts,
pool: newPool(opts.PoolSize, opts.PoolTTL),
seq: 0,
}
c := Client(rc)
// wrap in reverse
for i := len(opts.Wrappers); i > 0; i-- {
c = opts.Wrappers[i-1](c)
}
return c
}
func (r *rpcClient) newCodec(contentType string) (codec.NewCodec, error) {
if c, ok := r.opts.Codecs[contentType]; ok {
return c, nil
}
if cf, ok := DefaultCodecs[contentType]; ok {
return cf, nil
}
return nil, fmt.Errorf("Unsupported Content-Type: %s", contentType)
}
func (r *rpcClient) call(ctx context.Context, node *registry.Node, req Request, resp interface{}, opts CallOptions) error {
address := node.Address
if node.Port > 0 {
address = fmt.Sprintf("%s:%d", address, node.Port)
}
msg := &transport.Message{
Header: make(map[string]string),
}
md, ok := metadata.FromContext(ctx)
if ok {
for k, v := range md {
msg.Header[k] = v
}
}
// set timeout in nanoseconds
msg.Header["Timeout"] = fmt.Sprintf("%d", opts.RequestTimeout)
// set the content type for the request
msg.Header["Content-Type"] = req.ContentType()
// set the accept header
msg.Header["Accept"] = req.ContentType()
// setup old protocol
cf := setupProtocol(msg, node)
// no codec specified
if cf == nil {
var err error
cf, err = r.newCodec(req.ContentType())
if err != nil {
return errors.InternalServerError("go.micro.client", err.Error())
}
}
var grr error
c, err := r.pool.getConn(address, r.opts.Transport, transport.WithTimeout(opts.DialTimeout))
if err != nil {
return errors.InternalServerError("go.micro.client", "connection error: %v", err)
}
defer func() {
// defer execution of release
r.pool.release(address, c, grr)
}()
seq := atomic.LoadUint64(&r.seq)
atomic.AddUint64(&r.seq, 1)
codec := newRpcCodec(msg, c, cf)
rsp := &rpcResponse{
socket: c,
codec: codec,
}
stream := &rpcStream{
context: ctx,
request: req,
response: rsp,
codec: codec,
closed: make(chan bool),
id: fmt.Sprintf("%v", seq),
}
defer stream.Close()
ch := make(chan error, 1)
go func() {
defer func() {
if r := recover(); r != nil {
ch <- errors.InternalServerError("go.micro.client", "panic recovered: %v", r)
}
}()
// send request
if err := stream.Send(req.Body()); err != nil {
ch <- err
return
}
// recv request
if err := stream.Recv(resp); err != nil {
ch <- err
return
}
// success
ch <- nil
}()
select {
case err := <-ch:
grr = err
return err
case <-ctx.Done():
grr = ctx.Err()
return errors.Timeout("go.micro.client", fmt.Sprintf("%v", ctx.Err()))
}
}
func (r *rpcClient) stream(ctx context.Context, node *registry.Node, req Request, opts CallOptions) (Stream, error) {
address := node.Address
if node.Port > 0 {
address = fmt.Sprintf("%s:%d", address, node.Port)
}
msg := &transport.Message{
Header: make(map[string]string),
}
md, ok := metadata.FromContext(ctx)
if ok {
for k, v := range md {
msg.Header[k] = v
}
}
// set timeout in nanoseconds
msg.Header["Timeout"] = fmt.Sprintf("%d", opts.RequestTimeout)
// set the content type for the request
msg.Header["Content-Type"] = req.ContentType()
// set the accept header
msg.Header["Accept"] = req.ContentType()
// set old codecs
cf := setupProtocol(msg, node)
// no codec specified
if cf == nil {
var err error
cf, err = r.newCodec(req.ContentType())
if err != nil {
return nil, errors.InternalServerError("go.micro.client", err.Error())
}
}
dOpts := []transport.DialOption{
transport.WithStream(),
}
if opts.DialTimeout >= 0 {
dOpts = append(dOpts, transport.WithTimeout(opts.DialTimeout))
}
c, err := r.opts.Transport.Dial(address, dOpts...)
if err != nil {
return nil, errors.InternalServerError("go.micro.client", "connection error: %v", err)
}
codec := newRpcCodec(msg, c, cf)
rsp := &rpcResponse{
socket: c,
codec: codec,
}
// set request codec
if r, ok := req.(*rpcRequest); ok {
r.codec = codec
}
stream := &rpcStream{
context: ctx,
request: req,
response: rsp,
closed: make(chan bool),
codec: codec,
}
ch := make(chan error, 1)
go func() {
ch <- stream.Send(req.Body())
}()
var grr error
select {
case err := <-ch:
grr = err
case <-ctx.Done():
grr = errors.Timeout("go.micro.client", fmt.Sprintf("%v", ctx.Err()))
}
if grr != nil {
stream.Close()
return nil, grr
}
return stream, nil
}
func (r *rpcClient) Init(opts ...Option) error {
size := r.opts.PoolSize
ttl := r.opts.PoolTTL
for _, o := range opts {
o(&r.opts)
}
// update pool configuration if the options changed
if size != r.opts.PoolSize || ttl != r.opts.PoolTTL {
r.pool.Lock()
r.pool.size = r.opts.PoolSize
r.pool.ttl = int64(r.opts.PoolTTL.Seconds())
r.pool.Unlock()
}
return nil
}
func (r *rpcClient) Options() Options {
return r.opts
}
func (r *rpcClient) next(request Request, opts CallOptions) (selector.Next, error) {
service := request.Service()
// get proxy
if prx := os.Getenv("MICRO_PROXY"); len(prx) > 0 {
service = prx
}
// get proxy address
if prx := os.Getenv("MICRO_PROXY_ADDRESS"); len(prx) > 0 {
opts.Address = prx
}
// return remote address
if len(opts.Address) > 0 {
address := opts.Address
port := 0
host, sport, err := net.SplitHostPort(opts.Address)
if err == nil {
address = host
port, _ = strconv.Atoi(sport)
}
return func() (*registry.Node, error) {
return &registry.Node{
Address: address,
Port: port,
}, nil
}, nil
}
// get next nodes from the selector
next, err := r.opts.Selector.Select(service, opts.SelectOptions...)
if err != nil && err == selector.ErrNotFound {
return nil, errors.NotFound("go.micro.client", "service %s: %v", service, err.Error())
} else if err != nil {
return nil, errors.InternalServerError("go.micro.client", "error selecting %s node: %v", service, err.Error())
}
return next, nil
}
func (r *rpcClient) Call(ctx context.Context, request Request, response interface{}, opts ...CallOption) error {
// make a copy of call opts
callOpts := r.opts.CallOptions
for _, opt := range opts {
opt(&callOpts)
}
next, err := r.next(request, callOpts)
if err != nil {
return err
}
// check if we already have a deadline
d, ok := ctx.Deadline()
if !ok {
// no deadline so we create a new one
ctx, _ = context.WithTimeout(ctx, callOpts.RequestTimeout)
} else {
// got a deadline so no need to setup context
// but we need to set the timeout we pass along
opt := WithRequestTimeout(d.Sub(time.Now()))
opt(&callOpts)
}
// should we noop right here?
select {
case <-ctx.Done():
return errors.Timeout("go.micro.client", fmt.Sprintf("%v", ctx.Err()))
default:
}
// make copy of call method
rcall := r.call
// wrap the call in reverse
for i := len(callOpts.CallWrappers); i > 0; i-- {
rcall = callOpts.CallWrappers[i-1](rcall)
}
// return errors.New("go.micro.client", "request timeout", 408)
call := func(i int) error {
// call backoff first. Someone may want an initial start delay
t, err := callOpts.Backoff(ctx, request, i)
if err != nil {
return errors.InternalServerError("go.micro.client", "backoff error: %v", err.Error())
}
// only sleep if greater than 0
if t.Seconds() > 0 {
time.Sleep(t)
}
// select next node
node, err := next()
if err != nil && err == selector.ErrNotFound {
return errors.NotFound("go.micro.client", "service %s: %v", request.Service(), err.Error())
} else if err != nil {
return errors.InternalServerError("go.micro.client", "error getting next %s node: %v", request.Service(), err.Error())
}
// make the call
err = rcall(ctx, node, request, response, callOpts)
r.opts.Selector.Mark(request.Service(), node, err)
return err
}
ch := make(chan error, callOpts.Retries)
var gerr error
for i := 0; i <= callOpts.Retries; i++ {
go func(i int) {
ch <- call(i)
}(i)
select {
case <-ctx.Done():
return errors.Timeout("go.micro.client", fmt.Sprintf("call timeout: %v", ctx.Err()))
case err := <-ch:
// if the call succeeded lets bail early
if err == nil {
return nil
}
retry, rerr := callOpts.Retry(ctx, request, i, err)
if rerr != nil {
return rerr
}
if !retry {
return err
}
gerr = err
}
}
return gerr
}
func (r *rpcClient) Stream(ctx context.Context, request Request, opts ...CallOption) (Stream, error) {
// make a copy of call opts
callOpts := r.opts.CallOptions
for _, opt := range opts {
opt(&callOpts)
}
next, err := r.next(request, callOpts)
if err != nil {
return nil, err
}
// should we noop right here?
select {
case <-ctx.Done():
return nil, errors.Timeout("go.micro.client", fmt.Sprintf("%v", ctx.Err()))
default:
}
call := func(i int) (Stream, error) {
// call backoff first. Someone may want an initial start delay
t, err := callOpts.Backoff(ctx, request, i)
if err != nil {
return nil, errors.InternalServerError("go.micro.client", "backoff error: %v", err.Error())
}
// only sleep if greater than 0
if t.Seconds() > 0 {
time.Sleep(t)
}
node, err := next()
if err != nil && err == selector.ErrNotFound {
return nil, errors.NotFound("go.micro.client", "service %s: %v", request.Service(), err.Error())
} else if err != nil {
return nil, errors.InternalServerError("go.micro.client", "error getting next %s node: %v", request.Service(), err.Error())
}
stream, err := r.stream(ctx, node, request, callOpts)
r.opts.Selector.Mark(request.Service(), node, err)
return stream, err
}
type response struct {
stream Stream
err error
}
ch := make(chan response, callOpts.Retries)
var grr error
for i := 0; i <= callOpts.Retries; i++ {
go func() {
s, err := call(i)
ch <- response{s, err}
}()
select {
case <-ctx.Done():
return nil, errors.Timeout("go.micro.client", fmt.Sprintf("call timeout: %v", ctx.Err()))
case rsp := <-ch:
// if the call succeeded lets bail early
if rsp.err == nil {
return rsp.stream, nil
}
retry, rerr := callOpts.Retry(ctx, request, i, rsp.err)
if rerr != nil {
return nil, rerr
}
if !retry {
return nil, rsp.err
}
grr = rsp.err
}
}
return nil, grr
}
func (r *rpcClient) Publish(ctx context.Context, msg Message, opts ...PublishOption) error {
options := PublishOptions{
Context: context.Background(),
}
for _, o := range opts {
o(&options)
}
md, ok := metadata.FromContext(ctx)
if !ok {
md = make(map[string]string)
}
id := uuid.New().String()
md["Content-Type"] = msg.ContentType()
md["Micro-Topic"] = msg.Topic()
md["Micro-Id"] = id
// set the topic
topic := msg.Topic()
// get proxy
if prx := os.Getenv("MICRO_PROXY"); len(prx) > 0 {
options.Exchange = prx
}
// get the exchange
if len(options.Exchange) > 0 {
topic = options.Exchange
}
// encode message body
cf, err := r.newCodec(msg.ContentType())
if err != nil {
return errors.InternalServerError("go.micro.client", err.Error())
}
b := &buffer{bytes.NewBuffer(nil)}
if err := cf(b).Write(&codec.Message{
Target: topic,
Type: codec.Publication,
Header: map[string]string{
"Micro-Id": id,
"Micro-Topic": msg.Topic(),
},
}, msg.Payload()); err != nil {
return errors.InternalServerError("go.micro.client", err.Error())
}
r.once.Do(func() {
r.opts.Broker.Connect()
})
return r.opts.Broker.Publish(topic, &broker.Message{
Header: md,
Body: b.Bytes(),
})
}
func (r *rpcClient) NewMessage(topic string, message interface{}, opts ...MessageOption) Message {
return newMessage(topic, message, r.opts.ContentType, opts...)
}
func (r *rpcClient) NewRequest(service, method string, request interface{}, reqOpts ...RequestOption) Request {
return newRequest(service, method, request, r.opts.ContentType, reqOpts...)
}
func (r *rpcClient) String() string {
return "rpc"
}

View File

@@ -1,167 +0,0 @@
package client
import (
"context"
"fmt"
"testing"
"github.com/micro/go-micro/errors"
"github.com/micro/go-micro/registry"
"github.com/micro/go-micro/registry/memory"
"github.com/micro/go-micro/selector"
)
func newTestRegistry() registry.Registry {
r := memory.NewRegistry()
r.(*memory.Registry).Setup()
return r
}
func TestCallAddress(t *testing.T) {
var called bool
service := "test.service"
endpoint := "Test.Endpoint"
address := "10.1.10.1"
port := 8080
wrap := func(cf CallFunc) CallFunc {
return func(ctx context.Context, node *registry.Node, req Request, rsp interface{}, opts CallOptions) error {
called = true
if req.Service() != service {
return fmt.Errorf("expected service: %s got %s", service, req.Service())
}
if req.Endpoint() != endpoint {
return fmt.Errorf("expected service: %s got %s", endpoint, req.Endpoint())
}
if node.Address != address {
return fmt.Errorf("expected address: %s got %s", address, node.Address)
}
if node.Port != port {
return fmt.Errorf("expected address: %d got %d", port, node.Port)
}
// don't do the call
return nil
}
}
r := newTestRegistry()
c := NewClient(
Registry(r),
WrapCall(wrap),
)
c.Options().Selector.Init(selector.Registry(r))
req := c.NewRequest(service, endpoint, nil)
// test calling remote address
if err := c.Call(context.Background(), req, nil, WithAddress(fmt.Sprintf("%s:%d", address, port))); err != nil {
t.Fatal("call with address error", err)
}
if !called {
t.Fatal("wrapper not called")
}
}
func TestCallRetry(t *testing.T) {
service := "test.service"
endpoint := "Test.Endpoint"
address := "10.1.10.1"
var called int
wrap := func(cf CallFunc) CallFunc {
return func(ctx context.Context, node *registry.Node, req Request, rsp interface{}, opts CallOptions) error {
called++
if called == 1 {
return errors.InternalServerError("test.error", "retry request")
}
// don't do the call
return nil
}
}
r := newTestRegistry()
c := NewClient(
Registry(r),
WrapCall(wrap),
)
c.Options().Selector.Init(selector.Registry(r))
req := c.NewRequest(service, endpoint, nil)
// test calling remote address
if err := c.Call(context.Background(), req, nil, WithAddress(address)); err != nil {
t.Fatal("call with address error", err)
}
// num calls
if called < c.Options().CallOptions.Retries+1 {
t.Fatal("request not retried")
}
}
func TestCallWrapper(t *testing.T) {
var called bool
id := "test.1"
service := "test.service"
endpoint := "Test.Endpoint"
address := "10.1.10.1"
port := 8080
wrap := func(cf CallFunc) CallFunc {
return func(ctx context.Context, node *registry.Node, req Request, rsp interface{}, opts CallOptions) error {
called = true
if req.Service() != service {
return fmt.Errorf("expected service: %s got %s", service, req.Service())
}
if req.Endpoint() != endpoint {
return fmt.Errorf("expected service: %s got %s", endpoint, req.Endpoint())
}
if node.Address != address {
return fmt.Errorf("expected address: %s got %s", address, node.Address)
}
// don't do the call
return nil
}
}
r := newTestRegistry()
c := NewClient(
Registry(r),
WrapCall(wrap),
)
c.Options().Selector.Init(selector.Registry(r))
r.Register(&registry.Service{
Name: service,
Version: "latest",
Nodes: []*registry.Node{
&registry.Node{
Id: id,
Address: address,
Port: port,
},
},
})
req := c.NewRequest(service, endpoint, nil)
if err := c.Call(context.Background(), req, nil); err != nil {
t.Fatal("call wrapper error", err)
}
if !called {
t.Fatal("wrapper not called")
}
}

View File

@@ -1,260 +0,0 @@
package client
import (
"bytes"
errs "errors"
"github.com/micro/go-micro/codec"
raw "github.com/micro/go-micro/codec/bytes"
"github.com/micro/go-micro/codec/grpc"
"github.com/micro/go-micro/codec/json"
"github.com/micro/go-micro/codec/jsonrpc"
"github.com/micro/go-micro/codec/proto"
"github.com/micro/go-micro/codec/protorpc"
"github.com/micro/go-micro/errors"
"github.com/micro/go-micro/registry"
"github.com/micro/go-micro/transport"
)
const (
lastStreamResponseError = "EOS"
)
// serverError represents an error that has been returned from
// the remote side of the RPC connection.
type serverError string
func (e serverError) Error() string {
return string(e)
}
// errShutdown holds the specific error for closing/closed connections
var (
errShutdown = errs.New("connection is shut down")
)
type rpcCodec struct {
client transport.Client
codec codec.Codec
req *transport.Message
buf *readWriteCloser
}
type readWriteCloser struct {
wbuf *bytes.Buffer
rbuf *bytes.Buffer
}
var (
DefaultContentType = "application/protobuf"
DefaultCodecs = map[string]codec.NewCodec{
"application/grpc": grpc.NewCodec,
"application/grpc+json": grpc.NewCodec,
"application/grpc+proto": grpc.NewCodec,
"application/protobuf": proto.NewCodec,
"application/json": json.NewCodec,
"application/json-rpc": jsonrpc.NewCodec,
"application/proto-rpc": protorpc.NewCodec,
"application/octet-stream": raw.NewCodec,
}
// TODO: remove legacy codec list
defaultCodecs = map[string]codec.NewCodec{
"application/json": jsonrpc.NewCodec,
"application/json-rpc": jsonrpc.NewCodec,
"application/protobuf": protorpc.NewCodec,
"application/proto-rpc": protorpc.NewCodec,
"application/octet-stream": protorpc.NewCodec,
}
)
func (rwc *readWriteCloser) Read(p []byte) (n int, err error) {
return rwc.rbuf.Read(p)
}
func (rwc *readWriteCloser) Write(p []byte) (n int, err error) {
return rwc.wbuf.Write(p)
}
func (rwc *readWriteCloser) Close() error {
rwc.rbuf.Reset()
rwc.wbuf.Reset()
return nil
}
func getHeaders(m *codec.Message) {
get := func(hdr string) string {
if hd := m.Header[hdr]; len(hd) > 0 {
return hd
}
// old
return m.Header["X-"+hdr]
}
// check error in header
if len(m.Error) == 0 {
m.Error = get("Micro-Error")
}
// check endpoint in header
if len(m.Endpoint) == 0 {
m.Endpoint = get("Micro-Endpoint")
}
// check method in header
if len(m.Method) == 0 {
m.Method = get("Micro-Method")
}
if len(m.Id) == 0 {
m.Id = get("Micro-Id")
}
}
func setHeaders(m *codec.Message) {
set := func(hdr, v string) {
if len(v) == 0 {
return
}
m.Header[hdr] = v
m.Header["X-"+hdr] = v
}
set("Micro-Id", m.Id)
set("Micro-Service", m.Target)
set("Micro-Method", m.Method)
set("Micro-Endpoint", m.Endpoint)
}
// setupProtocol sets up the old protocol
func setupProtocol(msg *transport.Message, node *registry.Node) codec.NewCodec {
protocol := node.Metadata["protocol"]
// got protocol
if len(protocol) > 0 {
return nil
}
// no protocol use old codecs
switch msg.Header["Content-Type"] {
case "application/json":
msg.Header["Content-Type"] = "application/json-rpc"
case "application/protobuf":
msg.Header["Content-Type"] = "application/proto-rpc"
}
// now return codec
return defaultCodecs[msg.Header["Content-Type"]]
}
func newRpcCodec(req *transport.Message, client transport.Client, c codec.NewCodec) codec.Codec {
rwc := &readWriteCloser{
wbuf: bytes.NewBuffer(nil),
rbuf: bytes.NewBuffer(nil),
}
r := &rpcCodec{
buf: rwc,
client: client,
codec: c(rwc),
req: req,
}
return r
}
func (c *rpcCodec) Write(m *codec.Message, body interface{}) error {
c.buf.wbuf.Reset()
// create header
if m.Header == nil {
m.Header = map[string]string{}
}
// copy original header
for k, v := range c.req.Header {
m.Header[k] = v
}
// set the mucp headers
setHeaders(m)
// if body is bytes Frame don't encode
if body != nil {
b, ok := body.(*raw.Frame)
if ok {
// set body
m.Body = b.Data
body = nil
}
}
if len(m.Body) == 0 {
// write to codec
if err := c.codec.Write(m, body); err != nil {
return errors.InternalServerError("go.micro.client.codec", err.Error())
}
// set body
m.Body = c.buf.wbuf.Bytes()
}
// create new transport message
msg := transport.Message{
Header: m.Header,
Body: m.Body,
}
// send the request
if err := c.client.Send(&msg); err != nil {
return errors.InternalServerError("go.micro.client.transport", err.Error())
}
return nil
}
func (c *rpcCodec) ReadHeader(m *codec.Message, r codec.MessageType) error {
var tm transport.Message
// read message from transport
if err := c.client.Recv(&tm); err != nil {
return errors.InternalServerError("go.micro.client.transport", err.Error())
}
c.buf.rbuf.Reset()
c.buf.rbuf.Write(tm.Body)
// set headers from transport
m.Header = tm.Header
// read header
err := c.codec.ReadHeader(m, r)
// get headers
getHeaders(m)
// return header error
if err != nil {
return errors.InternalServerError("go.micro.client.codec", err.Error())
}
return nil
}
func (c *rpcCodec) ReadBody(b interface{}) error {
// read body
if err := c.codec.ReadBody(b); err != nil {
return errors.InternalServerError("go.micro.client.codec", err.Error())
}
return nil
}
func (c *rpcCodec) Close() error {
c.buf.Close()
c.codec.Close()
if err := c.client.Close(); err != nil {
return errors.InternalServerError("go.micro.client.transport", err.Error())
}
return nil
}
func (c *rpcCodec) String() string {
return "rpc"
}

View File

@@ -1,36 +0,0 @@
package client
type message struct {
topic string
contentType string
payload interface{}
}
func newMessage(topic string, payload interface{}, contentType string, opts ...MessageOption) Message {
var options MessageOptions
for _, o := range opts {
o(&options)
}
if len(options.ContentType) > 0 {
contentType = options.ContentType
}
return &message{
payload: payload,
topic: topic,
contentType: contentType,
}
}
func (m *message) ContentType() string {
return m.contentType
}
func (m *message) Topic() string {
return m.topic
}
func (m *message) Payload() interface{} {
return m.payload
}

View File

@@ -1,87 +0,0 @@
package client
import (
"sync"
"time"
"github.com/micro/go-micro/transport"
)
type pool struct {
size int
ttl int64
sync.Mutex
conns map[string][]*poolConn
}
type poolConn struct {
transport.Client
created int64
}
func newPool(size int, ttl time.Duration) *pool {
return &pool{
size: size,
ttl: int64(ttl.Seconds()),
conns: make(map[string][]*poolConn),
}
}
// NoOp the Close since we manage it
func (p *poolConn) Close() error {
return nil
}
func (p *pool) getConn(addr string, tr transport.Transport, opts ...transport.DialOption) (*poolConn, error) {
p.Lock()
conns := p.conns[addr]
now := time.Now().Unix()
// while we have conns check age and then return one
// otherwise we'll create a new conn
for len(conns) > 0 {
conn := conns[len(conns)-1]
conns = conns[:len(conns)-1]
p.conns[addr] = conns
// if conn is old kill it and move on
if d := now - conn.created; d > p.ttl {
conn.Client.Close()
continue
}
// we got a good conn, lets unlock and return it
p.Unlock()
return conn, nil
}
p.Unlock()
// create new conn
c, err := tr.Dial(addr, opts...)
if err != nil {
return nil, err
}
return &poolConn{c, time.Now().Unix()}, nil
}
func (p *pool) release(addr string, conn *poolConn, err error) {
// don't store the conn if it has errored
if err != nil {
conn.Client.Close()
return
}
// otherwise put it back for reuse
p.Lock()
conns := p.conns[addr]
if len(conns) >= p.size {
p.Unlock()
conn.Client.Close()
return
}
p.conns[addr] = append(conns, conn)
p.Unlock()
}

View File

@@ -1,84 +0,0 @@
package client
import (
"testing"
"time"
"github.com/micro/go-micro/transport"
"github.com/micro/go-micro/transport/memory"
)
func testPool(t *testing.T, size int, ttl time.Duration) {
// zero pool
p := newPool(size, ttl)
// mock transport
tr := memory.NewTransport()
// listen
l, err := tr.Listen(":0")
if err != nil {
t.Fatal(err)
}
defer l.Close()
// accept loop
go func() {
for {
if err := l.Accept(func(s transport.Socket) {
for {
var msg transport.Message
if err := s.Recv(&msg); err != nil {
return
}
if err := s.Send(&msg); err != nil {
return
}
}
}); err != nil {
return
}
}
}()
for i := 0; i < 10; i++ {
// get a conn
c, err := p.getConn(l.Addr(), tr)
if err != nil {
t.Fatal(err)
}
msg := &transport.Message{
Body: []byte(`hello world`),
}
if err := c.Send(msg); err != nil {
t.Fatal(err)
}
var rcv transport.Message
if err := c.Recv(&rcv); err != nil {
t.Fatal(err)
}
if string(rcv.Body) != string(msg.Body) {
t.Fatalf("got %v, expected %v", rcv.Body, msg.Body)
}
// release the conn
p.release(l.Addr(), c, nil)
p.Lock()
if i := len(p.conns[l.Addr()]); i > size {
p.Unlock()
t.Fatalf("pool size %d is greater than expected %d", i, size)
}
p.Unlock()
}
}
func TestRPCPool(t *testing.T) {
testPool(t, 0, time.Minute)
testPool(t, 2, time.Minute)
}

View File

@@ -1,65 +0,0 @@
package client
import (
"github.com/micro/go-micro/codec"
)
type rpcRequest struct {
service string
method string
endpoint string
contentType string
codec codec.Codec
body interface{}
opts RequestOptions
}
func newRequest(service, endpoint string, request interface{}, contentType string, reqOpts ...RequestOption) Request {
var opts RequestOptions
for _, o := range reqOpts {
o(&opts)
}
// set the content-type specified
if len(opts.ContentType) > 0 {
contentType = opts.ContentType
}
return &rpcRequest{
service: service,
method: endpoint,
endpoint: endpoint,
body: request,
contentType: contentType,
opts: opts,
}
}
func (r *rpcRequest) ContentType() string {
return r.contentType
}
func (r *rpcRequest) Service() string {
return r.service
}
func (r *rpcRequest) Method() string {
return r.method
}
func (r *rpcRequest) Endpoint() string {
return r.endpoint
}
func (r *rpcRequest) Body() interface{} {
return r.body
}
func (r *rpcRequest) Codec() codec.Writer {
return r.codec
}
func (r *rpcRequest) Stream() bool {
return r.opts.Stream
}

View File

@@ -1,23 +0,0 @@
package client
import (
"testing"
)
func TestRequestOptions(t *testing.T) {
r := newRequest("service", "endpoint", nil, "application/json")
if r.Service() != "service" {
t.Fatalf("expected 'service' got %s", r.Service())
}
if r.Endpoint() != "endpoint" {
t.Fatalf("expected 'endpoint' got %s", r.Endpoint())
}
if r.ContentType() != "application/json" {
t.Fatalf("expected 'endpoint' got %s", r.ContentType())
}
r2 := newRequest("service", "endpoint", nil, "application/json", WithContentType("application/protobuf"))
if r2.ContentType() != "application/protobuf" {
t.Fatalf("expected 'endpoint' got %s", r2.ContentType())
}
}

View File

@@ -1,35 +0,0 @@
package client
import (
"github.com/micro/go-micro/codec"
"github.com/micro/go-micro/transport"
)
type rpcResponse struct {
header map[string]string
body []byte
socket transport.Socket
codec codec.Codec
}
func (r *rpcResponse) Codec() codec.Reader {
return r.codec
}
func (r *rpcResponse) Header() map[string]string {
return r.header
}
func (r *rpcResponse) Read() ([]byte, error) {
var msg transport.Message
if err := r.socket.Recv(&msg); err != nil {
return nil, err
}
// set internals
r.header = msg.Header
r.body = msg.Body
return msg.Body, nil
}

View File

@@ -1,125 +0,0 @@
package client
import (
"context"
"io"
"sync"
"github.com/micro/go-micro/codec"
)
// Implements the streamer interface
type rpcStream struct {
sync.RWMutex
id string
closed chan bool
err error
request Request
response Response
codec codec.Codec
context context.Context
}
func (r *rpcStream) isClosed() bool {
select {
case <-r.closed:
return true
default:
return false
}
}
func (r *rpcStream) Context() context.Context {
return r.context
}
func (r *rpcStream) Request() Request {
return r.request
}
func (r *rpcStream) Response() Response {
return r.response
}
func (r *rpcStream) Send(msg interface{}) error {
r.Lock()
defer r.Unlock()
if r.isClosed() {
r.err = errShutdown
return errShutdown
}
req := codec.Message{
Id: r.id,
Target: r.request.Service(),
Method: r.request.Method(),
Endpoint: r.request.Endpoint(),
Type: codec.Request,
}
if err := r.codec.Write(&req, msg); err != nil {
r.err = err
return err
}
return nil
}
func (r *rpcStream) Recv(msg interface{}) error {
r.Lock()
defer r.Unlock()
if r.isClosed() {
r.err = errShutdown
return errShutdown
}
var resp codec.Message
if err := r.codec.ReadHeader(&resp, codec.Response); err != nil {
if err == io.EOF && !r.isClosed() {
r.err = io.ErrUnexpectedEOF
return io.ErrUnexpectedEOF
}
r.err = err
return err
}
switch {
case len(resp.Error) > 0:
// We've got an error response. Give this to the request;
// any subsequent requests will get the ReadResponseBody
// error if there is one.
if resp.Error != lastStreamResponseError {
r.err = serverError(resp.Error)
} else {
r.err = io.EOF
}
if err := r.codec.ReadBody(nil); err != nil {
r.err = err
}
default:
if err := r.codec.ReadBody(msg); err != nil {
r.err = err
}
}
return r.err
}
func (r *rpcStream) Error() error {
r.RLock()
defer r.RUnlock()
return r.err
}
func (r *rpcStream) Close() error {
select {
case <-r.closed:
return nil
default:
close(r.closed)
return r.codec.Close()
}
}

43
client/test_request.go Normal file
View File

@@ -0,0 +1,43 @@
package client
import (
"go.unistack.org/micro/v3/codec"
)
type testRequest struct {
codec codec.Codec
body interface{}
service string
method string
endpoint string
contentType string
opts RequestOptions
}
func (r *testRequest) ContentType() string {
return r.contentType
}
func (r *testRequest) Service() string {
return r.service
}
func (r *testRequest) Method() string {
return r.method
}
func (r *testRequest) Endpoint() string {
return r.endpoint
}
func (r *testRequest) Body() interface{} {
return r.body
}
func (r *testRequest) Codec() codec.Codec {
return r.codec
}
func (r *testRequest) Stream() bool {
return r.opts.Stream
}

View File

@@ -2,12 +2,10 @@ package client
import (
"context"
"github.com/micro/go-micro/registry"
)
// CallFunc represents the individual call func
type CallFunc func(ctx context.Context, node *registry.Node, req Request, rsp interface{}, opts CallOptions) error
type CallFunc func(ctx context.Context, addr string, req Request, rsp interface{}, opts CallOptions) error
// CallWrapper is a low level wrapper for the CallFunc
type CallWrapper func(CallFunc) CallFunc

47
cluster/cluster.go Normal file
View File

@@ -0,0 +1,47 @@
package cluster
import (
"context"
"go.unistack.org/micro/v3/metadata"
)
// Message sent to member in cluster
type Message interface {
// Header returns message headers
Header() metadata.Metadata
// Body returns broker message may be []byte slice or some go struct or interface
Body() interface{}
}
type Node interface {
// Name returns node name
Name() string
// Address returns node address
Address() string
// Metadata returns node metadata
Metadata() metadata.Metadata
}
// Cluster interface used for cluster communication across nodes
type Cluster interface {
// Join is used to take an existing members and performing state sync
Join(ctx context.Context, addr ...string) error
// Leave broadcast a leave message and stop listeners
Leave(ctx context.Context) error
// Ping is used to probe live status of the node
Ping(ctx context.Context, node Node, payload []byte) error
// Members returns the cluster members
Members() ([]Node, error)
// Broadcast send message for all members in cluster, if filter is not nil, nodes may be filtered
// by key/value pairs
Broadcast(ctx context.Context, msg Message, filter ...string) error
// Unicast send message to single member in cluster
Unicast(ctx context.Context, node Node, msg Message) error
// Live returns cluster liveness
Live() bool
// Ready returns cluster readiness
Ready() bool
// Health returns cluster health
Health() bool
}

View File

@@ -1,480 +0,0 @@
// Package cmd is an interface for parsing the command line
package cmd
import (
"fmt"
"io"
"math/rand"
"os"
"strings"
"time"
"github.com/micro/cli"
"github.com/micro/go-log"
"github.com/micro/go-micro/client"
"github.com/micro/go-micro/server"
// brokers
"github.com/micro/go-micro/broker"
"github.com/micro/go-micro/broker/http"
"github.com/micro/go-micro/broker/memory"
// registries
"github.com/micro/go-micro/registry"
"github.com/micro/go-micro/registry/consul"
"github.com/micro/go-micro/registry/gossip"
"github.com/micro/go-micro/registry/mdns"
rmem "github.com/micro/go-micro/registry/memory"
// selectors
"github.com/micro/go-micro/selector"
"github.com/micro/go-micro/selector/dns"
"github.com/micro/go-micro/selector/static"
// transports
"github.com/micro/go-micro/transport"
thttp "github.com/micro/go-micro/transport/http"
tmem "github.com/micro/go-micro/transport/memory"
)
type Cmd interface {
// The cli app within this cmd
App() *cli.App
// Adds options, parses flags and initialise
// exits on error
Init(opts ...Option) error
// Options set within this command
Options() Options
}
type cmd struct {
opts Options
app *cli.App
}
type Option func(o *Options)
var (
DefaultCmd = newCmd()
DefaultFlags = []cli.Flag{
cli.StringFlag{
Name: "client",
EnvVar: "MICRO_CLIENT",
Usage: "Client for go-micro; rpc",
},
cli.StringFlag{
Name: "client_request_timeout",
EnvVar: "MICRO_CLIENT_REQUEST_TIMEOUT",
Usage: "Sets the client request timeout. e.g 500ms, 5s, 1m. Default: 5s",
},
cli.IntFlag{
Name: "client_retries",
EnvVar: "MICRO_CLIENT_RETRIES",
Usage: "Sets the client retries. Default: 1",
},
cli.IntFlag{
Name: "client_pool_size",
EnvVar: "MICRO_CLIENT_POOL_SIZE",
Usage: "Sets the client connection pool size. Default: 1",
},
cli.StringFlag{
Name: "client_pool_ttl",
EnvVar: "MICRO_CLIENT_POOL_TTL",
Usage: "Sets the client connection pool ttl. e.g 500ms, 5s, 1m. Default: 1m",
},
cli.IntFlag{
Name: "register_ttl",
EnvVar: "MICRO_REGISTER_TTL",
Usage: "Register TTL in seconds",
},
cli.IntFlag{
Name: "register_interval",
EnvVar: "MICRO_REGISTER_INTERVAL",
Usage: "Register interval in seconds",
},
cli.StringFlag{
Name: "server",
EnvVar: "MICRO_SERVER",
Usage: "Server for go-micro; rpc",
},
cli.StringFlag{
Name: "server_name",
EnvVar: "MICRO_SERVER_NAME",
Usage: "Name of the server. go.micro.srv.example",
},
cli.StringFlag{
Name: "server_version",
EnvVar: "MICRO_SERVER_VERSION",
Usage: "Version of the server. 1.1.0",
},
cli.StringFlag{
Name: "server_id",
EnvVar: "MICRO_SERVER_ID",
Usage: "Id of the server. Auto-generated if not specified",
},
cli.StringFlag{
Name: "server_address",
EnvVar: "MICRO_SERVER_ADDRESS",
Usage: "Bind address for the server. 127.0.0.1:8080",
},
cli.StringFlag{
Name: "server_advertise",
EnvVar: "MICRO_SERVER_ADVERTISE",
Usage: "Used instead of the server_address when registering with discovery. 127.0.0.1:8080",
},
cli.StringSliceFlag{
Name: "server_metadata",
EnvVar: "MICRO_SERVER_METADATA",
Value: &cli.StringSlice{},
Usage: "A list of key-value pairs defining metadata. version=1.0.0",
},
cli.StringFlag{
Name: "broker",
EnvVar: "MICRO_BROKER",
Usage: "Broker for pub/sub. http, nats, rabbitmq",
},
cli.StringFlag{
Name: "broker_address",
EnvVar: "MICRO_BROKER_ADDRESS",
Usage: "Comma-separated list of broker addresses",
},
cli.StringFlag{
Name: "registry",
EnvVar: "MICRO_REGISTRY",
Usage: "Registry for discovery. consul, mdns",
},
cli.StringFlag{
Name: "registry_address",
EnvVar: "MICRO_REGISTRY_ADDRESS",
Usage: "Comma-separated list of registry addresses",
},
cli.StringFlag{
Name: "selector",
EnvVar: "MICRO_SELECTOR",
Usage: "Selector used to pick nodes for querying",
},
cli.StringFlag{
Name: "transport",
EnvVar: "MICRO_TRANSPORT",
Usage: "Transport mechanism used; http",
},
cli.StringFlag{
Name: "transport_address",
EnvVar: "MICRO_TRANSPORT_ADDRESS",
Usage: "Comma-separated list of transport addresses",
},
}
DefaultBrokers = map[string]func(...broker.Option) broker.Broker{
"http": http.NewBroker,
"memory": memory.NewBroker,
}
DefaultClients = map[string]func(...client.Option) client.Client{
"rpc": client.NewClient,
}
DefaultRegistries = map[string]func(...registry.Option) registry.Registry{
"consul": consul.NewRegistry,
"gossip": gossip.NewRegistry,
"mdns": mdns.NewRegistry,
"memory": rmem.NewRegistry,
}
DefaultSelectors = map[string]func(...selector.Option) selector.Selector{
"default": selector.NewSelector,
"dns": dns.NewSelector,
"cache": selector.NewSelector,
"static": static.NewSelector,
}
DefaultServers = map[string]func(...server.Option) server.Server{
"rpc": server.NewServer,
}
DefaultTransports = map[string]func(...transport.Option) transport.Transport{
"memory": tmem.NewTransport,
"http": thttp.NewTransport,
}
// used for default selection as the fall back
defaultClient = "rpc"
defaultServer = "rpc"
defaultBroker = "http"
defaultRegistry = "mdns"
defaultSelector = "registry"
defaultTransport = "http"
)
func init() {
rand.Seed(time.Now().Unix())
help := cli.HelpPrinter
cli.HelpPrinter = func(writer io.Writer, templ string, data interface{}) {
help(writer, templ, data)
os.Exit(0)
}
}
func newCmd(opts ...Option) Cmd {
options := Options{
Broker: &broker.DefaultBroker,
Client: &client.DefaultClient,
Registry: &registry.DefaultRegistry,
Server: &server.DefaultServer,
Selector: &selector.DefaultSelector,
Transport: &transport.DefaultTransport,
Brokers: DefaultBrokers,
Clients: DefaultClients,
Registries: DefaultRegistries,
Selectors: DefaultSelectors,
Servers: DefaultServers,
Transports: DefaultTransports,
}
for _, o := range opts {
o(&options)
}
if len(options.Description) == 0 {
options.Description = "a go-micro service"
}
cmd := new(cmd)
cmd.opts = options
cmd.app = cli.NewApp()
cmd.app.Name = cmd.opts.Name
cmd.app.Version = cmd.opts.Version
cmd.app.Usage = cmd.opts.Description
cmd.app.Before = cmd.Before
cmd.app.Flags = DefaultFlags
cmd.app.Action = func(c *cli.Context) {}
if len(options.Version) == 0 {
cmd.app.HideVersion = true
}
return cmd
}
func (c *cmd) App() *cli.App {
return c.app
}
func (c *cmd) Options() Options {
return c.opts
}
func (c *cmd) Before(ctx *cli.Context) error {
// If flags are set then use them otherwise do nothing
var serverOpts []server.Option
var clientOpts []client.Option
// Set the client
if name := ctx.String("client"); len(name) > 0 {
// only change if we have the client and type differs
if cl, ok := c.opts.Clients[name]; ok && (*c.opts.Client).String() != name {
*c.opts.Client = cl()
}
}
// Set the server
if name := ctx.String("server"); len(name) > 0 {
// only change if we have the server and type differs
if s, ok := c.opts.Servers[name]; ok && (*c.opts.Server).String() != name {
*c.opts.Server = s()
}
}
// Set the broker
if name := ctx.String("broker"); len(name) > 0 && (*c.opts.Broker).String() != name {
b, ok := c.opts.Brokers[name]
if !ok {
return fmt.Errorf("Broker %s not found", name)
}
*c.opts.Broker = b()
serverOpts = append(serverOpts, server.Broker(*c.opts.Broker))
clientOpts = append(clientOpts, client.Broker(*c.opts.Broker))
}
// Set the registry
if name := ctx.String("registry"); len(name) > 0 && (*c.opts.Registry).String() != name {
r, ok := c.opts.Registries[name]
if !ok {
return fmt.Errorf("Registry %s not found", name)
}
*c.opts.Registry = r()
serverOpts = append(serverOpts, server.Registry(*c.opts.Registry))
clientOpts = append(clientOpts, client.Registry(*c.opts.Registry))
if err := (*c.opts.Selector).Init(selector.Registry(*c.opts.Registry)); err != nil {
log.Fatalf("Error configuring registry: %v", err)
}
clientOpts = append(clientOpts, client.Selector(*c.opts.Selector))
if err := (*c.opts.Broker).Init(broker.Registry(*c.opts.Registry)); err != nil {
log.Fatalf("Error configuring broker: %v", err)
}
}
// Set the selector
if name := ctx.String("selector"); len(name) > 0 && (*c.opts.Selector).String() != name {
s, ok := c.opts.Selectors[name]
if !ok {
return fmt.Errorf("Selector %s not found", name)
}
*c.opts.Selector = s(selector.Registry(*c.opts.Registry))
// No server option here. Should there be?
clientOpts = append(clientOpts, client.Selector(*c.opts.Selector))
}
// Set the transport
if name := ctx.String("transport"); len(name) > 0 && (*c.opts.Transport).String() != name {
t, ok := c.opts.Transports[name]
if !ok {
return fmt.Errorf("Transport %s not found", name)
}
*c.opts.Transport = t()
serverOpts = append(serverOpts, server.Transport(*c.opts.Transport))
clientOpts = append(clientOpts, client.Transport(*c.opts.Transport))
}
// Parse the server options
metadata := make(map[string]string)
for _, d := range ctx.StringSlice("server_metadata") {
var key, val string
parts := strings.Split(d, "=")
key = parts[0]
if len(parts) > 1 {
val = strings.Join(parts[1:], "=")
}
metadata[key] = val
}
if len(metadata) > 0 {
serverOpts = append(serverOpts, server.Metadata(metadata))
}
if len(ctx.String("broker_address")) > 0 {
if err := (*c.opts.Broker).Init(broker.Addrs(strings.Split(ctx.String("broker_address"), ",")...)); err != nil {
log.Fatalf("Error configuring broker: %v", err)
}
}
if len(ctx.String("registry_address")) > 0 {
if err := (*c.opts.Registry).Init(registry.Addrs(strings.Split(ctx.String("registry_address"), ",")...)); err != nil {
log.Fatalf("Error configuring registry: %v", err)
}
}
if len(ctx.String("transport_address")) > 0 {
if err := (*c.opts.Transport).Init(transport.Addrs(strings.Split(ctx.String("transport_address"), ",")...)); err != nil {
log.Fatalf("Error configuring transport: %v", err)
}
}
if len(ctx.String("server_name")) > 0 {
serverOpts = append(serverOpts, server.Name(ctx.String("server_name")))
}
if len(ctx.String("server_version")) > 0 {
serverOpts = append(serverOpts, server.Version(ctx.String("server_version")))
}
if len(ctx.String("server_id")) > 0 {
serverOpts = append(serverOpts, server.Id(ctx.String("server_id")))
}
if len(ctx.String("server_address")) > 0 {
serverOpts = append(serverOpts, server.Address(ctx.String("server_address")))
}
if len(ctx.String("server_advertise")) > 0 {
serverOpts = append(serverOpts, server.Advertise(ctx.String("server_advertise")))
}
if ttl := time.Duration(ctx.GlobalInt("register_ttl")); ttl > 0 {
serverOpts = append(serverOpts, server.RegisterTTL(ttl*time.Second))
}
if val := time.Duration(ctx.GlobalInt("register_interval")); val > 0 {
serverOpts = append(serverOpts, server.RegisterInterval(val*time.Second))
}
// client opts
if r := ctx.Int("client_retries"); r >= 0 {
clientOpts = append(clientOpts, client.Retries(r))
}
if t := ctx.String("client_request_timeout"); len(t) > 0 {
d, err := time.ParseDuration(t)
if err != nil {
return fmt.Errorf("failed to parse client_request_timeout: %v", t)
}
clientOpts = append(clientOpts, client.RequestTimeout(d))
}
if r := ctx.Int("client_pool_size"); r > 0 {
clientOpts = append(clientOpts, client.PoolSize(r))
}
if t := ctx.String("client_pool_ttl"); len(t) > 0 {
d, err := time.ParseDuration(t)
if err != nil {
return fmt.Errorf("failed to parse client_pool_ttl: %v", t)
}
clientOpts = append(clientOpts, client.PoolTTL(d))
}
// We have some command line opts for the server.
// Lets set it up
if len(serverOpts) > 0 {
if err := (*c.opts.Server).Init(serverOpts...); err != nil {
log.Fatalf("Error configuring server: %v", err)
}
}
// Use an init option?
if len(clientOpts) > 0 {
if err := (*c.opts.Client).Init(clientOpts...); err != nil {
log.Fatalf("Error configuring client: %v", err)
}
}
return nil
}
func (c *cmd) Init(opts ...Option) error {
for _, o := range opts {
o(&c.opts)
}
c.app.Name = c.opts.Name
c.app.Version = c.opts.Version
c.app.HideVersion = len(c.opts.Version) == 0
c.app.Usage = c.opts.Description
c.app.RunAndExitOnError()
return nil
}
func DefaultOptions() Options {
return DefaultCmd.Options()
}
func App() *cli.App {
return DefaultCmd.App()
}
func Init(opts ...Option) error {
return DefaultCmd.Init(opts...)
}
func NewCmd(opts ...Option) Cmd {
return newCmd(opts...)
}

View File

@@ -1,137 +0,0 @@
package cmd
import (
"context"
"github.com/micro/go-micro/broker"
"github.com/micro/go-micro/client"
"github.com/micro/go-micro/registry"
"github.com/micro/go-micro/selector"
"github.com/micro/go-micro/server"
"github.com/micro/go-micro/transport"
)
type Options struct {
// For the Command Line itself
Name string
Description string
Version string
// We need pointers to things so we can swap them out if needed.
Broker *broker.Broker
Registry *registry.Registry
Selector *selector.Selector
Transport *transport.Transport
Client *client.Client
Server *server.Server
Brokers map[string]func(...broker.Option) broker.Broker
Clients map[string]func(...client.Option) client.Client
Registries map[string]func(...registry.Option) registry.Registry
Selectors map[string]func(...selector.Option) selector.Selector
Servers map[string]func(...server.Option) server.Server
Transports map[string]func(...transport.Option) transport.Transport
// Other options for implementations of the interface
// can be stored in a context
Context context.Context
}
// Command line Name
func Name(n string) Option {
return func(o *Options) {
o.Name = n
}
}
// Command line Description
func Description(d string) Option {
return func(o *Options) {
o.Description = d
}
}
// Command line Version
func Version(v string) Option {
return func(o *Options) {
o.Version = v
}
}
func Broker(b *broker.Broker) Option {
return func(o *Options) {
o.Broker = b
}
}
func Selector(s *selector.Selector) Option {
return func(o *Options) {
o.Selector = s
}
}
func Registry(r *registry.Registry) Option {
return func(o *Options) {
o.Registry = r
}
}
func Transport(t *transport.Transport) Option {
return func(o *Options) {
o.Transport = t
}
}
func Client(c *client.Client) Option {
return func(o *Options) {
o.Client = c
}
}
func Server(s *server.Server) Option {
return func(o *Options) {
o.Server = s
}
}
// New broker func
func NewBroker(name string, b func(...broker.Option) broker.Broker) Option {
return func(o *Options) {
o.Brokers[name] = b
}
}
// New client func
func NewClient(name string, b func(...client.Option) client.Client) Option {
return func(o *Options) {
o.Clients[name] = b
}
}
// New registry func
func NewRegistry(name string, r func(...registry.Option) registry.Registry) Option {
return func(o *Options) {
o.Registries[name] = r
}
}
// New selector func
func NewSelector(name string, s func(...selector.Option) selector.Selector) Option {
return func(o *Options) {
o.Selectors[name] = s
}
}
// New server func
func NewServer(name string, s func(...server.Option) server.Server) Option {
return func(o *Options) {
o.Servers[name] = s
}
}
// New transport func
func NewTransport(name string, t func(...transport.Option) transport.Transport) Option {
return func(o *Options) {
o.Transports[name] = t
}
}

View File

@@ -1,75 +0,0 @@
// Package bytes provides a bytes codec which does not encode or decode anything
package bytes
import (
"fmt"
"io"
"io/ioutil"
"github.com/micro/go-micro/codec"
)
type Codec struct {
Conn io.ReadWriteCloser
}
// Frame gives us the ability to define raw data to send over the pipes
type Frame struct {
Data []byte
}
func (c *Codec) ReadHeader(m *codec.Message, t codec.MessageType) error {
return nil
}
func (c *Codec) ReadBody(b interface{}) error {
// read bytes
buf, err := ioutil.ReadAll(c.Conn)
if err != nil {
return err
}
switch b.(type) {
case *[]byte:
v := b.(*[]byte)
*v = buf
case *Frame:
v := b.(*Frame)
v.Data = buf
default:
return fmt.Errorf("failed to read body: %v is not type of *[]byte", b)
}
return nil
}
func (c *Codec) Write(m *codec.Message, b interface{}) error {
var v []byte
switch b.(type) {
case *Frame:
v = b.(*Frame).Data
case *[]byte:
ve := b.(*[]byte)
v = *ve
case []byte:
v = b.([]byte)
default:
return fmt.Errorf("failed to write: %v is not type of *[]byte or []byte", b)
}
_, err := c.Conn.Write(v)
return err
}
func (c *Codec) Close() error {
return c.Conn.Close()
}
func (c *Codec) String() string {
return "bytes"
}
func NewCodec(c io.ReadWriteCloser) codec.Codec {
return &Codec{
Conn: c,
}
}

View File

@@ -1,41 +0,0 @@
package bytes
import (
"errors"
)
type Marshaler struct{}
type Message struct {
Header map[string]string
Body []byte
}
func (n Marshaler) Marshal(v interface{}) ([]byte, error) {
switch v.(type) {
case *[]byte:
ve := v.(*[]byte)
return *ve, nil
case []byte:
return v.([]byte), nil
case *Message:
return v.(*Message).Body, nil
}
return nil, errors.New("invalid message")
}
func (n Marshaler) Unmarshal(d []byte, v interface{}) error {
switch v.(type) {
case *[]byte:
ve := v.(*[]byte)
*ve = d
case *Message:
ve := v.(*Message)
ve.Body = d
}
return errors.New("invalid message")
}
func (n Marshaler) String() string {
return "bytes"
}

View File

@@ -2,62 +2,76 @@
package codec
import (
"io"
"errors"
"gopkg.in/yaml.v3"
)
const (
Error MessageType = iota
Request
Response
Publication
var (
// ErrInvalidMessage returned when invalid messge passed to codec
ErrInvalidMessage = errors.New("invalid message")
// ErrUnknownContentType returned when content-type is unknown
ErrUnknownContentType = errors.New("unknown content-type")
)
type MessageType int
var (
// DefaultCodec is the global default codec
DefaultCodec = NewCodec()
// DefaultTagName specifies struct tag name to control codec Marshal/Unmarshal
DefaultTagName = "codec"
)
// Takes in a connection/buffer and returns a new Codec
type NewCodec func(io.ReadWriteCloser) Codec
// Codec encodes/decodes various types of messages used within go-micro.
// ReadHeader and ReadBody are called in pairs to read requests/responses
// from the connection. Close is called when finished with the
// connection. ReadBody may be called with a nil argument to force the
// body to be read and discarded.
// Codec encodes/decodes various types of messages.
type Codec interface {
Reader
Writer
Close() error
Marshal(v interface{}, opts ...Option) ([]byte, error)
Unmarshal(b []byte, v interface{}, opts ...Option) error
String() string
}
type Reader interface {
ReadHeader(*Message, MessageType) error
ReadBody(interface{}) error
}
type Writer interface {
Write(*Message, interface{}) error
}
// Marshaler is a simple encoding interface used for the broker/transport
// where headers are not supported by the underlying implementation.
type Marshaler interface {
Marshal(interface{}) ([]byte, error)
Unmarshal([]byte, interface{}) error
type CodecV2 interface {
Marshal(buf []byte, v interface{}, opts ...Option) ([]byte, error)
Unmarshal(buf []byte, v interface{}, opts ...Option) error
String() string
}
// Message represents detailed information about
// the communication, likely followed by the body.
// In the case of an error, body may be nil.
type Message struct {
Id string
Type MessageType
Target string
Method string
Endpoint string
Error string
// RawMessage is a raw encoded JSON value.
// It implements Marshaler and Unmarshaler and can be used to delay decoding or precompute a encoding.
type RawMessage []byte
// The values read from the socket
Header map[string]string
Body []byte
// MarshalJSON returns m as the JSON encoding of m.
func (m *RawMessage) MarshalJSON() ([]byte, error) {
if m == nil {
return []byte("null"), nil
} else if len(*m) == 0 {
return []byte("null"), nil
}
return *m, nil
}
// UnmarshalJSON sets *m to a copy of data.
func (m *RawMessage) UnmarshalJSON(data []byte) error {
if m == nil {
return errors.New("RawMessage UnmarshalJSON on nil pointer")
}
*m = append((*m)[0:0], data...)
return nil
}
// MarshalYAML returns m as the JSON encoding of m.
func (m *RawMessage) MarshalYAML() ([]byte, error) {
if m == nil {
return []byte("null"), nil
} else if len(*m) == 0 {
return []byte("null"), nil
}
return *m, nil
}
// UnmarshalYAML sets *m to a copy of data.
func (m *RawMessage) UnmarshalYAML(n *yaml.Node) error {
if m == nil {
return errors.New("RawMessage UnmarshalYAML on nil pointer")
}
*m = append((*m)[0:0], []byte(n.Value)...)
return nil
}

43
codec/context.go Normal file
View File

@@ -0,0 +1,43 @@
package codec
import (
"context"
)
type codecKey struct{}
// FromContext returns codec from context
func FromContext(ctx context.Context) (Codec, bool) {
if ctx == nil {
return nil, false
}
c, ok := ctx.Value(codecKey{}).(Codec)
return c, ok
}
// MustContext returns codec from context
func MustContext(ctx context.Context) Codec {
c, ok := FromContext(ctx)
if !ok {
panic("missing codec")
}
return c
}
// NewContext put codec in context
func NewContext(ctx context.Context, c Codec) context.Context {
if ctx == nil {
ctx = context.Background()
}
return context.WithValue(ctx, codecKey{}, c)
}
// SetOption returns a function to setup a context with given value
func SetOption(k, v interface{}) Option {
return func(o *Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, k, v)
}
}

35
codec/context_test.go Normal file
View File

@@ -0,0 +1,35 @@
package codec
import (
"context"
"testing"
)
func TestFromContext(t *testing.T) {
ctx := context.WithValue(context.TODO(), codecKey{}, NewCodec())
c, ok := FromContext(ctx)
if c == nil || !ok {
t.Fatal("FromContext not works")
}
}
func TestNewContext(t *testing.T) {
ctx := NewContext(context.TODO(), NewCodec())
c, ok := FromContext(ctx)
if c == nil || !ok {
t.Fatal("NewContext not works")
}
}
func TestSetOption(t *testing.T) {
type key struct{}
o := SetOption(key{}, "test")
opts := &Options{}
o(opts)
if v, ok := opts.Context.Value(key{}).(string); !ok || v == "" {
t.Fatal("SetOption not works")
}
}

58
codec/frame.go Normal file
View File

@@ -0,0 +1,58 @@
package codec
import "gopkg.in/yaml.v3"
// Frame gives us the ability to define raw data to send over the pipes
type Frame struct {
Data []byte
}
// NewFrame returns new frame with data
func NewFrame(data []byte) *Frame {
return &Frame{Data: data}
}
// MarshalJSON returns frame data
func (m *Frame) MarshalJSON() ([]byte, error) {
return m.Marshal()
}
// UnmarshalJSON set frame data
func (m *Frame) UnmarshalJSON(data []byte) error {
return m.Unmarshal(data)
}
// MarshalYAML returns frame data
func (m *Frame) MarshalYAML() ([]byte, error) {
return m.Marshal()
}
// UnmarshalYAML set frame data
func (m *Frame) UnmarshalYAML(n *yaml.Node) error {
m.Data = []byte(n.Value)
return nil
}
// ProtoMessage noop func
func (m *Frame) ProtoMessage() {}
// Reset resets frame
func (m *Frame) Reset() {
*m = Frame{}
}
// String returns frame as string
func (m *Frame) String() string {
return string(m.Data)
}
// Marshal returns frame data
func (m *Frame) Marshal() ([]byte, error) {
return m.Data, nil
}
// Unmarshal set frame data
func (m *Frame) Unmarshal(data []byte) error {
m.Data = data
return nil
}

28
codec/frame.proto Normal file
View File

@@ -0,0 +1,28 @@
// Copyright 2021 Unistack LLC
//
// 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.
syntax = "proto3";
package micro.codec;
option cc_enable_arenas = true;
option go_package = "go.unistack.org/micro/v3/codec;codec";
option java_multiple_files = true;
option java_outer_classname = "MicroCodec";
option java_package = "micro.codec";
option objc_class_prefix = "MCODEC";
message Frame {
bytes data = 1;
}

View File

@@ -1,132 +0,0 @@
// Package grpc provides a grpc codec
package grpc
import (
"encoding/json"
"errors"
"fmt"
"io"
"strings"
"github.com/golang/protobuf/proto"
"github.com/micro/go-micro/codec"
)
type Codec struct {
Conn io.ReadWriteCloser
ContentType string
}
func (c *Codec) ReadHeader(m *codec.Message, t codec.MessageType) error {
if ct := m.Header["Content-Type"]; len(ct) > 0 {
c.ContentType = ct
}
if ct := m.Header["content-type"]; len(ct) > 0 {
c.ContentType = ct
}
// service method
path := m.Header[":path"]
if len(path) == 0 || path[0] != '/' {
m.Target = m.Header["Micro-Service"]
m.Endpoint = m.Header["Micro-Endpoint"]
} else {
// [ , a.package.Foo, Bar]
parts := strings.Split(path, "/")
if len(parts) != 3 {
return errors.New("Unknown request path")
}
service := strings.Split(parts[1], ".")
m.Endpoint = strings.Join([]string{service[len(service)-1], parts[2]}, ".")
m.Target = strings.Join(service[:len(service)-1], ".")
}
return nil
}
func (c *Codec) ReadBody(b interface{}) error {
// no body
if b == nil {
return nil
}
_, buf, err := decode(c.Conn)
if err != nil {
return err
}
switch c.ContentType {
case "application/grpc+json":
return json.Unmarshal(buf, b)
case "application/grpc+proto", "application/grpc":
return proto.Unmarshal(buf, b.(proto.Message))
}
return errors.New("Unsupported Content-Type")
}
func (c *Codec) Write(m *codec.Message, b interface{}) error {
var buf []byte
var err error
if ct := m.Header["Content-Type"]; len(ct) > 0 {
c.ContentType = ct
}
if ct := m.Header["content-type"]; len(ct) > 0 {
c.ContentType = ct
}
switch m.Type {
case codec.Request:
parts := strings.Split(m.Endpoint, ".")
m.Header[":method"] = "POST"
m.Header[":path"] = fmt.Sprintf("/%s.%s/%s", m.Target, parts[0], parts[1])
m.Header[":proto"] = "HTTP/2.0"
m.Header["te"] = "trailers"
m.Header["user-agent"] = "grpc-go/1.0.0"
m.Header[":authority"] = m.Target
m.Header["content-type"] = c.ContentType
case codec.Response:
m.Header["Trailer"] = "grpc-status, grpc-message"
m.Header["grpc-status"] = "0"
m.Header["grpc-message"] = ""
}
// marshal content
switch c.ContentType {
case "application/grpc+json":
buf, err = json.Marshal(b)
case "application/grpc+proto", "application/grpc":
pb, ok := b.(proto.Message)
if ok {
buf, err = proto.Marshal(pb)
}
default:
err = errors.New("Unsupported Content-Type")
}
// check error
if err != nil {
m.Header["grpc-status"] = "8"
m.Header["grpc-message"] = err.Error()
return err
}
return encode(0, buf, c.Conn)
}
func (c *Codec) Close() error {
return c.Conn.Close()
}
func (c *Codec) String() string {
return "grpc"
}
func NewCodec(c io.ReadWriteCloser) codec.Codec {
return &Codec{
Conn: c,
ContentType: "application/grpc",
}
}

View File

@@ -1,70 +0,0 @@
package grpc
import (
"encoding/binary"
"fmt"
"io"
)
var (
maxMessageSize = 1024 * 1024 * 4
maxInt = int(^uint(0) >> 1)
)
func decode(r io.Reader) (uint8, []byte, error) {
header := make([]byte, 5)
// read the header
if _, err := r.Read(header[:]); err != nil {
return uint8(0), nil, err
}
// get encoding format e.g compressed
cf := uint8(header[0])
// get message length
length := binary.BigEndian.Uint32(header[1:])
// no encoding format
if length == 0 {
return cf, nil, nil
}
//
if int64(length) > int64(maxInt) {
return cf, nil, fmt.Errorf("grpc: received message larger than max length allowed on current machine (%d vs. %d)", length, maxInt)
}
if int(length) > maxMessageSize {
return cf, nil, fmt.Errorf("grpc: received message larger than max (%d vs. %d)", length, maxMessageSize)
}
msg := make([]byte, int(length))
if _, err := r.Read(msg); err != nil {
if err == io.EOF {
err = io.ErrUnexpectedEOF
}
return cf, nil, err
}
return cf, msg, nil
}
func encode(cf uint8, buf []byte, w io.Writer) error {
header := make([]byte, 5)
// set compression
header[0] = byte(cf)
// write length as header
binary.BigEndian.PutUint32(header[1:], uint32(len(buf)))
// read the header
if _, err := w.Write(header[:]); err != nil {
return err
}
// write the buffer
_, err := w.Write(buf)
return err
}

View File

@@ -1,49 +0,0 @@
// Package json provides a json codec
package json
import (
"encoding/json"
"io"
"github.com/micro/go-micro/codec"
)
type Codec struct {
Conn io.ReadWriteCloser
Encoder *json.Encoder
Decoder *json.Decoder
}
func (c *Codec) ReadHeader(m *codec.Message, t codec.MessageType) error {
return nil
}
func (c *Codec) ReadBody(b interface{}) error {
if b == nil {
return nil
}
return c.Decoder.Decode(b)
}
func (c *Codec) Write(m *codec.Message, b interface{}) error {
if b == nil {
return nil
}
return c.Encoder.Encode(b)
}
func (c *Codec) Close() error {
return c.Conn.Close()
}
func (c *Codec) String() string {
return "json"
}
func NewCodec(c io.ReadWriteCloser) codec.Codec {
return &Codec{
Conn: c,
Decoder: json.NewDecoder(c),
Encoder: json.NewEncoder(c),
}
}

View File

@@ -1,19 +0,0 @@
package json
import (
"encoding/json"
)
type Marshaler struct{}
func (j Marshaler) Marshal(v interface{}) ([]byte, error) {
return json.Marshal(v)
}
func (j Marshaler) Unmarshal(d []byte, v interface{}) error {
return json.Unmarshal(d, v)
}
func (j Marshaler) String() string {
return "json"
}

View File

@@ -1,97 +0,0 @@
package jsonrpc
import (
"encoding/json"
"fmt"
"io"
"sync"
"github.com/micro/go-micro/codec"
)
type clientCodec struct {
dec *json.Decoder // for reading JSON values
enc *json.Encoder // for writing JSON values
c io.Closer
// temporary work space
req clientRequest
resp clientResponse
sync.Mutex
pending map[interface{}]string
}
type clientRequest struct {
Method string `json:"method"`
Params [1]interface{} `json:"params"`
ID interface{} `json:"id"`
}
type clientResponse struct {
ID interface{} `json:"id"`
Result *json.RawMessage `json:"result"`
Error interface{} `json:"error"`
}
func newClientCodec(conn io.ReadWriteCloser) *clientCodec {
return &clientCodec{
dec: json.NewDecoder(conn),
enc: json.NewEncoder(conn),
c: conn,
pending: make(map[interface{}]string),
}
}
func (c *clientCodec) Write(m *codec.Message, b interface{}) error {
c.Lock()
c.pending[m.Id] = m.Method
c.Unlock()
c.req.Method = m.Method
c.req.Params[0] = b
c.req.ID = m.Id
return c.enc.Encode(&c.req)
}
func (r *clientResponse) reset() {
r.ID = 0
r.Result = nil
r.Error = nil
}
func (c *clientCodec) ReadHeader(m *codec.Message) error {
c.resp.reset()
if err := c.dec.Decode(&c.resp); err != nil {
return err
}
c.Lock()
m.Method = c.pending[c.resp.ID]
delete(c.pending, c.resp.ID)
c.Unlock()
m.Error = ""
m.Id = fmt.Sprintf("%v", c.resp.ID)
if c.resp.Error != nil {
x, ok := c.resp.Error.(string)
if !ok {
return fmt.Errorf("invalid error %v", c.resp.Error)
}
if x == "" {
x = "unspecified error"
}
m.Error = x
}
return nil
}
func (c *clientCodec) ReadBody(x interface{}) error {
if x == nil || c.resp.Result == nil {
return nil
}
return json.Unmarshal(*c.resp.Result, x)
}
func (c *clientCodec) Close() error {
return c.c.Close()
}

View File

@@ -1,89 +0,0 @@
// Package jsonrpc provides a json-rpc 1.0 codec
package jsonrpc
import (
"bytes"
"encoding/json"
"fmt"
"io"
"github.com/micro/go-micro/codec"
)
type jsonCodec struct {
buf *bytes.Buffer
mt codec.MessageType
rwc io.ReadWriteCloser
c *clientCodec
s *serverCodec
}
func (j *jsonCodec) Close() error {
j.buf.Reset()
return j.rwc.Close()
}
func (j *jsonCodec) String() string {
return "json-rpc"
}
func (j *jsonCodec) Write(m *codec.Message, b interface{}) error {
switch m.Type {
case codec.Request:
return j.c.Write(m, b)
case codec.Response, codec.Error:
return j.s.Write(m, b)
case codec.Publication:
data, err := json.Marshal(b)
if err != nil {
return err
}
_, err = j.rwc.Write(data)
return err
default:
return fmt.Errorf("Unrecognised message type: %v", m.Type)
}
}
func (j *jsonCodec) ReadHeader(m *codec.Message, mt codec.MessageType) error {
j.buf.Reset()
j.mt = mt
switch mt {
case codec.Request:
return j.s.ReadHeader(m)
case codec.Response:
return j.c.ReadHeader(m)
case codec.Publication:
_, err := io.Copy(j.buf, j.rwc)
return err
default:
return fmt.Errorf("Unrecognised message type: %v", mt)
}
return nil
}
func (j *jsonCodec) ReadBody(b interface{}) error {
switch j.mt {
case codec.Request:
return j.s.ReadBody(b)
case codec.Response:
return j.c.ReadBody(b)
case codec.Publication:
if b != nil {
return json.Unmarshal(j.buf.Bytes(), b)
}
default:
return fmt.Errorf("Unrecognised message type: %v", j.mt)
}
return nil
}
func NewCodec(rwc io.ReadWriteCloser) codec.Codec {
return &jsonCodec{
buf: bytes.NewBuffer(nil),
rwc: rwc,
c: newClientCodec(rwc),
s: newServerCodec(rwc),
}
}

View File

@@ -1,87 +0,0 @@
package jsonrpc
import (
"encoding/json"
"fmt"
"io"
"github.com/micro/go-micro/codec"
)
type serverCodec struct {
dec *json.Decoder // for reading JSON values
enc *json.Encoder // for writing JSON values
c io.Closer
// temporary work space
req serverRequest
resp serverResponse
}
type serverRequest struct {
Method string `json:"method"`
Params *json.RawMessage `json:"params"`
ID interface{} `json:"id"`
}
type serverResponse struct {
ID interface{} `json:"id"`
Result interface{} `json:"result"`
Error interface{} `json:"error"`
}
func newServerCodec(conn io.ReadWriteCloser) *serverCodec {
return &serverCodec{
dec: json.NewDecoder(conn),
enc: json.NewEncoder(conn),
c: conn,
}
}
func (r *serverRequest) reset() {
r.Method = ""
if r.Params != nil {
*r.Params = (*r.Params)[0:0]
}
if r.ID != nil {
r.ID = nil
}
}
func (c *serverCodec) ReadHeader(m *codec.Message) error {
c.req.reset()
if err := c.dec.Decode(&c.req); err != nil {
return err
}
m.Method = c.req.Method
m.Id = fmt.Sprintf("%v", c.req.ID)
c.req.ID = nil
return nil
}
func (c *serverCodec) ReadBody(x interface{}) error {
if x == nil {
return nil
}
var params [1]interface{}
params[0] = x
return json.Unmarshal(*c.req.Params, &params)
}
var null = json.RawMessage([]byte("null"))
func (c *serverCodec) Write(m *codec.Message, x interface{}) error {
var resp serverResponse
resp.ID = m.Id
resp.Result = x
if m.Error == "" {
resp.Error = nil
} else {
resp.Error = m.Error
}
return c.enc.Encode(resp)
}
func (c *serverCodec) Close() error {
return c.c.Close()
}

68
codec/noop.go Normal file
View File

@@ -0,0 +1,68 @@
package codec
import (
"encoding/json"
codecpb "go.unistack.org/micro-proto/v3/codec"
)
type noopCodec struct {
opts Options
}
func (c *noopCodec) String() string {
return "noop"
}
// NewCodec returns new noop codec
func NewCodec(opts ...Option) Codec {
return &noopCodec{opts: NewOptions(opts...)}
}
func (c *noopCodec) Marshal(v interface{}, opts ...Option) ([]byte, error) {
if v == nil {
return nil, nil
}
switch ve := v.(type) {
case string:
return []byte(ve), nil
case *string:
return []byte(*ve), nil
case *[]byte:
return *ve, nil
case []byte:
return ve, nil
case *Frame:
return ve.Data, nil
case *codecpb.Frame:
return ve.Data, nil
}
return json.Marshal(v)
}
func (c *noopCodec) Unmarshal(d []byte, v interface{}, opts ...Option) error {
if v == nil {
return nil
}
switch ve := v.(type) {
case *string:
*ve = string(d)
return nil
case []byte:
copy(ve, d)
return nil
case *[]byte:
*ve = d
return nil
case *Frame:
ve.Data = d
return nil
case *codecpb.Frame:
ve.Data = d
return nil
}
return json.Unmarshal(d, v)
}

48
codec/noop_test.go Normal file
View File

@@ -0,0 +1,48 @@
package codec
import (
"bytes"
"testing"
)
func TestNoopBytesPtr(t *testing.T) {
req := []byte("test req")
rsp := make([]byte, len(req))
nc := NewCodec()
if err := nc.Unmarshal(req, &rsp); err != nil {
t.Fatal(err)
}
if !bytes.Equal(req, rsp) {
t.Fatalf("req not eq rsp: %s != %s", req, rsp)
}
}
func TestNoopBytes(t *testing.T) {
req := []byte("test req")
var rsp []byte
nc := NewCodec()
if err := nc.Unmarshal(req, &rsp); err != nil {
t.Fatal(err)
}
if !bytes.Equal(req, rsp) {
t.Fatalf("req not eq rsp: %s != %s", req, rsp)
}
}
func TestNoopString(t *testing.T) {
req := []byte("test req")
var rsp string
nc := NewCodec()
if err := nc.Unmarshal(req, &rsp); err != nil {
t.Fatal(err)
}
if !bytes.Equal(req, []byte(rsp)) {
t.Fatalf("req not eq rsp: %s != %s", req, rsp)
}
}

81
codec/options.go Normal file
View File

@@ -0,0 +1,81 @@
package codec
import (
"context"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/meter"
"go.unistack.org/micro/v3/tracer"
)
// Option func
type Option func(*Options)
// Options contains codec options
type Options struct {
// Meter used for metrics
Meter meter.Meter
// Logger used for logging
Logger logger.Logger
// Tracer used for tracing
Tracer tracer.Tracer
// Context stores additional codec options
Context context.Context
// TagName specifies tag name in struct to control codec
TagName string
// Flatten specifies that struct must be analyzed for flatten tag
Flatten bool
}
// TagName sets the codec tag name in struct
func TagName(n string) Option {
return func(o *Options) {
o.TagName = n
}
}
// Flatten enables checking for flatten tag name
func Flatten(b bool) Option {
return func(o *Options) {
o.Flatten = b
}
}
// Logger sets the logger
func Logger(l logger.Logger) Option {
return func(o *Options) {
o.Logger = l
}
}
// Tracer to be used for tracing
func Tracer(t tracer.Tracer) Option {
return func(o *Options) {
o.Tracer = t
}
}
// Meter sets the meter
func Meter(m meter.Meter) Option {
return func(o *Options) {
o.Meter = m
}
}
// NewOptions returns new options
func NewOptions(opts ...Option) Options {
options := Options{
Context: context.Background(),
Logger: logger.DefaultLogger,
Meter: meter.DefaultMeter,
Tracer: tracer.DefaultTracer,
TagName: DefaultTagName,
Flatten: false,
}
for _, o := range opts {
o(&options)
}
return options
}

View File

@@ -1,19 +0,0 @@
package proto
import (
"github.com/golang/protobuf/proto"
)
type Marshaler struct{}
func (Marshaler) Marshal(v interface{}) ([]byte, error) {
return proto.Marshal(v.(proto.Message))
}
func (Marshaler) Unmarshal(data []byte, v interface{}) error {
return proto.Unmarshal(data, v.(proto.Message))
}
func (Marshaler) Name() string {
return "proto"
}

View File

@@ -1,56 +0,0 @@
// Package proto provides a proto codec
package proto
import (
"io"
"io/ioutil"
"github.com/golang/protobuf/proto"
"github.com/micro/go-micro/codec"
)
type Codec struct {
Conn io.ReadWriteCloser
}
func (c *Codec) ReadHeader(m *codec.Message, t codec.MessageType) error {
return nil
}
func (c *Codec) ReadBody(b interface{}) error {
if b == nil {
return nil
}
buf, err := ioutil.ReadAll(c.Conn)
if err != nil {
return err
}
return proto.Unmarshal(buf, b.(proto.Message))
}
func (c *Codec) Write(m *codec.Message, b interface{}) error {
p, ok := b.(proto.Message)
if !ok {
return nil
}
buf, err := proto.Marshal(p)
if err != nil {
return err
}
_, err = c.Conn.Write(buf)
return err
}
func (c *Codec) Close() error {
return c.Conn.Close()
}
func (c *Codec) String() string {
return "proto"
}
func NewCodec(c io.ReadWriteCloser) codec.Codec {
return &Codec{
Conn: c,
}
}

View File

@@ -1,83 +0,0 @@
// Code generated by protoc-gen-go.
// source: envelope.proto
// DO NOT EDIT!
/*
Package proto is a generated protocol buffer package.
It is generated from these files:
envelope.proto
It has these top-level messages:
Request
Response
*/
package protorpc
import proto "github.com/golang/protobuf/proto"
import json "encoding/json"
import math "math"
// Reference proto, json, and math imports to suppress error if they are not otherwise used.
var _ = proto.Marshal
var _ = &json.SyntaxError{}
var _ = math.Inf
type Request struct {
ServiceMethod *string `protobuf:"bytes,1,opt,name=service_method" json:"service_method,omitempty"`
Seq *uint64 `protobuf:"fixed64,2,opt,name=seq" json:"seq,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *Request) Reset() { *m = Request{} }
func (m *Request) String() string { return proto.CompactTextString(m) }
func (*Request) ProtoMessage() {}
func (m *Request) GetServiceMethod() string {
if m != nil && m.ServiceMethod != nil {
return *m.ServiceMethod
}
return ""
}
func (m *Request) GetSeq() uint64 {
if m != nil && m.Seq != nil {
return *m.Seq
}
return 0
}
type Response struct {
ServiceMethod *string `protobuf:"bytes,1,opt,name=service_method" json:"service_method,omitempty"`
Seq *uint64 `protobuf:"fixed64,2,opt,name=seq" json:"seq,omitempty"`
Error *string `protobuf:"bytes,3,opt,name=error" json:"error,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *Response) Reset() { *m = Response{} }
func (m *Response) String() string { return proto.CompactTextString(m) }
func (*Response) ProtoMessage() {}
func (m *Response) GetServiceMethod() string {
if m != nil && m.ServiceMethod != nil {
return *m.ServiceMethod
}
return ""
}
func (m *Response) GetSeq() uint64 {
if m != nil && m.Seq != nil {
return *m.Seq
}
return 0
}
func (m *Response) GetError() string {
if m != nil && m.Error != nil {
return *m.Error
}
return ""
}
func init() {
}

View File

@@ -1,12 +0,0 @@
package protorpc;
message Request {
optional string service_method = 1;
optional fixed64 seq = 2;
}
message Response {
optional string service_method = 1;
optional fixed64 seq = 2;
optional string error = 3;
}

View File

@@ -1,36 +0,0 @@
package protorpc
import (
"encoding/binary"
"io"
)
// WriteNetString writes data to a big-endian netstring on a Writer.
// Size is always a 32-bit unsigned int.
func WriteNetString(w io.Writer, data []byte) (written int, err error) {
size := make([]byte, 4)
binary.BigEndian.PutUint32(size, uint32(len(data)))
if written, err = w.Write(size); err != nil {
return
}
return w.Write(data)
}
// ReadNetString reads data from a big-endian netstring.
func ReadNetString(r io.Reader) (data []byte, err error) {
sizeBuf := make([]byte, 4)
_, err = r.Read(sizeBuf)
if err != nil {
return nil, err
}
size := binary.BigEndian.Uint32(sizeBuf)
if size == 0 {
return nil, nil
}
data = make([]byte, size)
_, err = r.Read(data)
if err != nil {
return nil, err
}
return
}

View File

@@ -1,178 +0,0 @@
// Protorpc provides a net/rpc proto-rpc codec. See envelope.proto for the format.
package protorpc
import (
"bytes"
"fmt"
"io"
"strconv"
"sync"
"github.com/golang/protobuf/proto"
"github.com/micro/go-micro/codec"
)
type flusher interface {
Flush() error
}
type protoCodec struct {
sync.Mutex
rwc io.ReadWriteCloser
mt codec.MessageType
buf *bytes.Buffer
}
func (c *protoCodec) Close() error {
c.buf.Reset()
return c.rwc.Close()
}
func (c *protoCodec) String() string {
return "proto-rpc"
}
func id(id string) *uint64 {
p, err := strconv.ParseInt(id, 10, 64)
if err != nil {
p = 0
}
i := uint64(p)
return &i
}
func (c *protoCodec) Write(m *codec.Message, b interface{}) error {
switch m.Type {
case codec.Request:
c.Lock()
defer c.Unlock()
// This is protobuf, of course we copy it.
pbr := &Request{ServiceMethod: &m.Method, Seq: id(m.Id)}
data, err := proto.Marshal(pbr)
if err != nil {
return err
}
_, err = WriteNetString(c.rwc, data)
if err != nil {
return err
}
// Of course this is a protobuf! Trust me or detonate the program.
data, err = proto.Marshal(b.(proto.Message))
if err != nil {
return err
}
_, err = WriteNetString(c.rwc, data)
if err != nil {
return err
}
if flusher, ok := c.rwc.(flusher); ok {
if err = flusher.Flush(); err != nil {
return err
}
}
case codec.Response, codec.Error:
c.Lock()
defer c.Unlock()
rtmp := &Response{ServiceMethod: &m.Method, Seq: id(m.Id), Error: &m.Error}
data, err := proto.Marshal(rtmp)
if err != nil {
return err
}
_, err = WriteNetString(c.rwc, data)
if err != nil {
return err
}
if pb, ok := b.(proto.Message); ok {
data, err = proto.Marshal(pb)
if err != nil {
return err
}
} else {
data = nil
}
_, err = WriteNetString(c.rwc, data)
if err != nil {
return err
}
if flusher, ok := c.rwc.(flusher); ok {
if err = flusher.Flush(); err != nil {
return err
}
}
case codec.Publication:
data, err := proto.Marshal(b.(proto.Message))
if err != nil {
return err
}
c.rwc.Write(data)
default:
return fmt.Errorf("Unrecognised message type: %v", m.Type)
}
return nil
}
func (c *protoCodec) ReadHeader(m *codec.Message, mt codec.MessageType) error {
c.buf.Reset()
c.mt = mt
switch mt {
case codec.Request:
data, err := ReadNetString(c.rwc)
if err != nil {
return err
}
rtmp := new(Request)
err = proto.Unmarshal(data, rtmp)
if err != nil {
return err
}
m.Method = rtmp.GetServiceMethod()
m.Id = fmt.Sprintf("%d", rtmp.GetSeq())
case codec.Response:
data, err := ReadNetString(c.rwc)
if err != nil {
return err
}
rtmp := new(Response)
err = proto.Unmarshal(data, rtmp)
if err != nil {
return err
}
m.Method = rtmp.GetServiceMethod()
m.Id = fmt.Sprintf("%d", rtmp.GetSeq())
m.Error = rtmp.GetError()
case codec.Publication:
_, err := io.Copy(c.buf, c.rwc)
return err
default:
return fmt.Errorf("Unrecognised message type: %v", mt)
}
return nil
}
func (c *protoCodec) ReadBody(b interface{}) error {
var data []byte
switch c.mt {
case codec.Request, codec.Response:
var err error
data, err = ReadNetString(c.rwc)
if err != nil {
return err
}
case codec.Publication:
data = c.buf.Bytes()
default:
return fmt.Errorf("Unrecognised message type: %v", c.mt)
}
if b != nil {
return proto.Unmarshal(data, b.(proto.Message))
}
return nil
}
func NewCodec(rwc io.ReadWriteCloser) codec.Codec {
return &protoCodec{
buf: bytes.NewBuffer(nil),
rwc: rwc,
}
}

224
config/config.go Normal file
View File

@@ -0,0 +1,224 @@
// Package config is an interface for dynamic configuration.
package config
import (
"context"
"errors"
"reflect"
"time"
)
type Validator interface {
Validate() error
}
// DefaultConfig default config
var DefaultConfig = NewConfig()
// DefaultWatcherMinInterval default min interval for poll changes
var DefaultWatcherMinInterval = 5 * time.Second
// DefaultWatcherMaxInterval default max interval for poll changes
var DefaultWatcherMaxInterval = 9 * time.Second
var (
// ErrCodecMissing is returned when codec needed and not specified
ErrCodecMissing = errors.New("codec missing")
// ErrInvalidStruct is returned when the target struct is invalid
ErrInvalidStruct = errors.New("invalid struct specified")
// ErrWatcherStopped is returned when source watcher has been stopped
ErrWatcherStopped = errors.New("watcher stopped")
// ErrWatcherNotImplemented returned when config does not implement watch
ErrWatcherNotImplemented = errors.New("watcher not implemented")
)
// Config is an interface abstraction for dynamic configuration
type Config interface {
// Name returns name of config
Name() string
// Init the config
Init(opts ...Option) error
// Options in the config
Options() Options
// Load config from sources
Load(context.Context, ...LoadOption) error
// Save config to sources
Save(context.Context, ...SaveOption) error
// Watch a config for changes
Watch(context.Context, ...WatchOption) (Watcher, error)
// String returns config type name
String() string
}
type (
FuncLoad func(ctx context.Context, opts ...LoadOption) error
HookLoad func(next FuncLoad) FuncLoad
FuncSave func(ctx context.Context, opts ...SaveOption) error
HookSave func(next FuncSave) FuncSave
)
// Watcher is the config watcher
type Watcher interface {
// Next blocks until update happens or error returned
Next() (map[string]interface{}, error)
// Stop stops watcher
Stop() error
}
// Load loads config from config sources
func Load(ctx context.Context, cs []Config, opts ...LoadOption) error {
var err error
for _, c := range cs {
if err = c.Init(); err != nil {
return err
}
if err = c.Load(ctx, opts...); err != nil {
return err
}
}
return nil
}
// Validate runs Validate() error func for each struct field
func Validate(ctx context.Context, cfg interface{}) error {
if cfg == nil {
return nil
}
if v, ok := cfg.(Validator); ok {
if err := v.Validate(); err != nil {
return err
}
}
sv := reflect.ValueOf(cfg)
if sv.Kind() == reflect.Ptr {
sv = sv.Elem()
}
if sv.Kind() != reflect.Struct {
return nil
}
typ := sv.Type()
for idx := 0; idx < typ.NumField(); idx++ {
fld := typ.Field(idx)
val := sv.Field(idx)
if !val.IsValid() || len(fld.PkgPath) != 0 {
continue
}
if v, ok := val.Interface().(Validator); ok {
if err := v.Validate(); err != nil {
return err
}
}
switch val.Kind() {
case reflect.Ptr:
if reflect.Indirect(val).Kind() == reflect.Struct {
if err := Validate(ctx, val.Interface()); err != nil {
return err
}
}
case reflect.Struct:
if err := Validate(ctx, val.Interface()); err != nil {
return err
}
}
}
return nil
}
var (
// DefaultBeforeLoad default func that runs before config Load
DefaultBeforeLoad = func(ctx context.Context, c Config) error {
for _, fn := range c.Options().BeforeLoad {
if fn == nil {
return nil
}
if err := fn(ctx, c); err != nil {
c.Options().Logger.Error(ctx, c.String()+" BeforeLoad error", err)
if !c.Options().AllowFail {
return err
}
}
}
return nil
}
// DefaultAfterLoad default func that runs after config Load
DefaultAfterLoad = func(ctx context.Context, c Config) error {
for _, fn := range c.Options().AfterLoad {
if fn == nil {
return nil
}
if err := fn(ctx, c); err != nil {
c.Options().Logger.Error(ctx, c.String()+" AfterLoad error", err)
if !c.Options().AllowFail {
return err
}
}
}
return nil
}
// DefaultBeforeSave default func that runs befora config Save
DefaultBeforeSave = func(ctx context.Context, c Config) error {
for _, fn := range c.Options().BeforeSave {
if fn == nil {
return nil
}
if err := fn(ctx, c); err != nil {
c.Options().Logger.Error(ctx, c.String()+" BeforeSave error", err)
if !c.Options().AllowFail {
return err
}
}
}
return nil
}
// DefaultAfterSave default func that runs after config Save
DefaultAfterSave = func(ctx context.Context, c Config) error {
for _, fn := range c.Options().AfterSave {
if fn == nil {
return nil
}
if err := fn(ctx, c); err != nil {
c.Options().Logger.Error(ctx, c.String()+" AfterSave error", err)
if !c.Options().AllowFail {
return err
}
}
}
return nil
}
// DefaultBeforeInit default func that runs befora config Init
DefaultBeforeInit = func(ctx context.Context, c Config) error {
for _, fn := range c.Options().BeforeInit {
if fn == nil {
return nil
}
if err := fn(ctx, c); err != nil {
c.Options().Logger.Error(ctx, c.String()+" BeforeInit error", err)
if !c.Options().AllowFail {
return err
}
}
}
return nil
}
// DefaultAfterInit default func that runs after config Init
DefaultAfterInit = func(ctx context.Context, c Config) error {
for _, fn := range c.Options().AfterSave {
if fn == nil {
return nil
}
if err := fn(ctx, c); err != nil {
c.Options().Logger.Error(ctx, c.String()+" AfterInit error", err)
if !c.Options().AllowFail {
return err
}
}
}
return nil
}
)

73
config/context.go Normal file
View File

@@ -0,0 +1,73 @@
package config
import (
"context"
)
type configKey struct{}
// FromContext returns store from context
func FromContext(ctx context.Context) (Config, bool) {
if ctx == nil {
return nil, false
}
c, ok := ctx.Value(configKey{}).(Config)
return c, ok
}
// MustContext returns store from context
func MustContext(ctx context.Context) Config {
c, ok := FromContext(ctx)
if !ok {
panic("missing config")
}
return c
}
// NewContext put store in context
func NewContext(ctx context.Context, c Config) context.Context {
if ctx == nil {
ctx = context.Background()
}
return context.WithValue(ctx, configKey{}, c)
}
// SetOption returns a function to setup a context with given value
func SetOption(k, v interface{}) Option {
return func(o *Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, k, v)
}
}
// SetSaveOption returns a function to setup a context with given value
func SetSaveOption(k, v interface{}) SaveOption {
return func(o *SaveOptions) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, k, v)
}
}
// SetLoadOption returns a function to setup a context with given value
func SetLoadOption(k, v interface{}) LoadOption {
return func(o *LoadOptions) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, k, v)
}
}
// SetWatchOption returns a function to setup a context with given value
func SetWatchOption(k, v interface{}) WatchOption {
return func(o *WatchOptions) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, k, v)
}
}

86
config/context_test.go Normal file
View File

@@ -0,0 +1,86 @@
package config
import (
"context"
"testing"
)
func TestFromNilContext(t *testing.T) {
// nolint: staticcheck
c, ok := FromContext(nil)
if ok || c != nil {
t.Fatal("FromContext not works")
}
}
func TestNewNilContext(t *testing.T) {
// nolint: staticcheck
ctx := NewContext(nil, NewConfig())
c, ok := FromContext(ctx)
if c == nil || !ok {
t.Fatal("NewContext not works")
}
}
func TestFromContext(t *testing.T) {
ctx := context.WithValue(context.TODO(), configKey{}, NewConfig())
c, ok := FromContext(ctx)
if c == nil || !ok {
t.Fatal("FromContext not works")
}
}
func TestNewContext(t *testing.T) {
ctx := NewContext(context.TODO(), NewConfig())
c, ok := FromContext(ctx)
if c == nil || !ok {
t.Fatal("NewContext not works")
}
}
func TestSetOption(t *testing.T) {
type key struct{}
o := SetOption(key{}, "test")
opts := &Options{}
o(opts)
if v, ok := opts.Context.Value(key{}).(string); !ok || v == "" {
t.Fatal("SetOption not works")
}
}
func TestSetSaveOption(t *testing.T) {
type key struct{}
o := SetSaveOption(key{}, "test")
opts := &SaveOptions{}
o(opts)
if v, ok := opts.Context.Value(key{}).(string); !ok || v == "" {
t.Fatal("SetSaveOption not works")
}
}
func TestSetLoadOption(t *testing.T) {
type key struct{}
o := SetLoadOption(key{}, "test")
opts := &LoadOptions{}
o(opts)
if v, ok := opts.Context.Value(key{}).(string); !ok || v == "" {
t.Fatal("SetLoadOption not works")
}
}
func TestSetWatchOption(t *testing.T) {
type key struct{}
o := SetWatchOption(key{}, "test")
opts := &WatchOptions{}
o(opts)
if v, ok := opts.Context.Value(key{}).(string); !ok || v == "" {
t.Fatal("SetWatchOption not works")
}
}

Some files were not shown because too many files have changed in this diff Show More