Coder Social home page Coder Social logo

Comments (4)

noahzaozao avatar noahzaozao commented on June 30, 2024

范例中的 resolver.Register(discovery.Builder())方法,在Builder方法内,
discovery.go 116行处调用New( nil),由于传入了nil的*Config,
导致在discovery.go 141行fixConfig(c) 方法内
discovery.go 94行报出错误 NOTE: please config a default HOST

from kratos.

noahzaozao avatar noahzaozao commented on June 30, 2024
package dao

import (
	"context"

	"github.com/bilibili/kratos/pkg/net/rpc/warden"

	"google.golang.org/grpc"
)

// AppID unique app id for service discovery
const AppID = "your app id"

// NewClient new member grpc client
func NewClient(cfg *warden.ClientConfig, opts ...grpc.DialOption) (DemoClient, error) {
	client := warden.NewClient(cfg, opts...)
	conn, err := client.Dial(context.Background(), "discovery://default/"+AppID)
	if err != nil {
		return nil, err
	}
	// 注意替换这里:
	// NewDemoClient方法是在"api"目录下代码生成的
	// 对应proto文件内自定义的service名字,请使用正确方法名替换
	return NewDemoClient(conn), nil
}

测试代码引用自 warden-quickstart.md 91-117行

from kratos.

noahzaozao avatar noahzaozao commented on June 30, 2024

@tonyboxes @felixhao @Terry-Mao

from kratos.

noahzaozao avatar noahzaozao commented on June 30, 2024

已解决,在client := warden.NewClient(cfg, opts...)之前加如下代码,问题解决

conf := &naming.Config{
		Nodes: []string{"127.0.0.1:7171"},
		Zone:  "sh1",
		Env:   "test",
	}
	dis := naming.New(conf)
	dis.Build(AppID)

from kratos.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.