Commit 826129ca authored by AlexStocks's avatar AlexStocks

add dubbo-go protocol

parent 38392533
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package gxprotocol
import (
"reflect"
)
// Invocation is a invocation for each remote method.
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.
ParameterValues() []reflect.Value
// Arguments gets arguments.
Arguments() []interface{}
// Reply gets response of request
Reply() interface{}
// Attachments gets all attachments
Attachments() map[string]interface{}
// AttachmentsByKey gets attachment by key , if nil then return default value. (It will be deprecated in the future)
AttachmentsByKey(string, string) string
Attachment(string) interface{}
// Attributes refers to dubbo 2.7.6. It is different from attachment. It is used in internal process.
Attributes() map[string]interface{}
// AttributeByKey gets attribute by key , if nil then return default value
AttributeByKey(string, interface{}) interface{}
// SetAttachments sets attribute by @key and @value.
SetAttachments(key string, value interface{})
// Invoker gets the invoker in current context.
Invoker() Invoker
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package gxprotocol
import (
"context"
)
import (
"github.com/dubbogo/gost/dubbogo"
)
// Invoker the service invocation interface for the consumer
//go:generate mockgen -source invoker.go -destination mock/mock_invoker.go -self_package github.com/apache/dubbo-go/protocol/mock --package mock Invoker
// Extension - Invoker
type Invoker interface {
gxdubbogo.Node
// Invoke the invocation and return result.
Invoke(context.Context, Invocation) Result
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package gxprotocol
// Result is a RPC result
type Result interface {
// SetError sets error.
SetError(error)
// Error gets error.
Error() error
// SetResult sets invoker result.
SetResult(interface{})
// Result gets invoker result.
Result() interface{}
// SetAttachments replaces the existing attachments with the specified param.
SetAttachments(map[string]interface{})
// Attachments gets all attachments
Attachments() map[string]interface{}
// AddAttachment adds the specified map to existing attachments in this instance.
AddAttachment(string, interface{})
// Attachment gets attachment by key with default value.
Attachment(string, interface{}) interface{}
}
Markdown is supported
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