當前位置: 首頁>>代碼示例>>Golang>>正文


Golang descriptor.Registry類代碼示例

本文整理匯總了Golang中github.com/gengo/grpc-gateway/protoc-gen-grpc-gateway/descriptor.Registry的典型用法代碼示例。如果您正苦於以下問題:Golang Registry類的具體用法?Golang Registry怎麽用?Golang Registry使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Registry類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: New

// New returns a new generator which generates grpc gateway files.
func New(reg *descriptor.Registry) gen.Generator {
	var imports []descriptor.GoPackage
	for _, pkgpath := range []string{
		"encoding/json",
		"io",
		"net/http",
		"github.com/gengo/grpc-gateway/runtime",
		"github.com/gengo/grpc-gateway/utilities",
		"github.com/golang/glog",
		"github.com/golang/protobuf/proto",
		"golang.org/x/net/context",
		"google.golang.org/grpc",
		"google.golang.org/grpc/codes",
	} {
		pkg := descriptor.GoPackage{
			Path: pkgpath,
			Name: path.Base(pkgpath),
		}
		if err := reg.ReserveGoPackageAlias(pkg.Name, pkg.Path); err != nil {
			for i := 0; ; i++ {
				alias := fmt.Sprintf("%s_%d", pkg.Name, i)
				if err := reg.ReserveGoPackageAlias(alias, pkg.Path); err != nil {
					continue
				}
				pkg.Alias = alias
				break
			}
		}
		imports = append(imports, pkg)
	}
	return &generator{reg: reg, baseImports: imports}
}
開發者ID:JohanSJA,項目名稱:grpc-gateway,代碼行數:33,代碼來源:generator.go

示例2: findNestedMessages

// findNestedMessages that can be generated by the services.
func findNestedMessages(message *descriptor.Message, reg *descriptor.Registry, m messageMap) {
	// Iterate over all the fields that
	for _, t := range message.Fields {
		fieldType := t.GetTypeName()
		// If the type is an empty string then it is a proto primitive
		if fieldType != "" {
			if _, ok := m[fieldType]; !ok {
				msg, err := reg.LookupMsg("", fieldType)
				if err != nil {
					panic(err)
				}
				m[fieldType] = msg
				findNestedMessages(msg, reg, m)
			}
		}
	}
}
開發者ID:floridoo,項目名稱:grpc-gateway,代碼行數:18,代碼來源:template.go

示例3: fullyQualifiedNameToSwaggerName

// Take in a FQMN and return a swagger safe version of the FQMN
func fullyQualifiedNameToSwaggerName(fqmn string, reg *descriptor.Registry) string {
	return resolveFullyQualifiedNameToSwaggerName(fqmn, reg.GetAllFQMNs())
}
開發者ID:achew22,項目名稱:grpc-gateway,代碼行數:4,代碼來源:template.go

示例4: fullyQualifiedNameToSwaggerName

// Take in a FQMN or FQEN and return a swagger safe version of the FQMN
func fullyQualifiedNameToSwaggerName(fqn string, reg *descriptor.Registry) string {
	return resolveFullyQualifiedNameToSwaggerName(fqn, append(reg.GetAllFQMNs(), reg.GetAllFQENs()...))
}
開發者ID:t-yuki,項目名稱:grpc-gateway,代碼行數:4,代碼來源:template.go


注:本文中的github.com/gengo/grpc-gateway/protoc-gen-grpc-gateway/descriptor.Registry類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。