INNER CODE UNIT · Go

func

go-kratos/gateway · client/factory.go:107

func (na *nodeApplier) apply(ctx context.Context) error {
	var nodes []selector.Node
	for _, backend := range na.endpoint.Backends {
		target, err := parseTarget(backend.Target)
		if err != nil {
			return err
		}
		switch target.Scheme {
		case "direct":
			weighted := backend.Weight // weight is only valid for direct scheme
			node := newNode(na.buildContext, backend.Target, na.endpoint.Protocol, weighted, backend.Metadata, "", "", WithTLS(backend.Tls), WithTLSConfigName(backend.TlsConfigName))
			nodes = append(nodes, node)
			na.picker.Apply(nodes)
		case "discovery":
			existed := AddWatch(ctx, na.registry, target.Endpoint, na)
			if existed {
				log.Infof("watch target %+v already existed", target)
			}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…