Browse Source

embed: add example for ServiceRegister.

disksing 9 years ago
parent
commit
861cb5cfa2
1 changed files with 8 additions and 1 deletions
  1. 8 1
      embed/config.go

+ 8 - 1
embed/config.go

@@ -28,6 +28,7 @@ import (
 	"github.com/coreos/etcd/pkg/netutil"
 	"github.com/coreos/etcd/pkg/netutil"
 	"github.com/coreos/etcd/pkg/transport"
 	"github.com/coreos/etcd/pkg/transport"
 	"github.com/coreos/etcd/pkg/types"
 	"github.com/coreos/etcd/pkg/types"
+
 	"github.com/ghodss/yaml"
 	"github.com/ghodss/yaml"
 	"google.golang.org/grpc"
 	"google.golang.org/grpc"
 )
 )
@@ -127,7 +128,13 @@ type Config struct {
 	// The map key is the route path for the handler, and
 	// The map key is the route path for the handler, and
 	// you must ensure it can't be conflicted with etcd's.
 	// you must ensure it can't be conflicted with etcd's.
 	UserHandlers map[string]http.Handler `json:"-"`
 	UserHandlers map[string]http.Handler `json:"-"`
-	// ServiceRegister is for registering users' gRPC services.
+	// ServiceRegister is for registering users' gRPC services. A simple usage example:
+	//	cfg := embed.NewConfig()
+	//	cfg.ServerRegister = func(s *grpc.Server) {
+	//		pb.RegisterFooServer(s, &fooServer{})
+	//		pb.RegisterBarServer(s, &barServer{})
+	//	}
+	//	embed.StartEtcd(cfg)
 	ServiceRegister func(*grpc.Server) `json:"-"`
 	ServiceRegister func(*grpc.Server) `json:"-"`
 }
 }