generic/

directory
v1.5.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2022 License: Apache-2.0

README

Generic Reference Example

1. Introduction

Generic invocation is mainly used when the client does not have API interface or model class, all POJOs in parameters and return values are represented by Map. Commonly used for framework integration such as: implementing a common service testing framework, all service implementations can be invoked via GenericService.

2. Code
var ( 
    //appName is the unique identification of RPCService 
    appName         = "UserConsumer"
    referenceConfig = config.ReferenceConfig{
        InterfaceName: "org.apache.dubbo.UserProvider",
        Cluster:       "failover",
        Registry:      "demoZk",
        Protocol:      dubbo.DUBBO,
        Generic:       true,
    }
)

func init() {
    referenceConfig.GenericLoad(appName)
    time.Sleep(3 * time.Second)
}

func main() {
    resp, err := referenceConfig.GetRPCService().(*config.GenericService).Invoke(
    	context.TODO(),
    	[]interface{}{
    		//method name
    		"queryUser",
    		//parameter type
    		[]string{"org.apache.dubbo.User"},
    		//parameter array
    		[]hessian.Object{user},
    	},
    )
}

Directories

Path Synopsis
go-client
cmd command
pkg
go-server
cmd command
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL