Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add dubbo-go-hessian-registry generator #33

Merged
merged 5 commits into from
Feb 6, 2022

Conversation

ChangedenCZD
Copy link
Contributor

@ChangedenCZD ChangedenCZD commented Jan 28, 2022

Add dubbo-go-hessian-registry generator.

About apache/dubbo-go#1712 减少registerPOJO的过程

Usage

main.go

package main

//go:generate go run "github.com/dubbogo/tools/cmd/dubbogo-cli" -generator -include pkg
func main() {

}

pkg/demo.go

package pkg

type Demo0 struct {
	A string `json:"a"`
	B string `json:"b"`
}

func (*Demo0) JavaClassName() string {
	return "org.apache.dubbo.Demo0"
}

type Demo1 struct {
	C string `json:"c"`
}

func (*Demo1) JavaClassName() string {
	return "org.apache.dubbo.Demo1"
}

Execute go generate

go generate

Console logs

2022/01/28 11:58:11 === Generate start [pkg\demo.go] ===
2022/01/28 11:58:11 === Registry POJO [pkg\demo.go].Demo0 ===
2022/01/28 11:58:11 === Registry POJO [pkg\demo.go].Demo1 ===
2022/01/28 11:58:11 === Generate completed [pkg\demo.go] ===

Result

pkg/demo.go

package pkg

import (
	"github.com/apache/dubbo-go-hessian2"
)

type Demo0 struct {
	A string `json:"a"`
	B string `json:"b"`
}

func (*Demo0) JavaClassName() string {
	return "org.apache.dubbo.Demo0"
}

type Demo1 struct {
	C string `json:"c"`
}

func (*Demo1) JavaClassName() string {
	return "org.apache.dubbo.Demo1"
}

func init() {

	hessian.RegisterPOJO(&Demo0{})

	hessian.RegisterPOJO(&Demo1{})

}

Command flags

flag description default
include Preprocess files parent directory path. ./
thread Worker thread limit. (cpu core) * 2

@AlexStocks
Copy link
Contributor

建议合并到 dubbogo-cli 这个工具里面,减少用户使用成本。

@cjphaha cjphaha merged commit 08d6657 into dubbogo:master Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants