Skip to content
Snippets Groups Projects
Unverified Commit de2dad98 authored by Xin.Zh's avatar Xin.Zh Committed by GitHub
Browse files

Merge pull request #950 from cvictory/feature/parameterTypes2

Feature: Add ParameterTypeNames at Invocation 
parents ed97c95c 0ecbcefd
No related branches found
No related tags found
No related merge requests found
......@@ -25,6 +25,8 @@ import (
type Invocation interface {
// MethodName gets invocation method name.
MethodName() string
// ParameterTypeNames gets invocation parameter type names.
ParameterTypeNames() []string
// ParameterTypes gets invocation parameter types.
ParameterTypes() []reflect.Type
// ParameterValues gets invocation parameter values.
......
......@@ -35,8 +35,11 @@ import (
// todo: is it necessary to separate fields of consumer(provider) from RPCInvocation
// nolint
type RPCInvocation struct {
methodName string
parameterTypes []reflect.Type
methodName string
// Parameter Type Names. It is used to specify the parameterType
parameterTypeNames []string
parameterTypes []reflect.Type
parameterValues []reflect.Value
arguments []interface{}
reply interface{}
......@@ -80,6 +83,11 @@ func (r *RPCInvocation) ParameterTypes() []reflect.Type {
return r.parameterTypes
}
// ParameterTypeNames gets RPC invocation parameter types of string expression.
func (r *RPCInvocation) ParameterTypeNames() []string {
return r.parameterTypeNames
}
// ParameterValues gets RPC invocation parameter values.
func (r *RPCInvocation) ParameterValues() []reflect.Value {
return r.parameterValues
......@@ -213,6 +221,18 @@ func WithParameterTypes(parameterTypes []reflect.Type) option {
}
}
// WithParameterTypeNames creates option with @parameterTypeNames.
func WithParameterTypeNames(parameterTypeNames []string) option {
return func(invo *RPCInvocation) {
if len(parameterTypeNames) == 0 {
return
}
parameterTypeNamesTmp := make([]string, len(parameterTypeNames))
copy(parameterTypeNamesTmp, parameterTypeNames)
invo.parameterTypeNames = parameterTypeNamesTmp
}
}
// WithParameterValues creates option with @parameterValues
func WithParameterValues(parameterValues []reflect.Value) option {
return func(invo *RPCInvocation) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment