文件历史

提交图

34 次代码提交

作者 SHA1 备注 提交日期
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
Tsln 479bd58c3f fix consul context key mismatch (#2801) 2025-08-29 07:39:20 +01:00
Byron Silvers 95540b7859 fix consul watcher address handling (#2800) 2025-08-19 09:27:34 +01:00
Brian Ketelsen cd2b40ca4a Add a selection of plugins to the core repo (#2755)
* WIP

* fix: default memory registry, add registrations for mdns, nats

* fix: same for broker

* fix: add more

* fix: http port

* rename redis

* chore: linting
2025-05-15 18:47:35 +01:00
Asim Aslam d4832e8f34 Remove consul registry (#818) 2019-10-23 15:53:28 +01:00
Milos Gajdos b8815dff14 Append a port to address if it does not exist 2019-10-03 16:16:25 +01:00
lubaoquan 866631df1d fixes https://github.com/micro/go-micro/issues/793 2019-09-30 10:36:43 +08:00
Shu Xian bf0e46dc0d fix registry addr error for mq-rpc 2019-08-14 21:32:28 +08:00
Asim Aslam edb0fe4b16 fix the consul setup code 2019-08-06 19:43:46 +01:00
Asim Aslam e16420fdbd Consul config fix https://github.com/micro/go-micro/pull/641 2019-08-06 09:15:38 +01:00
Asim Aslam 1f744b31a4 Return the dead node when deleting the service 2019-07-10 21:03:53 +01:00
Asim Aslam e0bf1c2283 Remove Port from registry 2019-07-08 08:01:42 +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
Blair McMillan 389d141c5a Use existing consul client for watcher 2019-05-16 12:37:48 +10: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: https://github.com/hashicorp/consul/commit/6c885d383a7f303cc6c625108d3e7fc1a35d715d
2019-04-26 10:40:10 -07:00
Asim Aslam df6561165a gofmt 2019-04-23 07:13:21 +00:00
shuxian d3f447a732 solve NewRegistry httpclient 'nil pointer dereference' bug 2019-02-28 09:56:57 +08:00
Asim Aslam 7314af347b Set MDNS as default registry 2019-01-15 16:50:37 +00:00
Asim Aslam a1665ab37a Add consul package comment 2018-12-01 12:54:46 +00:00
Blair McMillan 7171c00e42 Add ability to specify Consul options and default to AllowStale for all gets 2018-11-23 17:11:37 +10:00
Asim Aslam af328ee7b4 Support connect native registration 2018-08-06 17:12:34 +01:00
Shulhan 44b934d458 registry: rename context key "consul_register_tcp_check" to "consul_tcp_check" 2018-03-21 21:57:04 +07:00
Shulhan 1eb4398b6c registry/consul: rename "RegisterTCPCheck" to "TCPCheck" 2018-03-21 18:17:56 +07:00
Shulhan 68ab671bd0 Use registry.options.Context to set Consul TCP check option 2018-03-19 20:34:56 +07:00
Asim Aslam c9b40cb33b switch to stdlib context 2018-03-03 11:53:52 +00:00
chriss fabdd4a704 Remove consul token helper method.
A Consul config struct can be passed using the `Config` helper making this helper redundant.
2016-11-21 16:16:24 +00:00
chriss 8a25723fe0 Set consul token via registry options.
Optionally configure a token to use with the consul client.
2016-11-18 00:07:12 +00:00
chriss 3d7187f405 Add the ability to pass consul client config via registry options.
This can be used when you need to configure the consul client to use a specific configuration (E.G to pass a Token if consul is using ACL policies)
2016-11-17 23:24:14 +00:00
Asim 3d3044404e Don't add to defaults in func init, just add them to cmd 2016-04-26 18:49:02 +01:00
Asim f088074f29 Registry init 2016-03-15 22:20:21 +00:00
Asim 71764564e7 Add packages for the defaults 2016-03-14 10:45:38 +00:00
Asim 04e07f4b39 Move plugins to go-plugins 2015-11-25 00:17:15 +00:00
Asim 5d88115f2a update links from myodc to micro 2015-11-20 16:17:33 +00:00
Asim 74fd1fc989 Restructure go-micro layout and plugins 2015-05-23 20:04:16 +01:00