1
0
mirror of https://github.com/go-micro/go-micro.git synced 2026-05-06 19:21:46 +02:00
Commit Graph

68 Commits

Author SHA1 Message Date
asim a38d7df106 go fmt 2026-02-04 14:37:40 +00:00
Asim Aslam cae6fbbe76 Framework hardening: security, reliability, and developer experience improvements (#2826)
* fix: remove deprecated rand.Seed calls

Go 1.20+ automatically seeds the global random number generator.
These calls are no-ops and generate warnings with newer Go versions.

Removed from:
- selector/strategy.go
- registry/cache/cache.go
- broker/memory.go
- broker/http.go
- cmd/cmd.go
- transport/memory.go

Co-authored-by: Shelley <shelley@exe.dev>

* fix: handle previously ignored errors

- MySQL store: properly handle prepared statement errors in initDB()
- Consul registry: handle client creation errors in Client() method

These silent failures could cause hard-to-debug issues in production.

Co-authored-by: Shelley <shelley@exe.dev>

* feat(genai): improve provider interface with context and streaming

Breaking changes:
- Generate() and Stream() now require context.Context as first parameter
- Stream.Close() added for proper resource cleanup

Improvements:
- Proper context support for cancellation and timeouts
- Real SSE streaming for OpenAI and Gemini text generation
- Better error handling with wrapped errors and API error responses
- Thread-safe provider registry with sync.RWMutex
- New options: WithMaxTokens, WithTemperature, WithTimeout
- Stream has proper Close() method for cleanup
- Results can include Error field for per-chunk errors

Provider updates:
- OpenAI: true streaming with SSE parsing, proper HTTP client with timeout
- Gemini: true streaming with streamGenerateContent endpoint
- Default model updated to gpt-4o-mini (OpenAI) and gemini-2.0-flash (Gemini)

Co-authored-by: Shelley <shelley@exe.dev>

* feat(tls): make TLS secure by default, configurable via environment

BREAKING: TLS now verifies certificates by default. Set MICRO_TLS_INSECURE=true
to restore previous behavior (NOT recommended for production).

Changes:
- Add util/tls.Config(), SecureConfig(), InsecureConfig(), ConfigFromEnv() helpers
- Update all components to use ConfigFromEnv() instead of hardcoded InsecureSkipVerify
- Set MinVersion to TLS 1.2 for all TLS configs

Affected components:
- broker/http
- broker/rabbitmq
- registry/etcd
- registry/consul
- transport/grpc

This improves security posture while allowing opt-out for development environments.

Co-authored-by: Shelley <shelley@exe.dev>

* feat(tls): add TLS helpers with opt-in secure mode

NOT a breaking change - keeps InsecureSkipVerify=true as default for
local development compatibility.

New util/tls helpers:
- Config() - returns config based on MICRO_TLS_SECURE env var
- SecureConfig() - certificate verification enabled
- InsecureConfig() - certificate verification disabled (dev only)

For production security, use one of:
- Set MICRO_TLS_SECURE=true with proper CA-signed certs
- Use a service mesh (Istio, Linkerd) for automatic mTLS
- Configure TLSConfig directly with your certificates

Also: Changed CLI alias from 'g' to 'gen' for clarity
- micro generate handler -> micro gen handler

Co-authored-by: Shelley <shelley@exe.dev>

* refactor(cli): rename generate directory to gen for consistency

Directory name now matches the command alias:
  cmd/micro/cli/gen/ -> micro gen handler

Co-authored-by: Shelley <shelley@exe.dev>

---------

Co-authored-by: Shelley <shelley@exe.dev>
2026-01-27 10:39:25 +00:00
asim 610c00859f v5 2024-06-04 21:40:43 +01:00
Lukasz Raczylo a7522e7d6c fix: struct field alignment (#2632) 2023-04-26 02:16:34 +02:00
David Brouwer a3980c2308 feat: add test framework & refactor RPC server (#2579)
Co-authored-by: Rene Jochum <rene@jochum.dev>
2022-10-20 13:00:50 +02:00
David Brouwer 85c0b0b8eb fix: some linting issues (#2563) 2022-09-30 16:27:07 +02:00
Mohamed MHAMDI 1db36357d5 feat(logger): add logger option to all micro components (override DefaultLogger) closes #2556 (#2559)
* feat(logger): add logger option to all components

* fix: refactor api/rpc.go

* fix: refactor api/stream.go

* fix: api/options.go comment

* fix(logger): do not use logger.Helper internally

* fix(logger): fix comments

* fix(logger): use level.Enabled method

* fix: rename mlogger to log

* fix: run go fmt

* fix: log level

* fix: factories

Co-authored-by: Mohamed MHAMDI <mmhamdi@hubside.com>
Co-authored-by: Davincible <david.brouwer.99@gmail.com>
2022-09-29 16:44:53 +02:00
Asim Aslam 1cd7cfaa6c go-micro.dev/v4 (#2305) 2021-10-12 12:55:53 +01:00
JeffreyBool f48911d2c3 fix: "Solve the problem that the resources have not been fully released due to early exit" (#2168)
* Update http.go

Exit before deregister is executed

* Create http.go

Exit before deregister is executed

* Solve the problem that the resources have not been fully released due to early exit

* Optimize some code

* Optimize some code
2021-05-17 08:16:52 +01:00
Asim Aslam d94936f6c9 v3 (#2104)
* v3

* revert plugins

* fixup some issues
2021-01-20 13:54:31 +00:00
Asim Aslam a7c31a0d2b refactor all the things 2020-12-29 15:49:26 +00:00
Asim Aslam df687fe5d4 move selector 2020-12-12 20:14:50 +00:00
Asim Aslam ca5acba0c6 Move selector to client/selector 2019-06-21 15:13:54 +01:00
Vasiliy Tolstov 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 7a3a7e2eaf remove rcache reference 2019-05-31 16:00:44 +01:00
xinfei.wu a56929d1b8 reuse rcache 2019-02-13 17:47:31 +08:00
Asim Aslam 1321782785 in case of reload return nil 2019-01-19 10:20:16 +00:00
Asim Aslam 082f57fcad We can just check nil vals 2019-01-16 15:42:42 +00:00
Asim Aslam cc5629fb6b Don't return zero length services 2019-01-16 15:41:37 +00:00
Asim Aslam f2ac73eae5 only log error if its plus 3 2019-01-14 16:09:51 +00:00
Asim Aslam 39c24baca9 rename mock things to memory 2019-01-14 15:27:25 +00:00
Asim Aslam d519180806 Merge branch 'master' into dns 2019-01-07 13:52:37 +00:00
Asim Aslam d6a5ff432c add net.LookupHost for dns 2019-01-07 09:34:07 +00:00
Asim Aslam f9da55e8a9 Add dns selector 2019-01-07 07:41:26 +00:00
Asim Aslam 4692af4393 Add static selector 2019-01-06 21:12:02 +00:00
Asim Aslam 460fb3e70c update package comments 2018-12-29 16:18:05 +00:00
Asim Aslam 5cae330732 Update selector race, rename cache selector 2018-12-29 15:44:51 +00:00
Asim Aslam 67d10e5f39 simplify get code 2018-12-18 18:06:34 +00:00
Asim Aslam 770c16a66d move to using rwmutex for selector 2018-12-18 16:51:42 +00:00
Mikhail Grachev 25e6dcc9b6 Fix some linter issues 2018-11-13 11:57:42 +03:00
Asim Aslam c9b40cb33b switch to stdlib context 2018-03-03 11:53:52 +00:00
Asim Aslam 02260dcaa3 Add watch options 2018-02-19 17:12:37 +00:00
Asim Aslam e7104d609a return the not found error 2017-10-28 16:21:32 +01:00
Asim Aslam d48735793d remove ticker 2017-10-26 21:12:48 +01:00
Asim Aslam 6fb652f78a lazily start watcher 2017-10-26 20:55:52 +01:00
Uffy b92130eeee remove redundant rand.Seed 2017-10-09 14:22:15 +08:00
Asim Aslam bab586b71e make use of micro/go-log 2017-05-11 20:43:42 +01:00
wangkechun 059b9d36d7 fix fmt str 2017-02-25 22:53:25 +08:00
Asim Aslam 71d717a06d strip doc.go files 2016-12-14 15:41:48 +00:00
Asim b3cdbaae1a Use random starting index for roundrobin 2016-10-29 09:31:32 +01:00
Asim 30e0fef615 Strip blacklist 2016-06-19 14:41:33 +01:00
Asim 02a0eb29d2 Temporarily disable blacklisting 2016-06-17 15:41:29 +01:00
Asim 4d24f4e30c Blacklist for longer to ensure it works 2016-05-26 18:26:02 +01:00
Asim 1254a87286 Add package comments 2016-05-24 22:22:46 +01:00
Asim 0d21b08928 Run method is obsolete 2016-05-07 03:08:43 +01:00
Asim 75f2706fd0 Use ErrNoneAvailable and test blacklisting 2016-05-07 00:04:08 +01:00
Asim 8353b7b865 Add blacklist to cache 2016-05-06 23:15:40 +01:00
Asim 77e4d4d9c4 Next phase of selector 2016-05-06 23:12:37 +01:00
Asim 6070e235eb remove comment 2016-05-05 21:13:07 +01:00
Asim 670ed74a13 Use del method 2016-05-05 21:12:59 +01:00