mirror of
https://github.com/go-kratos/kratos.git
synced 2025-03-17 21:07:54 +02:00
rename Registry to Endpointer (#964)
This commit is contained in:
parent
41ea1fbc76
commit
4cb3fd62e3
2
app.go
2
app.go
@ -113,7 +113,7 @@ func (a *App) Stop() error {
|
||||
func buildInstance(o options) (*registry.ServiceInstance, error) {
|
||||
if len(o.endpoints) == 0 {
|
||||
for _, srv := range o.servers {
|
||||
if r, ok := srv.(transport.Registry); ok {
|
||||
if r, ok := srv.(transport.Endpointer); ok {
|
||||
e, err := r.Endpoint()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -20,7 +20,7 @@ import (
|
||||
)
|
||||
|
||||
var _ transport.Server = (*Server)(nil)
|
||||
var _ transport.Registry = (*Server)(nil)
|
||||
var _ transport.Endpointer = (*Server)(nil)
|
||||
|
||||
// ServerOption is gRPC server option.
|
||||
type ServerOption func(o *Server)
|
||||
@ -117,7 +117,7 @@ func NewServer(opts ...ServerOption) *Server {
|
||||
// examples:
|
||||
// grpc://127.0.0.1:9000?isSecure=false
|
||||
func (s *Server) Endpoint() (string, error) {
|
||||
if strings.HasSuffix(s.address, ":0") {
|
||||
if s.lis == nil && strings.HasSuffix(s.address, ":0") {
|
||||
lis, err := net.Listen(s.network, s.address)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
@ -17,7 +17,7 @@ import (
|
||||
)
|
||||
|
||||
var _ transport.Server = (*Server)(nil)
|
||||
var _ transport.Registry = (*Server)(nil)
|
||||
var _ transport.Endpointer = (*Server)(nil)
|
||||
|
||||
// ServerOption is HTTP server option.
|
||||
type ServerOption func(*Server)
|
||||
@ -105,7 +105,7 @@ func (s *Server) ServeHTTP(res http.ResponseWriter, req *http.Request) {
|
||||
// examples:
|
||||
// http://127.0.0.1:8000?isSecure=false
|
||||
func (s *Server) Endpoint() (string, error) {
|
||||
if strings.HasSuffix(s.address, ":0") {
|
||||
if s.lis == nil && strings.HasSuffix(s.address, ":0") {
|
||||
lis, err := net.Listen(s.network, s.address)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
@ -10,17 +10,17 @@ import (
|
||||
_ "github.com/go-kratos/kratos/v2/encoding/yaml"
|
||||
)
|
||||
|
||||
// Registry is registry endpoint.
|
||||
type Registry interface {
|
||||
Endpoint() (string, error)
|
||||
}
|
||||
|
||||
// Server is transport server.
|
||||
type Server interface {
|
||||
Start() error
|
||||
Stop() error
|
||||
}
|
||||
|
||||
// Endpointer is registry endpoint.
|
||||
type Endpointer interface {
|
||||
Endpoint() (string, error)
|
||||
}
|
||||
|
||||
// Transport is transport context value.
|
||||
type Transport struct {
|
||||
Kind Kind
|
||||
|
Loading…
x
Reference in New Issue
Block a user