Merge branch 'main' into fix/apollo

fix/apollo
baozhecheng 2 years ago
commit 8fd97b6258
  1. 5
      contrib/log/fluent/fluent.go
  2. 2
      contrib/registry/discovery/impl_registrar.go
  3. 62
      contrib/registry/kubernetes/registry.go
  4. 3
      transport/grpc/resolver/direct/builder.go
  5. 3
      transport/grpc/server.go
  6. 5
      transport/http/server.go

@ -99,8 +99,9 @@ type Logger struct {
// NewLogger new a std logger with options. // NewLogger new a std logger with options.
// target: // target:
// tcp://127.0.0.1:24224 //
// unix://var/run/fluent/fluent.sock // tcp://127.0.0.1:24224
// unix://var/run/fluent/fluent.sock
func NewLogger(addr string, opts ...Option) (*Logger, error) { func NewLogger(addr string, opts ...Option) (*Logger, error) {
option := options{} option := options{}
for _, o := range opts { for _, o := range opts {

@ -62,7 +62,7 @@ func (d *Discovery) Register(ctx context.Context, service *registry.ServiceInsta
return return
} }
// register an instance with Discovery // register an instance with Discovery
func (d *Discovery) register(ctx context.Context, ins *discoveryInstance) (err error) { func (d *Discovery) register(ctx context.Context, ins *discoveryInstance) (err error) {
d.mutex.RLock() d.mutex.RLock()
c := d.config c := d.config

@ -32,37 +32,37 @@ import (
// kratos-service-protocols: define the protocols of the service // kratos-service-protocols: define the protocols of the service
// //
// Example Deployment: // Example Deployment:
// /*
// apiVersion: apps/v1 apiVersion: apps/v1
// kind: Deployment kind: Deployment
// metadata: metadata:
// name: nginx name: nginx
// labels: labels:
// app: nginx app: nginx
// spec: spec:
// replicas: 5 replicas: 5
// selector: selector:
// matchLabels: matchLabels:
// app: nginx app: nginx
// template: template:
// metadata: metadata:
// labels: labels:
// app: nginx app: nginx
// kratos-service-id: "56991810-c77f-4a95-8190-393efa9c1a61" kratos-service-id: "56991810-c77f-4a95-8190-393efa9c1a61"
// kratos-service-app: "nginx" kratos-service-app: "nginx"
// kratos-service-version: "v3.5.0" kratos-service-version: "v3.5.0"
// annotations: annotations:
// kratos-service-protocols: | kratos-service-protocols: |
// {"80": "http"} {"80": "http"}
// kratos-service-metadata: | kratos-service-metadata: |
// {"region": "sh", "zone": "sh001", "cluster": "pd"} {"region": "sh", "zone": "sh001", "cluster": "pd"}
// spec: spec:
// containers: containers:
// - name: nginx - name: nginx
// image: nginx:1.7.9 image: nginx:1.7.9
// ports: ports:
// - containerPort: 80 - containerPort: 80
// */
const ( const (
// LabelsKeyServiceID is used to define the ID of the service // LabelsKeyServiceID is used to define the ID of the service
LabelsKeyServiceID = "kratos-service-id" LabelsKeyServiceID = "kratos-service-id"

@ -14,7 +14,8 @@ type directBuilder struct{}
// NewBuilder creates a directBuilder which is used to factory direct resolvers. // NewBuilder creates a directBuilder which is used to factory direct resolvers.
// example: // example:
// direct://<authority>/127.0.0.1:9000,127.0.0.2:9000 //
// direct://<authority>/127.0.0.1:9000,127.0.0.2:9000
func NewBuilder() resolver.Builder { func NewBuilder() resolver.Builder {
return &directBuilder{} return &directBuilder{}
} }

@ -176,7 +176,8 @@ func (s *Server) Use(selector string, m ...middleware.Middleware) {
// Endpoint return a real address to registry endpoint. // Endpoint return a real address to registry endpoint.
// examples: // examples:
// grpc://127.0.0.1:9000?isSecure=false //
// grpc://127.0.0.1:9000?isSecure=false
func (s *Server) Endpoint() (*url.URL, error) { func (s *Server) Endpoint() (*url.URL, error) {
if err := s.listenAndEndpoint(); err != nil { if err := s.listenAndEndpoint(); err != nil {
return nil, s.err return nil, s.err

@ -256,8 +256,9 @@ func (s *Server) filter() mux.MiddlewareFunc {
// Endpoint return a real address to registry endpoint. // Endpoint return a real address to registry endpoint.
// examples: // examples:
// https://127.0.0.1:8000 //
// Legacy: http://127.0.0.1:8000?isSecure=false // https://127.0.0.1:8000
// Legacy: http://127.0.0.1:8000?isSecure=false
func (s *Server) Endpoint() (*url.URL, error) { func (s *Server) Endpoint() (*url.URL, error) {
if err := s.listenAndEndpoint(); err != nil { if err := s.listenAndEndpoint(); err != nil {
return nil, err return nil, err

Loading…
Cancel
Save