Feat: Add Go-sdk Actor Support (#196)

* ftr: init go-sdk action

* fix: finished design of actor-api's invoke feature

* fix: add readme

* fix: lint

* fix: add manager unit test

* fix: add actor state suport

* fix: add comments

* fix: add comment

* fix the change reqeust of pr

* fix: validate example test

* fix: linter

* add actor validation

* add actor validation

* fix: update actor validation init sleep time

* fix: add init time for validate example server

* fix: change actor to the end of test in order not to let reminder bother other test

* fix: validate test

* fix: typo of factory

* fix: add init time

* fix: ut

Co-authored-by: Yaron Schneider <yaronsc@microsoft.com>
Co-authored-by: Long Dai <long.dai@intel.com>
This commit is contained in:
Laurence 2021-11-03 05:45:27 +08:00 committed by GitHub
parent 5d3a4ad3f2
commit d9ad49d2a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
58 changed files with 10928 additions and 36 deletions

View File

@ -94,3 +94,4 @@ jobs:
./validate.sh hello-world
./validate.sh pubsub
./validate.sh service
./validate.sh actor

View File

@ -20,7 +20,7 @@ test: tidy ## Tests the entire project
.PHONY: spell
spell: ## Checks spelling across the entire project
@command -v misspell > /dev/null 2>&1 || (cd tools && go get github.com/client9/misspell/cmd/misspell)
@misspell -locale US -error go=golang client/**/* example/**/* service/**/* .
@misspell -locale US -error go=golang client/**/* examples/**/* service/**/* actor/**/* .
.PHONY: cover
cover: tidy ## Displays test coverage in the client and service packages

89
actor/actor.go Normal file
View File

@ -0,0 +1,89 @@
package actor
import (
"sync"
)
// Client is the interface that should be impl by user's actor client.
type Client interface {
// Type defines the type of the actor server to be invoke
Type() string
// ID should be unique, the actor server with target ID would be created before server processing the invocation.
ID() string
}
// Server is the interface that would be impl by user's actor server with ServerImplBase
/*
Actor user should only impls func Type() string, and his user-defined-method, Other function could be impl by
combining ServerImplBase.
*/
type Server interface {
// ID is impl by ServerImplBase. It can be called by user defined actor function to get the actor ID of it's instance.
ID() string
// SetID is impl by ServerImplBase. It is called by actor container to inject actor ID of the instance, and should
// not called by user
SetID(string)
// Type is defined by user
Type() string
// SetStateManager is impl by ServerImplBase to inject StateManager to this actor instance
SetStateManager(StateManager)
// SaveState is impl by ServerImplBase, It saves the state cache of this actor instance to state store component by calling api of daprd.
// Save state is called at two places: 1. On invocation of this actor instance. 2. When new actor starts.
SaveState() error
}
type ReminderCallee interface {
ReminderCall(string, []byte, string, string)
}
type Factory func() Server
type ServerImplBase struct {
stateManager StateManager
once sync.Once
id string
}
func (b *ServerImplBase) SetStateManager(stateManager StateManager) {
b.stateManager = stateManager
}
// GetStateManager can be called by user-defined-method, to get state manager of this actor instance.
func (b *ServerImplBase) GetStateManager() StateManager {
return b.stateManager
}
func (b *ServerImplBase) ID() string {
return b.id
}
func (b *ServerImplBase) SetID(id string) {
b.once.Do(func() {
b.id = id
})
}
// SaveState is to saves the state cache of this actor instance to state store component by calling api of daprd.
func (b *ServerImplBase) SaveState() error {
if b.stateManager != nil {
return b.stateManager.Save()
}
return nil
}
type StateManager interface {
// Add is to add new state store with @stateName and @value
Add(stateName string, value interface{}) error
// Get is to get state store of @stateName with type @reply
Get(stateName string, reply interface{}) error
// Set is to set new state store with @stateName and @value
Set(stateName string, value interface{}) error
// Remove is to remove state store with @stateName
Remove(stateName string) error
// Contains is to check if state store contains @stateName
Contains(stateName string) (bool, error)
// Save is to saves the state cache of this actor instance to state store component by calling api of daprd.
Save() error
// Flush is called by stateManager after Save
Flush()
}

7
actor/api/reminder.go Normal file
View File

@ -0,0 +1,7 @@
package api
type ActorReminderParams struct {
Data []byte `json:"data"`
DueTime string `json:"dueTime"`
Period string `json:"period"`
}

9
actor/api/runtime.go Normal file
View File

@ -0,0 +1,9 @@
package api
type ActorRuntimeConfig struct {
RegisteredActorTypes []string `json:"entities"`
ActorIdleTimeout string `json:"actorIdleTimeout"`
ActorScanInterval string `json:"actorScanInterval"`
DrainOngingCallTimeout string `json:"drainOngoingCallTimeout"`
DrainBalancedActors bool `json:"drainRebalancedActors"`
}

8
actor/api/timer.go Normal file
View File

@ -0,0 +1,8 @@
package api
type ActorTimerParam struct {
CallBack string `json:"callback"`
Data []byte `json:"data"`
DueTime string `json:"dueTime"`
Period string `json:"period"`
}

29
actor/codec/codec.go Normal file
View File

@ -0,0 +1,29 @@
package codec
import perrors "github.com/pkg/errors"
// Codec is serializer interface.
type Codec interface {
Marshal(interface{}) ([]byte, error)
Unmarshal([]byte, interface{}) error
}
// Factory is factory of codec.
type Factory func() Codec
// codecFactoryMap stores.
var codecFactoryMap = make(map[string]Factory)
// SetActorCodec set Actor's Codec.
func SetActorCodec(name string, f Factory) {
codecFactoryMap[name] = f
}
// GetActorCodec gets the target codec instance.
func GetActorCodec(name string) (Codec, error) {
f, ok := codecFactoryMap[name]
if !ok {
return nil, perrors.Errorf("no actor codec implement named %s", name)
}
return f(), nil
}

View File

@ -0,0 +1,7 @@
package constant
// DefaultSerializerType is default actor invocation serialization type json.
const DefaultSerializerType = "json"
// YamlSerializerType is yaml actor invocation serialization type.
const YamlSerializerType = "yaml"

25
actor/codec/impl/json.go Normal file
View File

@ -0,0 +1,25 @@
package impl
import (
"encoding/json"
"github.com/dapr/go-sdk/actor/codec"
"github.com/dapr/go-sdk/actor/codec/constant"
)
func init() {
codec.SetActorCodec(constant.DefaultSerializerType, func() codec.Codec {
return &JSONCodec{}
})
}
// JSONCodec is json impl of codec.Codec.
type JSONCodec struct{}
func (j *JSONCodec) Marshal(v interface{}) ([]byte, error) {
return json.Marshal(v)
}
func (j *JSONCodec) Unmarshal(data []byte, v interface{}) error {
return json.Unmarshal(data, v)
}

25
actor/codec/impl/yaml.go Normal file
View File

@ -0,0 +1,25 @@
package impl
import (
"github.com/dapr/go-sdk/actor/codec"
"github.com/dapr/go-sdk/actor/codec/constant"
"gopkg.in/yaml.v3"
)
func init() {
codec.SetActorCodec(constant.YamlSerializerType, func() codec.Codec {
return &YamlCodec{}
})
}
// YamlCodec is json yaml of codec.Codec.
type YamlCodec struct{}
func (y *YamlCodec) Marshal(v interface{}) ([]byte, error) {
return yaml.Marshal(v)
}
func (y *YamlCodec) Unmarshal(data []byte, v interface{}) error {
return yaml.Unmarshal(data, v)
}

29
actor/config/config.go Normal file
View File

@ -0,0 +1,29 @@
package config
import "github.com/dapr/go-sdk/actor/codec/constant"
// ActorConfig is Actor's configuration struct.
type ActorConfig struct {
SerializerType string
}
// Option is option function of ActorConfig.
type Option func(config *ActorConfig)
// WithSerializerName set serializer type of the actor as @serializerType.
func WithSerializerName(serializerType string) Option {
return func(config *ActorConfig) {
config.SerializerType = serializerType
}
}
// GetConfigFromOptions get final ActorConfig set by @opts.
func GetConfigFromOptions(opts ...Option) *ActorConfig {
conf := &ActorConfig{
SerializerType: constant.DefaultSerializerType,
}
for _, opt := range opts {
opt(conf)
}
return conf
}

View File

@ -0,0 +1,25 @@
package config
import (
"testing"
"github.com/dapr/go-sdk/actor/codec/constant"
"github.com/stretchr/testify/assert"
)
func TestRegisterActorTimer(t *testing.T) {
t.Run("get default config without options", func(t *testing.T) {
config := GetConfigFromOptions()
assert.NotNil(t, config)
assert.Equal(t, constant.DefaultSerializerType, config.SerializerType)
})
t.Run("get config with option", func(t *testing.T) {
config := GetConfigFromOptions(
WithSerializerName("mockSerializerType"),
)
assert.NotNil(t, config)
assert.Equal(t, "mockSerializerType", config.SerializerType)
})
}

20
actor/error/error.go Normal file
View File

@ -0,0 +1,20 @@
package error
type ActorErr uint8
// TODO(@laurence) the classification, handle and print log of error should be optimized.
const (
Success = ActorErr(0)
ErrActorTypeNotFound = ActorErr(1)
ErrRemindersParamsInvalid = ActorErr(2)
ErrActorMethodNoFound = ActorErr(3)
ErrActorInvokeFailed = ActorErr(4)
ErrReminderFuncUndefined = ActorErr(5)
ErrActorMethodSerializeFailed = ActorErr(6)
ErrActorSerializeNoFound = ActorErr(7)
ErrActorIDNotFound = ActorErr(8)
ErrActorFactoryNotSet = ActorErr(9)
ErrTimerParamsInvalid = ActorErr(10)
ErrSaveStateFailed = ActorErr(11)
ErrActorServerInvalid = ActorErr(12)
)

View File

@ -0,0 +1,73 @@
package manager
import (
"context"
"log"
"reflect"
"github.com/dapr/go-sdk/actor"
"github.com/dapr/go-sdk/actor/codec"
actorErr "github.com/dapr/go-sdk/actor/error"
"github.com/dapr/go-sdk/actor/state"
dapr "github.com/dapr/go-sdk/client"
)
type ActorContainer interface {
Invoke(methodName string, param []byte) ([]reflect.Value, actorErr.ActorErr)
GetActor() actor.Server
}
// DefaultActorContainer contains actor instance and methods type info generated from actor.
type DefaultActorContainer struct {
methodType map[string]*MethodType
actor actor.Server
serializer codec.Codec
}
// NewDefaultActorContainer creates a new ActorContainer with provider impl actor and serializer.
func NewDefaultActorContainer(actorID string, impl actor.Server, serializer codec.Codec) (ActorContainer, actorErr.ActorErr) {
impl.SetID(actorID)
daprClient, _ := dapr.NewClient()
// create state manager for this new actor
impl.SetStateManager(state.NewActorStateManager(impl.Type(), actorID, state.NewDaprStateAsyncProvider(daprClient)))
// save state of this actor
err := impl.SaveState()
if err != nil {
return nil, actorErr.ErrSaveStateFailed
}
methodType, err := getAbsctractMethodMap(impl)
if err != nil {
log.Printf("failed to get absctract method map from registered provider, err = %s", err)
return nil, actorErr.ErrActorServerInvalid
}
return &DefaultActorContainer{
methodType: methodType,
actor: impl,
serializer: serializer,
}, actorErr.Success
}
func (d *DefaultActorContainer) GetActor() actor.Server {
return d.actor
}
// Invoke call actor method with given methodName and param.
func (d *DefaultActorContainer) Invoke(methodName string, param []byte) ([]reflect.Value, actorErr.ActorErr) {
methodType, ok := d.methodType[methodName]
if !ok {
return nil, actorErr.ErrActorMethodNoFound
}
argsValues := make([]reflect.Value, 0)
argsValues = append(argsValues, reflect.ValueOf(d.actor), reflect.ValueOf(context.Background()))
if len(methodType.argsType) > 0 {
typ := methodType.argsType[0]
paramValue := reflect.New(typ)
paramInterface := paramValue.Interface()
if err := d.serializer.Unmarshal(param, paramInterface); err != nil {
return nil, actorErr.ErrActorMethodSerializeFailed
}
argsValues = append(argsValues, reflect.ValueOf(paramInterface).Elem())
}
returnValue := methodType.method.Func.Call(argsValues)
return returnValue, actorErr.Success
}

View File

@ -0,0 +1,61 @@
package manager
import (
"testing"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
actorErr "github.com/dapr/go-sdk/actor/error"
actorMock "github.com/dapr/go-sdk/actor/mock"
)
const mockActorID = "mockActorID"
func TestNewDefaultContainer(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mockServer := actorMock.NewMockServer(ctrl)
mockCodec := actorMock.NewMockCodec(ctrl)
mockServer.EXPECT().SetID(mockActorID)
mockServer.EXPECT().SetStateManager(gomock.Any())
mockServer.EXPECT().SaveState()
mockServer.EXPECT().Type()
newContainer, aerr := NewDefaultActorContainer(mockActorID, mockServer, mockCodec)
assert.Equal(t, actorErr.Success, aerr)
container, ok := newContainer.(*DefaultActorContainer)
assert.True(t, ok)
assert.NotNil(t, container)
assert.NotNil(t, container.actor)
assert.NotNil(t, container.serializer)
assert.NotNil(t, container.methodType)
}
func TestContainerInvoke(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mockServer := actorMock.NewMockServer(ctrl)
mockCodec := actorMock.NewMockCodec(ctrl)
param := `"param"`
mockServer.EXPECT().SetID(mockActorID)
mockServer.EXPECT().SetStateManager(gomock.Any())
mockServer.EXPECT().SaveState()
mockServer.EXPECT().Type()
newContainer, aerr := NewDefaultActorContainer("mockActorID", mockServer, mockCodec)
assert.Equal(t, actorErr.Success, aerr)
container := newContainer.(*DefaultActorContainer)
mockServer.EXPECT().Invoke(gomock.Any(), "param").Return(param, nil)
mockCodec.EXPECT().Unmarshal([]byte(param), gomock.Any()).SetArg(1, "param").Return(nil)
rsp, err := container.Invoke("Invoke", []byte(param))
assert.Equal(t, 2, len(rsp))
assert.Equal(t, actorErr.Success, err)
assert.Equal(t, param, rsp[0].Interface().(string))
}

267
actor/manager/manager.go Normal file
View File

@ -0,0 +1,267 @@
package manager
import (
"encoding/json"
"fmt"
"log"
"reflect"
"sync"
"unicode"
"unicode/utf8"
perrors "github.com/pkg/errors"
"github.com/dapr/go-sdk/actor"
"github.com/dapr/go-sdk/actor/api"
"github.com/dapr/go-sdk/actor/codec"
actorErr "github.com/dapr/go-sdk/actor/error"
)
type ActorManager interface {
RegisterActorImplFactory(f actor.Factory)
InvokeMethod(actorID, methodName string, request []byte) ([]byte, actorErr.ActorErr)
DetectiveActor(actorID string) actorErr.ActorErr
InvokeReminder(actorID, reminderName string, params []byte) actorErr.ActorErr
InvokeTimer(actorID, timerName string, params []byte) actorErr.ActorErr
}
// DefaultActorManager is to manage one type of actor.
type DefaultActorManager struct {
// factory is the actor factory of specific type of actor
factory actor.Factory
// activeActors stores the map actorID -> ActorContainer
activeActors sync.Map
// serializer is the param and response serializer of the actor
serializer codec.Codec
}
func NewDefaultActorManager(serializerType string) (ActorManager, actorErr.ActorErr) {
serializer, err := codec.GetActorCodec(serializerType)
if err != nil {
return nil, actorErr.ErrActorSerializeNoFound
}
return &DefaultActorManager{
serializer: serializer,
}, actorErr.Success
}
// RegisterActorImplFactory registers the action factory f.
func (m *DefaultActorManager) RegisterActorImplFactory(f actor.Factory) {
m.factory = f
}
// getAndCreateActorContainerIfNotExist will.
func (m *DefaultActorManager) getAndCreateActorContainerIfNotExist(actorID string) (ActorContainer, actorErr.ActorErr) {
val, ok := m.activeActors.Load(actorID)
if !ok {
newContainer, aerr := NewDefaultActorContainer(actorID, m.factory(), m.serializer)
if aerr != actorErr.Success {
return nil, aerr
}
m.activeActors.Store(actorID, newContainer)
val, _ = m.activeActors.Load(actorID)
}
return val.(ActorContainer), actorErr.Success
}
// InvokeMethod to invoke local function by @actorID, @methodName and @request request param.
func (m *DefaultActorManager) InvokeMethod(actorID, methodName string, request []byte) ([]byte, actorErr.ActorErr) {
if m.factory == nil {
return nil, actorErr.ErrActorFactoryNotSet
}
actorContainer, aerr := m.getAndCreateActorContainerIfNotExist(actorID)
if aerr != actorErr.Success {
return nil, aerr
}
returnValue, aerr := actorContainer.Invoke(methodName, request)
if aerr != actorErr.Success {
return nil, aerr
}
if len(returnValue) == 1 {
return nil, actorErr.Success
}
var (
retErr interface{}
replyv reflect.Value
)
if len(returnValue) == 2 {
replyv = returnValue[0]
retErr = returnValue[1].Interface()
}
if retErr != nil {
return nil, actorErr.ErrActorInvokeFailed
}
rspData, err := m.serializer.Marshal(replyv.Interface())
if err != nil {
return nil, actorErr.ErrActorMethodSerializeFailed
}
if err := actorContainer.GetActor().SaveState(); err != nil {
return nil, actorErr.ErrSaveStateFailed
}
return rspData, actorErr.Success
}
// DetectiveActor removes actor from actor manager.
func (m *DefaultActorManager) DetectiveActor(actorID string) actorErr.ActorErr {
_, ok := m.activeActors.Load(actorID)
if !ok {
return actorErr.ErrActorIDNotFound
}
m.activeActors.Delete(actorID)
return actorErr.Success
}
// InvokeReminder invoke reminder function with given params.
func (m *DefaultActorManager) InvokeReminder(actorID, reminderName string, params []byte) actorErr.ActorErr {
if m.factory == nil {
return actorErr.ErrActorFactoryNotSet
}
reminderParams := &api.ActorReminderParams{}
if err := json.Unmarshal(params, reminderParams); err != nil {
log.Printf("failed to unmarshal reminder param, err: %v ", err)
return actorErr.ErrRemindersParamsInvalid
}
actorContainer, aerr := m.getAndCreateActorContainerIfNotExist(actorID)
if aerr != actorErr.Success {
return aerr
}
targetActor, ok := actorContainer.GetActor().(actor.ReminderCallee)
if !ok {
return actorErr.ErrReminderFuncUndefined
}
targetActor.ReminderCall(reminderName, reminderParams.Data, reminderParams.DueTime, reminderParams.Period)
return actorErr.Success
}
// InvokeTimer invoke timer callback function with given params.
func (m *DefaultActorManager) InvokeTimer(actorID, timerName string, params []byte) actorErr.ActorErr {
if m.factory == nil {
return actorErr.ErrActorFactoryNotSet
}
timerParams := &api.ActorTimerParam{}
if err := json.Unmarshal(params, timerParams); err != nil {
log.Printf("failed to unmarshal reminder param, err: %v ", err)
return actorErr.ErrTimerParamsInvalid
}
actorContainer, aerr := m.getAndCreateActorContainerIfNotExist(actorID)
if aerr != actorErr.Success {
return aerr
}
_, aerr = actorContainer.Invoke(timerParams.CallBack, timerParams.Data)
return aerr
}
func getAbsctractMethodMap(rcvr interface{}) (map[string]*MethodType, error) {
s := &Service{}
s.reflectType = reflect.TypeOf(rcvr)
s.reflctValue = reflect.ValueOf(rcvr)
sname := reflect.Indirect(s.reflctValue).Type().Name()
if !isExported(sname) {
return nil, fmt.Errorf("type %s is not exported", sname)
}
return suitableMethods(s.reflectType), nil
}
func isExported(name string) bool {
s, _ := utf8.DecodeRuneInString(name)
return unicode.IsUpper(s)
}
// Service is description of service.
type Service struct {
reflctValue reflect.Value
reflectType reflect.Type
}
// MethodType is description of service method.
type MethodType struct {
method reflect.Method
ctxType reflect.Type // request context
argsType []reflect.Type // args except ctx, include replyType if existing
replyType reflect.Type // return value, otherwise it is nil
}
// suitableMethods returns suitable Rpc methods of typ.
func suitableMethods(typ reflect.Type) map[string]*MethodType {
methods := make(map[string]*MethodType)
for m := 0; m < typ.NumMethod(); m++ {
method := typ.Method(m)
if mt, err := suiteMethod(method); mt != nil && err != nil {
log.Printf("method %s is illegal, err = %s, just skip it", method.Name, err)
} else {
methods[method.Name] = mt
}
}
return methods
}
// suiteMethod returns a suitable Rpc methodType.
func suiteMethod(method reflect.Method) (*MethodType, error) {
mtype := method.Type
mname := method.Name
inNum := mtype.NumIn()
outNum := mtype.NumOut()
// Method must be exported.
if method.PkgPath != "" {
return nil, perrors.New("method is not exported")
}
var (
replyType, ctxType reflect.Type
argsType []reflect.Type
)
if outNum > 2 || outNum == 0 {
return nil, perrors.New("num out invalid")
}
// The latest return type of the method must be error.
if returnType := mtype.Out(outNum - 1); returnType != typeOfError {
return nil, perrors.New(fmt.Sprintf("the latest return type %s of method %q is not error", returnType, mname))
}
// replyType
if outNum == 2 {
replyType = mtype.Out(0)
if !isExportedOrBuiltinType(replyType) {
return nil, perrors.New(fmt.Sprintf("reply type of method %s not exported{%v}", mname, replyType))
}
}
index := 1
// ctxType
if inNum > 1 && mtype.In(1).String() == "context.Context" {
ctxType = mtype.In(1)
index = 2
}
for ; index < inNum; index++ {
argsType = append(argsType, mtype.In(index))
// need not be a pointer.
if !isExportedOrBuiltinType(mtype.In(index)) {
return nil, perrors.New(fmt.Sprintf("argument type of method %q is not exported %v", mname, mtype.In(index)))
}
}
return &MethodType{method: method, argsType: argsType, replyType: replyType, ctxType: ctxType}, nil
}
var typeOfError = reflect.TypeOf((*error)(nil)).Elem()
func isExportedOrBuiltinType(t reflect.Type) bool {
for t.Kind() == reflect.Ptr {
t = t.Elem()
}
// PkgPath will be non-empty even for an exported type,
// so we need to check the type name as well.
return isExported(t.Name()) || t.PkgPath() == ""
}

View File

@ -0,0 +1,134 @@
package manager
import (
"encoding/json"
"testing"
"github.com/stretchr/testify/assert"
"github.com/dapr/go-sdk/actor/api"
actorErr "github.com/dapr/go-sdk/actor/error"
"github.com/dapr/go-sdk/actor/mock"
)
func TestNewDefaultActorManager(t *testing.T) {
mng, err := NewDefaultActorManager("json")
assert.NotNil(t, mng)
assert.Equal(t, actorErr.Success, err)
mng, err = NewDefaultActorManager("badSerializerType")
assert.Nil(t, mng)
assert.Equal(t, actorErr.ErrActorSerializeNoFound, err)
}
func TestRegisterActorImplFactory(t *testing.T) {
mng, err := NewDefaultActorManager("json")
assert.NotNil(t, mng)
assert.Equal(t, actorErr.Success, err)
assert.Nil(t, mng.(*DefaultActorManager).factory)
mng.RegisterActorImplFactory(mock.ActorImplFactory)
assert.NotNil(t, mng.(*DefaultActorManager).factory)
}
func TestInvokeMethod(t *testing.T) {
mng, err := NewDefaultActorManager("json")
assert.NotNil(t, mng)
assert.Equal(t, actorErr.Success, err)
assert.Nil(t, mng.(*DefaultActorManager).factory)
data, err := mng.InvokeMethod("testActorID", "testMethodName", []byte(`"hello"`))
assert.Nil(t, data)
assert.Equal(t, actorErr.ErrActorFactoryNotSet, err)
mng.RegisterActorImplFactory(mock.ActorImplFactory)
assert.NotNil(t, mng.(*DefaultActorManager).factory)
data, err = mng.InvokeMethod("testActorID", "mockMethod", []byte(`"hello"`))
assert.Nil(t, data)
assert.Equal(t, actorErr.ErrActorMethodNoFound, err)
data, err = mng.InvokeMethod("testActorID", "Invoke", []byte(`"hello"`))
assert.Equal(t, data, []byte(`"hello"`))
assert.Equal(t, actorErr.Success, err)
}
func TestDetectiveActor(t *testing.T) {
mng, err := NewDefaultActorManager("json")
assert.NotNil(t, mng)
assert.Equal(t, actorErr.Success, err)
assert.Nil(t, mng.(*DefaultActorManager).factory)
err = mng.DetectiveActor("testActorID")
assert.Equal(t, actorErr.ErrActorIDNotFound, err)
mng.RegisterActorImplFactory(mock.ActorImplFactory)
assert.NotNil(t, mng.(*DefaultActorManager).factory)
mng.InvokeMethod("testActorID", "Invoke", []byte(`"hello"`))
err = mng.DetectiveActor("testActorID")
assert.Equal(t, actorErr.Success, err)
}
func TestInvokeReminder(t *testing.T) {
mng, err := NewDefaultActorManager("json")
assert.NotNil(t, mng)
assert.Equal(t, actorErr.Success, err)
assert.Nil(t, mng.(*DefaultActorManager).factory)
err = mng.InvokeReminder("testActorID", "testReminderName", []byte(`"hello"`))
assert.Equal(t, actorErr.ErrActorFactoryNotSet, err)
mng.RegisterActorImplFactory(mock.ActorImplFactory)
assert.NotNil(t, mng.(*DefaultActorManager).factory)
err = mng.InvokeReminder("testActorID", "testReminderName", []byte(`"hello"`))
assert.Equal(t, actorErr.ErrRemindersParamsInvalid, err)
reminderParam, _ := json.Marshal(&api.ActorReminderParams{
Data: []byte("hello"),
DueTime: "5s",
Period: "6s",
})
err = mng.InvokeReminder("testActorID", "testReminderName", reminderParam)
assert.Equal(t, actorErr.Success, err)
}
func TestInvokeTimer(t *testing.T) {
mng, err := NewDefaultActorManager("json")
assert.NotNil(t, mng)
assert.Equal(t, actorErr.Success, err)
assert.Nil(t, mng.(*DefaultActorManager).factory)
err = mng.InvokeTimer("testActorID", "testTimerName", []byte(`"hello"`))
assert.Equal(t, actorErr.ErrActorFactoryNotSet, err)
mng.RegisterActorImplFactory(mock.ActorImplFactory)
assert.NotNil(t, mng.(*DefaultActorManager).factory)
err = mng.InvokeTimer("testActorID", "testTimerName", []byte(`"hello"`))
assert.Equal(t, actorErr.ErrTimerParamsInvalid, err)
timerParam, _ := json.Marshal(&api.ActorTimerParam{
Data: []byte("hello"),
DueTime: "5s",
Period: "6s",
CallBack: "Invoke",
})
err = mng.InvokeTimer("testActorID", "testTimerName", timerParam)
assert.Equal(t, actorErr.ErrActorMethodSerializeFailed, err)
timerParam, _ = json.Marshal(&api.ActorTimerParam{
Data: []byte("hello"),
DueTime: "5s",
Period: "6s",
CallBack: "NoSuchMethod",
})
err = mng.InvokeTimer("testActorID", "testTimerName", timerParam)
assert.Equal(t, actorErr.ErrActorMethodNoFound, err)
timerParam, _ = json.Marshal(&api.ActorTimerParam{
Data: []byte(`"hello"`),
DueTime: "5s",
Period: "6s",
CallBack: "Invoke",
})
err = mng.InvokeTimer("testActorID", "testTimerName", timerParam)
assert.Equal(t, actorErr.Success, err)
}

63
actor/mock/mock_codec.go Normal file
View File

@ -0,0 +1,63 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: github.com/dapr/go-sdk/actor/codec (interfaces: Codec)
// Package actor is a generated GoMock package.
package mock
import (
reflect "reflect"
gomock "github.com/golang/mock/gomock"
)
// MockCodec is a mock of Codec interface.
type MockCodec struct {
ctrl *gomock.Controller
recorder *MockCodecMockRecorder
}
// MockCodecMockRecorder is the mock recorder for MockCodec.
type MockCodecMockRecorder struct {
mock *MockCodec
}
// NewMockCodec creates a new mock instance.
func NewMockCodec(ctrl *gomock.Controller) *MockCodec {
mock := &MockCodec{ctrl: ctrl}
mock.recorder = &MockCodecMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockCodec) EXPECT() *MockCodecMockRecorder {
return m.recorder
}
// Marshal mocks base method.
func (m *MockCodec) Marshal(arg0 interface{}) ([]byte, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Marshal", arg0)
ret0, _ := ret[0].([]byte)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Marshal indicates an expected call of Marshal.
func (mr *MockCodecMockRecorder) Marshal(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Marshal", reflect.TypeOf((*MockCodec)(nil).Marshal), arg0)
}
// Unmarshal mocks base method.
func (m *MockCodec) Unmarshal(arg0 []byte, arg1 interface{}) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Unmarshal", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
}
// Unmarshal indicates an expected call of Unmarshal.
func (mr *MockCodecMockRecorder) Unmarshal(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Unmarshal", reflect.TypeOf((*MockCodec)(nil).Unmarshal), arg0, arg1)
}

View File

@ -0,0 +1,66 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: github.com/dapr/go-sdk/actor/manager (interfaces: ActorContainer)
// Package mock is a generated GoMock package.
package mock
import (
reflect "reflect"
gomock "github.com/golang/mock/gomock"
actor "github.com/dapr/go-sdk/actor"
error "github.com/dapr/go-sdk/actor/error"
)
// MockActorContainer is a mock of ActorContainer interface.
type MockActorContainer struct {
ctrl *gomock.Controller
recorder *MockActorContainerMockRecorder
}
// MockActorContainerMockRecorder is the mock recorder for MockActorContainer.
type MockActorContainerMockRecorder struct {
mock *MockActorContainer
}
// NewMockActorContainer creates a new mock instance.
func NewMockActorContainer(ctrl *gomock.Controller) *MockActorContainer {
mock := &MockActorContainer{ctrl: ctrl}
mock.recorder = &MockActorContainerMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockActorContainer) EXPECT() *MockActorContainerMockRecorder {
return m.recorder
}
// GetActor mocks base method.
func (m *MockActorContainer) GetActor() actor.Server {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetActor")
ret0, _ := ret[0].(actor.Server)
return ret0
}
// GetActor indicates an expected call of GetActor.
func (mr *MockActorContainerMockRecorder) GetActor() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetActor", reflect.TypeOf((*MockActorContainer)(nil).GetActor))
}
// Invoke mocks base method.
func (m *MockActorContainer) Invoke(arg0 string, arg1 []byte) ([]reflect.Value, error.ActorErr) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Invoke", arg0, arg1)
ret0, _ := ret[0].([]reflect.Value)
ret1, _ := ret[1].(error.ActorErr)
return ret0, ret1
}
// Invoke indicates an expected call of Invoke.
func (mr *MockActorContainerMockRecorder) Invoke(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Invoke", reflect.TypeOf((*MockActorContainer)(nil).Invoke), arg0, arg1)
}

View File

@ -0,0 +1,38 @@
package mock
import (
"context"
"github.com/dapr/go-sdk/actor"
)
func ActorImplFactory() actor.Server {
return &ActorImpl{}
}
type ActorImpl struct {
actor.ServerImplBase
}
func (t *ActorImpl) Type() string {
return "testActorType"
}
func (t *ActorImpl) Invoke(ctx context.Context, req string) (string, error) {
return req, nil
}
func (t *ActorImpl) ReminderCall(reminderName string, state []byte, dueTime string, period string) {
}
func NotReminderCalleeActorFactory() actor.Server {
return &NotReminderCalleeActor{}
}
type NotReminderCalleeActor struct {
actor.ServerImplBase
}
func (t *NotReminderCalleeActor) Type() string {
return "testActorNotReminderCalleeType"
}

106
actor/mock/mock_manager.go Normal file
View File

@ -0,0 +1,106 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: github.com/dapr/go-sdk/actor/manager (interfaces: ActorManager)
// Package mock is a generated GoMock package.
package mock
import (
reflect "reflect"
gomock "github.com/golang/mock/gomock"
actor "github.com/dapr/go-sdk/actor"
error "github.com/dapr/go-sdk/actor/error"
)
// MockActorManager is a mock of ActorManager interface.
type MockActorManager struct {
ctrl *gomock.Controller
recorder *MockActorManagerMockRecorder
}
// MockActorManagerMockRecorder is the mock recorder for MockActorManager.
type MockActorManagerMockRecorder struct {
mock *MockActorManager
}
// NewMockActorManager creates a new mock instance.
func NewMockActorManager(ctrl *gomock.Controller) *MockActorManager {
mock := &MockActorManager{ctrl: ctrl}
mock.recorder = &MockActorManagerMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockActorManager) EXPECT() *MockActorManagerMockRecorder {
return m.recorder
}
// DetectiveActor mocks base method.
func (m *MockActorManager) DetectiveActor(arg0 string) error.ActorErr {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "DetectiveActor", arg0)
ret0, _ := ret[0].(error.ActorErr)
return ret0
}
// DetectiveActor indicates an expected call of DetectiveActor.
func (mr *MockActorManagerMockRecorder) DetectiveActor(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DetectiveActor", reflect.TypeOf((*MockActorManager)(nil).DetectiveActor), arg0)
}
// InvokeMethod mocks base method.
func (m *MockActorManager) InvokeMethod(arg0, arg1 string, arg2 []byte) ([]byte, error.ActorErr) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "InvokeMethod", arg0, arg1, arg2)
ret0, _ := ret[0].([]byte)
ret1, _ := ret[1].(error.ActorErr)
return ret0, ret1
}
// InvokeMethod indicates an expected call of InvokeMethod.
func (mr *MockActorManagerMockRecorder) InvokeMethod(arg0, arg1, arg2 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InvokeMethod", reflect.TypeOf((*MockActorManager)(nil).InvokeMethod), arg0, arg1, arg2)
}
// InvokeReminder mocks base method.
func (m *MockActorManager) InvokeReminder(arg0, arg1 string, arg2 []byte) error.ActorErr {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "InvokeReminder", arg0, arg1, arg2)
ret0, _ := ret[0].(error.ActorErr)
return ret0
}
// InvokeReminder indicates an expected call of InvokeReminder.
func (mr *MockActorManagerMockRecorder) InvokeReminder(arg0, arg1, arg2 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InvokeReminder", reflect.TypeOf((*MockActorManager)(nil).InvokeReminder), arg0, arg1, arg2)
}
// InvokeTimer mocks base method.
func (m *MockActorManager) InvokeTimer(arg0, arg1 string, arg2 []byte) error.ActorErr {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "InvokeTimer", arg0, arg1, arg2)
ret0, _ := ret[0].(error.ActorErr)
return ret0
}
// InvokeTimer indicates an expected call of InvokeTimer.
func (mr *MockActorManagerMockRecorder) InvokeTimer(arg0, arg1, arg2 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InvokeTimer", reflect.TypeOf((*MockActorManager)(nil).InvokeTimer), arg0, arg1, arg2)
}
// RegisterActorImplFactory mocks base method.
func (m *MockActorManager) RegisterActorImplFactory(arg0 actor.Factory) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "RegisterActorImplFactory", arg0)
}
// RegisterActorImplFactory indicates an expected call of RegisterActorImplFactory.
func (mr *MockActorManagerMockRecorder) RegisterActorImplFactory(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterActorImplFactory", reflect.TypeOf((*MockActorManager)(nil).RegisterActorImplFactory), arg0)
}

116
actor/mock/mock_server.go Normal file
View File

@ -0,0 +1,116 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: github.com/dapr/go-sdk/actor (interfaces: Server)
// Package actor is a generated GoMock package.
package mock
import (
"context"
reflect "reflect"
gomock "github.com/golang/mock/gomock"
actor "github.com/dapr/go-sdk/actor"
)
// MockServer is a mock of Server interface.
type MockServer struct {
ctrl *gomock.Controller
recorder *MockServerMockRecorder
}
// MockServerMockRecorder is the mock recorder for MockServer.
type MockServerMockRecorder struct {
mock *MockServer
}
// NewMockServer creates a new mock instance.
func NewMockServer(ctrl *gomock.Controller) *MockServer {
mock := &MockServer{ctrl: ctrl}
mock.recorder = &MockServerMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockServer) EXPECT() *MockServerMockRecorder {
return m.recorder
}
// ID mocks base method.
func (m *MockServer) ID() string {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ID")
ret0, _ := ret[0].(string)
return ret0
}
func (mr *MockServerMockRecorder) Invoke(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Invoke", reflect.TypeOf((*MockServer)(nil).Invoke), arg0, arg1)
}
func (m *MockServer) Invoke(ctx context.Context, input string) (string, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Invoke", ctx, input)
ret0, _ := ret[0].(string)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ID indicates an expected call of ID.
func (mr *MockServerMockRecorder) ID() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ID", reflect.TypeOf((*MockServer)(nil).ID))
}
// SaveState mocks base method.
func (m *MockServer) SaveState() error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "SaveState")
ret0, _ := ret[0].(error)
return ret0
}
// SaveState indicates an expected call of SaveState.
func (mr *MockServerMockRecorder) SaveState() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveState", reflect.TypeOf((*MockServer)(nil).SaveState))
}
// SetID mocks base method.
func (m *MockServer) SetID(arg0 string) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "SetID", arg0)
}
// SetID indicates an expected call of SetID.
func (mr *MockServerMockRecorder) SetID(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetID", reflect.TypeOf((*MockServer)(nil).SetID), arg0)
}
// SetStateManager mocks base method.
func (m *MockServer) SetStateManager(arg0 actor.StateManager) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "SetStateManager", arg0)
}
// SetStateManager indicates an expected call of SetStateManager.
func (mr *MockServerMockRecorder) SetStateManager(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetStateManager", reflect.TypeOf((*MockServer)(nil).SetStateManager), arg0)
}
// Type mocks base method.
func (m *MockServer) Type() string {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Type")
ret0, _ := ret[0].(string)
return ret0
}
// Type indicates an expected call of Type.
func (mr *MockServerMockRecorder) Type() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Type", reflect.TypeOf((*MockServer)(nil).Type))
}

View File

@ -0,0 +1,89 @@
package runtime
import (
"encoding/json"
"sync"
"github.com/dapr/go-sdk/actor"
"github.com/dapr/go-sdk/actor/api"
"github.com/dapr/go-sdk/actor/config"
actorErr "github.com/dapr/go-sdk/actor/error"
"github.com/dapr/go-sdk/actor/manager"
)
type ActorRunTime struct {
config api.ActorRuntimeConfig
actorManagers sync.Map
}
var actorRuntimeInstance *ActorRunTime
// NewActorRuntime creates an empty ActorRuntime.
func NewActorRuntime() *ActorRunTime {
return &ActorRunTime{}
}
// GetActorRuntimeInstance gets or create runtime instance.
func GetActorRuntimeInstance() *ActorRunTime {
if actorRuntimeInstance == nil {
actorRuntimeInstance = NewActorRuntime()
}
return actorRuntimeInstance
}
// RegisterActorFactory registers the given actor factory from user, and create new actor manager if not exists.
func (r *ActorRunTime) RegisterActorFactory(f actor.Factory, opt ...config.Option) {
conf := config.GetConfigFromOptions(opt...)
actType := f().Type()
r.config.RegisteredActorTypes = append(r.config.RegisteredActorTypes, actType)
mng, ok := r.actorManagers.Load(actType)
if !ok {
newMng, err := manager.NewDefaultActorManager(conf.SerializerType)
if err != actorErr.Success {
return
}
newMng.RegisterActorImplFactory(f)
r.actorManagers.Store(actType, newMng)
return
}
mng.(manager.ActorManager).RegisterActorImplFactory(f)
}
func (r *ActorRunTime) GetJSONSerializedConfig() ([]byte, error) {
data, err := json.Marshal(&r.config)
return data, err
}
func (r *ActorRunTime) InvokeActorMethod(actorTypeName, actorID, actorMethod string, payload []byte) ([]byte, actorErr.ActorErr) {
mng, ok := r.actorManagers.Load(actorTypeName)
if !ok {
return nil, actorErr.ErrActorTypeNotFound
}
return mng.(manager.ActorManager).InvokeMethod(actorID, actorMethod, payload)
}
func (r *ActorRunTime) Deactivate(actorTypeName, actorID string) actorErr.ActorErr {
targetManager, ok := r.actorManagers.Load(actorTypeName)
if !ok {
return actorErr.ErrActorTypeNotFound
}
return targetManager.(manager.ActorManager).DetectiveActor(actorID)
}
func (r *ActorRunTime) InvokeReminder(actorTypeName, actorID, reminderName string, params []byte) actorErr.ActorErr {
targetManager, ok := r.actorManagers.Load(actorTypeName)
if !ok {
return actorErr.ErrActorTypeNotFound
}
mng := targetManager.(manager.ActorManager)
return mng.InvokeReminder(actorID, reminderName, params)
}
func (r *ActorRunTime) InvokeTimer(actorTypeName, actorID, timerName string, params []byte) actorErr.ActorErr {
targetManager, ok := r.actorManagers.Load(actorTypeName)
if !ok {
return actorErr.ErrActorTypeNotFound
}
mng := targetManager.(manager.ActorManager)
return mng.InvokeTimer(actorID, timerName, params)
}

View File

@ -0,0 +1,102 @@
package runtime
import (
"testing"
actorErr "github.com/dapr/go-sdk/actor/error"
actorMock "github.com/dapr/go-sdk/actor/mock"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
)
func TestNewActorRuntime(t *testing.T) {
rt := NewActorRuntime()
assert.NotNil(t, rt)
}
func TestGetActorRuntime(t *testing.T) {
rt := GetActorRuntimeInstance()
assert.NotNil(t, rt)
}
func TestRegisterActorFactoryAndInvokeMethod(t *testing.T) {
rt := NewActorRuntime()
ctrl := gomock.NewController(t)
defer ctrl.Finish()
_, err := rt.InvokeActorMethod("testActorType", "mockActorID", "Invoke", []byte("param"))
assert.Equal(t, actorErr.ErrActorTypeNotFound, err)
mockServer := actorMock.NewMockActorManager(ctrl)
rt.actorManagers.Store("testActorType", mockServer)
mockServer.EXPECT().RegisterActorImplFactory(gomock.Any())
rt.RegisterActorFactory(actorMock.ActorImplFactory)
mockServer.EXPECT().InvokeMethod("mockActorID", "Invoke", []byte("param")).Return([]byte("response"), actorErr.Success)
rspData, err := rt.InvokeActorMethod("testActorType", "mockActorID", "Invoke", []byte("param"))
assert.Equal(t, []byte("response"), rspData)
assert.Equal(t, actorErr.Success, err)
}
func TestDeactive(t *testing.T) {
rt := NewActorRuntime()
ctrl := gomock.NewController(t)
defer ctrl.Finish()
err := rt.Deactivate("testActorType", "mockActorID")
assert.Equal(t, actorErr.ErrActorTypeNotFound, err)
mockServer := actorMock.NewMockActorManager(ctrl)
rt.actorManagers.Store("testActorType", mockServer)
mockServer.EXPECT().RegisterActorImplFactory(gomock.Any())
rt.RegisterActorFactory(actorMock.ActorImplFactory)
mockServer.EXPECT().DetectiveActor("mockActorID").Return(actorErr.Success)
err = rt.Deactivate("testActorType", "mockActorID")
assert.Equal(t, actorErr.Success, err)
}
func TestInvokeReminder(t *testing.T) {
rt := NewActorRuntime()
ctrl := gomock.NewController(t)
defer ctrl.Finish()
err := rt.InvokeReminder("testActorType", "mockActorID", "mockReminder", []byte("param"))
assert.Equal(t, actorErr.ErrActorTypeNotFound, err)
mockServer := actorMock.NewMockActorManager(ctrl)
rt.actorManagers.Store("testActorType", mockServer)
mockServer.EXPECT().RegisterActorImplFactory(gomock.Any())
rt.RegisterActorFactory(actorMock.ActorImplFactory)
mockServer.EXPECT().InvokeReminder("mockActorID", "mockReminder", []byte("param")).Return(actorErr.Success)
err = rt.InvokeReminder("testActorType", "mockActorID", "mockReminder", []byte("param"))
assert.Equal(t, actorErr.Success, err)
}
func TestInvokeTimer(t *testing.T) {
rt := NewActorRuntime()
ctrl := gomock.NewController(t)
defer ctrl.Finish()
err := rt.InvokeTimer("testActorType", "mockActorID", "mockTimer", []byte("param"))
assert.Equal(t, actorErr.ErrActorTypeNotFound, err)
mockServer := actorMock.NewMockActorManager(ctrl)
rt.actorManagers.Store("testActorType", mockServer)
mockServer.EXPECT().RegisterActorImplFactory(gomock.Any())
rt.RegisterActorFactory(actorMock.ActorImplFactory)
mockServer.EXPECT().InvokeTimer("mockActorID", "mockTimer", []byte("param")).Return(actorErr.Success)
err = rt.InvokeTimer("testActorType", "mockActorID", "mockTimer", []byte("param"))
assert.Equal(t, actorErr.Success, err)
}

View File

@ -0,0 +1,11 @@
package state
type ActorStateChange struct {
stateName string
value interface{}
changeKind ChangeKind
}
func NewActorStateChange(stateName string, value interface{}, changeKind ChangeKind) *ActorStateChange {
return &ActorStateChange{stateName: stateName, value: value, changeKind: changeKind}
}

View File

@ -0,0 +1,36 @@
package state
import (
"reflect"
"testing"
)
func TestNewActorStateChange(t *testing.T) {
type args struct {
stateName string
value interface{}
changeKind ChangeKind
}
tests := []struct {
name string
args args
want *ActorStateChange
}{
{
name: "init",
args: args{
stateName: "testStateName",
value: "testValue",
changeKind: Add,
},
want: &ActorStateChange{stateName: "testStateName", value: "testValue", changeKind: Add},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := NewActorStateChange(tt.args.stateName, tt.args.value, tt.args.changeKind); !reflect.DeepEqual(got, tt.want) {
t.Errorf("NewActorStateChange() = %v, want %v", got, tt.want)
}
})
}
}

View File

@ -0,0 +1,88 @@
package state
import (
"context"
"github.com/pkg/errors"
"github.com/dapr/go-sdk/actor/codec"
"github.com/dapr/go-sdk/actor/codec/constant"
client "github.com/dapr/go-sdk/client"
)
type DaprStateAsyncProvider struct {
daprClient client.Client
stateSerializer codec.Codec
}
func (d *DaprStateAsyncProvider) Contains(actorType string, actorID string, stateName string) (bool, error) {
result, err := d.daprClient.GetActorState(context.Background(), &client.GetActorStateRequest{
ActorType: actorType,
ActorID: actorID,
KeyName: stateName,
})
if err != nil || result == nil {
return false, err
}
return len(result.Data) > 0, err
}
func (d *DaprStateAsyncProvider) Load(actorType, actorID, stateName string, reply interface{}) error {
result, err := d.daprClient.GetActorState(context.Background(), &client.GetActorStateRequest{
ActorType: actorType,
ActorID: actorID,
KeyName: stateName,
})
if err != nil {
return errors.Errorf("get actor state error = %s", err.Error())
}
if len(result.Data) == 0 {
return errors.Errorf("get actor state result empty, with actorType: %s, actorID: %s, stateName %s", actorType, actorID, stateName)
}
if err := d.stateSerializer.Unmarshal(result.Data, reply); err != nil {
return errors.Errorf("unmarshal state data error = %s", err.Error())
}
return nil
}
func (d *DaprStateAsyncProvider) Apply(actorType, actorID string, changes []*ActorStateChange) error {
if len(changes) == 0 {
return nil
}
operations := make([]*client.ActorStateOperation, 0)
var value []byte
for _, stateChange := range changes {
if stateChange == nil {
continue
}
daprOperationName := string(stateChange.changeKind)
if len(daprOperationName) == 0 {
continue
}
if stateChange.changeKind == Add {
data, err := d.stateSerializer.Marshal(stateChange.value)
if err != nil {
return err
}
value = data
}
operations = append(operations, &client.ActorStateOperation{
OperationType: daprOperationName,
Key: stateChange.stateName,
Value: value,
})
}
return d.daprClient.SaveStateTransactionally(context.Background(), actorType, actorID, operations)
}
// TODO(@laurence) the daprClient may be nil.
func NewDaprStateAsyncProvider(daprClient client.Client) *DaprStateAsyncProvider {
stateSerializer, _ := codec.GetActorCodec(constant.DefaultSerializerType)
return &DaprStateAsyncProvider{
stateSerializer: stateSerializer,
daprClient: daprClient,
}
}

View File

@ -0,0 +1,129 @@
package state
import (
"reflect"
"testing"
"github.com/dapr/go-sdk/actor/codec"
"github.com/dapr/go-sdk/client"
)
func TestDaprStateAsyncProvider_Apply(t *testing.T) {
type fields struct {
daprClient client.Client
stateSerializer codec.Codec
}
type args struct {
actorType string
actorID string
changes []*ActorStateChange
}
tests := []struct {
name string
fields fields
args args
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
d := &DaprStateAsyncProvider{
daprClient: tt.fields.daprClient,
stateSerializer: tt.fields.stateSerializer,
}
if err := d.Apply(tt.args.actorType, tt.args.actorID, tt.args.changes); (err != nil) != tt.wantErr {
t.Errorf("Apply() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
func TestDaprStateAsyncProvider_Contains(t *testing.T) {
type fields struct {
daprClient client.Client
stateSerializer codec.Codec
}
type args struct {
actorType string
actorID string
stateName string
}
tests := []struct {
name string
fields fields
args args
want bool
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
d := &DaprStateAsyncProvider{
daprClient: tt.fields.daprClient,
stateSerializer: tt.fields.stateSerializer,
}
got, err := d.Contains(tt.args.actorType, tt.args.actorID, tt.args.stateName)
if (err != nil) != tt.wantErr {
t.Errorf("Contains() error = %v, wantErr %v", err, tt.wantErr)
return
}
if got != tt.want {
t.Errorf("Contains() got = %v, want %v", got, tt.want)
}
})
}
}
func TestDaprStateAsyncProvider_Load(t *testing.T) {
type fields struct {
daprClient client.Client
stateSerializer codec.Codec
}
type args struct {
actorType string
actorID string
stateName string
reply interface{}
}
tests := []struct {
name string
fields fields
args args
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
d := &DaprStateAsyncProvider{
daprClient: tt.fields.daprClient,
stateSerializer: tt.fields.stateSerializer,
}
if err := d.Load(tt.args.actorType, tt.args.actorID, tt.args.stateName, tt.args.reply); (err != nil) != tt.wantErr {
t.Errorf("Load() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
func TestNewDaprStateAsyncProvider(t *testing.T) {
type args struct {
daprClient client.Client
}
tests := []struct {
name string
args args
want *DaprStateAsyncProvider
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := NewDaprStateAsyncProvider(tt.args.daprClient); !reflect.DeepEqual(got, tt.want) {
t.Errorf("NewDaprStateAsyncProvider() = %v, want %v", got, tt.want)
}
})
}
}

View File

@ -0,0 +1,22 @@
package state
type ChangeKind string
const (
None = ChangeKind("")
Add = ChangeKind("upsert")
Update = ChangeKind("upsert")
Remove = ChangeKind("delete")
)
type ChangeMetadata struct {
Kind ChangeKind
Value interface{}
}
func NewChangeMetadata(kind ChangeKind, value interface{}) *ChangeMetadata {
return &ChangeMetadata{
Kind: kind,
Value: value,
}
}

View File

@ -0,0 +1,34 @@
package state
import (
"reflect"
"testing"
)
func TestNewChangeMetadata(t *testing.T) {
type args struct {
kind ChangeKind
value interface{}
}
tests := []struct {
name string
args args
want *ChangeMetadata
}{
{
name: "init",
args: args{kind: Add, value: &ChangeMetadata{}},
want: &ChangeMetadata{
Kind: Add,
Value: &ChangeMetadata{},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := NewChangeMetadata(tt.args.kind, tt.args.value); !reflect.DeepEqual(got, tt.want) {
t.Errorf("NewChangeMetadata() = %v, want %v", got, tt.want)
}
})
}
}

View File

@ -0,0 +1,175 @@
package state
import (
"reflect"
"sync"
"github.com/pkg/errors"
"github.com/dapr/go-sdk/actor"
)
type ActorStateManager struct {
ActorTypeName string
ActorID string
stateChangeTracker sync.Map // map[string]*ChangeMetadata
stateAsyncProvider *DaprStateAsyncProvider
}
func (a *ActorStateManager) Add(stateName string, value interface{}) error {
if stateName == "" {
return errors.Errorf("state's name can't be empty")
}
exists, err := a.stateAsyncProvider.Contains(a.ActorTypeName, a.ActorID, stateName)
if err != nil {
return err
}
if val, ok := a.stateChangeTracker.Load(stateName); ok {
metadata := val.(*ChangeMetadata)
if metadata.Kind == Remove {
a.stateChangeTracker.Store(stateName, &ChangeMetadata{
Kind: Update,
Value: value,
})
return nil
}
return errors.Errorf("Duplicate cached state: %s", stateName)
}
if exists {
return errors.Errorf("Duplicate state: %s", stateName)
}
a.stateChangeTracker.Store(stateName, &ChangeMetadata{
Kind: Add,
Value: value,
})
return nil
}
func (a *ActorStateManager) Get(stateName string, reply interface{}) error {
if stateName == "" {
return errors.Errorf("state's name can't be empty")
}
if val, ok := a.stateChangeTracker.Load(stateName); ok {
metadata := val.(*ChangeMetadata)
if metadata.Kind == Remove {
return errors.Errorf("state is marked for remove: %s", stateName)
}
replyVal := reflect.ValueOf(reply).Elem()
metadataValue := reflect.ValueOf(metadata.Value)
if metadataValue.Kind() == reflect.Ptr {
replyVal.Set(metadataValue.Elem())
} else {
replyVal.Set(metadataValue)
}
return nil
}
err := a.stateAsyncProvider.Load(a.ActorTypeName, a.ActorID, stateName, reply)
a.stateChangeTracker.Store(stateName, &ChangeMetadata{
Kind: None,
Value: reply,
})
return err
}
func (a *ActorStateManager) Set(stateName string, value interface{}) error {
if stateName == "" {
return errors.Errorf("state's name can't be empty")
}
if val, ok := a.stateChangeTracker.Load(stateName); ok {
metadata := val.(*ChangeMetadata)
if metadata.Kind == None || metadata.Kind == Remove {
metadata.Kind = Update
}
a.stateChangeTracker.Store(stateName, NewChangeMetadata(metadata.Kind, value))
return nil
}
a.stateChangeTracker.Store(stateName, &ChangeMetadata{
Kind: Add,
Value: value,
})
return nil
}
func (a *ActorStateManager) Remove(stateName string) error {
if stateName == "" {
return errors.Errorf("state's name can't be empty")
}
if val, ok := a.stateChangeTracker.Load(stateName); ok {
metadata := val.(*ChangeMetadata)
if metadata.Kind == Remove {
return nil
}
if metadata.Kind == Add {
a.stateChangeTracker.Delete(stateName)
return nil
}
a.stateChangeTracker.Store(stateName, &ChangeMetadata{
Kind: Remove,
Value: nil,
})
return nil
}
if exist, err := a.stateAsyncProvider.Contains(a.ActorTypeName, a.ActorID, stateName); err != nil && exist {
a.stateChangeTracker.Store(stateName, &ChangeMetadata{
Kind: Remove,
Value: nil,
})
}
return nil
}
func (a *ActorStateManager) Contains(stateName string) (bool, error) {
if stateName == "" {
return false, errors.Errorf("state's name can't be empty")
}
if val, ok := a.stateChangeTracker.Load(stateName); ok {
metadata := val.(*ChangeMetadata)
if metadata.Kind == Remove {
return false, nil
}
return true, nil
}
return a.stateAsyncProvider.Contains(a.ActorTypeName, a.ActorID, stateName)
}
func (a *ActorStateManager) Save() error {
changes := make([]*ActorStateChange, 0)
a.stateChangeTracker.Range(func(key, value interface{}) bool {
stateName := key.(string)
metadata := value.(*ChangeMetadata)
changes = append(changes, NewActorStateChange(stateName, metadata.Value, metadata.Kind))
return true
})
if err := a.stateAsyncProvider.Apply(a.ActorTypeName, a.ActorID, changes); err != nil {
return err
}
a.Flush()
return nil
}
func (a *ActorStateManager) Flush() {
a.stateChangeTracker.Range(func(key, value interface{}) bool {
stateName := key.(string)
metadata := value.(*ChangeMetadata)
if metadata.Kind == Remove {
a.stateChangeTracker.Delete(stateName)
return true
}
metadata = NewChangeMetadata(None, metadata.Value)
a.stateChangeTracker.Store(stateName, metadata)
return true
})
}
func NewActorStateManager(actorTypeName string, actorID string, provider *DaprStateAsyncProvider) actor.StateManager {
return &ActorStateManager{
stateAsyncProvider: provider,
ActorTypeName: actorTypeName,
ActorID: actorID,
}
}

448
client/actor.go Normal file
View File

@ -0,0 +1,448 @@
package client
import (
"context"
"encoding/json"
"fmt"
"reflect"
anypb "github.com/golang/protobuf/ptypes/any"
"github.com/pkg/errors"
pb "github.com/dapr/dapr/pkg/proto/runtime/v1"
"github.com/dapr/go-sdk/actor"
"github.com/dapr/go-sdk/actor/codec"
"github.com/dapr/go-sdk/actor/config"
)
type InvokeActorRequest struct {
ActorType string
ActorID string
Method string
Data []byte
}
type InvokeActorResponse struct {
Data []byte
}
// InvokeActor invokes specific operation on the configured Dapr binding.
// This method covers input, output, and bi-directional bindings.
func (c *GRPCClient) InvokeActor(ctx context.Context, in *InvokeActorRequest) (out *InvokeActorResponse, err error) {
if in == nil {
return nil, errors.New("actor invocation required")
}
if in.Method == "" {
return nil, errors.New("actor invocation method required")
}
if in.ActorType == "" {
return nil, errors.New("actor invocation actorType required")
}
if in.ActorID == "" {
return nil, errors.New("actor invocation actorID required")
}
req := &pb.InvokeActorRequest{
ActorType: in.ActorType,
ActorId: in.ActorID,
Method: in.Method,
Data: in.Data,
}
resp, err := c.protoClient.InvokeActor(c.withAuthToken(ctx), req)
if err != nil {
return nil, errors.Wrapf(err, "error invoking binding %s/%s", in.ActorType, in.ActorID)
}
out = &InvokeActorResponse{}
if resp != nil {
out.Data = resp.Data
}
return out, nil
}
// ImplActorClientStub impls the given client stub @actorClientStub, an example of client stub is as followed
/*
type ClientStub struct {
// User defined function
GetUser func(context.Context, *User) (*User, error)
Invoke func(context.Context, string) (string, error)
Get func(context.Context) (string, error)
Post func(context.Context, string) error
StartTimer func(context.Context, *TimerRequest) error
StopTimer func(context.Context, *TimerRequest) error
...
}
// Type defined the target type, which should be compatible with server side actor
func (a *ClientStub) Type() string {
return "testActorType"
}
// ID defined actor ID to be invoked
func (a *ClientStub) ID() string {
return "ActorImplID123456"
}.
*/
func (c *GRPCClient) ImplActorClientStub(actorClientStub actor.Client, opt ...config.Option) {
serializerType := config.GetConfigFromOptions(opt...).SerializerType
serializer, err := codec.GetActorCodec(serializerType)
if err != nil {
fmt.Printf("[Actor] ERROR: serializer type %s unsupported\n", serializerType)
return
}
c.implActor(actorClientStub, serializer)
}
type RegisterActorReminderRequest struct {
ActorType string
ActorID string
Name string
DueTime string
Period string
Data []byte
}
// RegisterActorReminder registers a new reminder to target actor. Then, a reminder would be created and
// invoke actor's ReminderCall function if implemented.
// If server side actor impls this function, it's asserted to actor.ReminderCallee and can be invoked with call period
// and state data as param @in defined.
func (c *GRPCClient) RegisterActorReminder(ctx context.Context, in *RegisterActorReminderRequest) (err error) {
if in == nil {
return errors.New("actor register reminder invocation request param required")
}
if in.ActorType == "" {
return errors.New("actor register reminder invocation actorType required")
}
if in.ActorID == "" {
return errors.New("actor register reminder invocation actorID required")
}
if in.Name == "" {
return errors.New("actor register reminder invocation name required")
}
if in.DueTime == "" {
return errors.New("actor register reminder invocation dueTime required")
}
if in.Period == "" {
return errors.New("actor register reminder invocation period required")
}
req := &pb.RegisterActorReminderRequest{
ActorType: in.ActorType,
ActorId: in.ActorID,
Name: in.Name,
DueTime: in.DueTime,
Period: in.Period,
Data: in.Data,
}
_, err = c.protoClient.RegisterActorReminder(c.withAuthToken(ctx), req)
if err != nil {
return errors.Wrapf(err, "error invoking register actor reminder %s/%s", in.ActorType, in.ActorID)
}
return nil
}
type UnregisterActorReminderRequest struct {
ActorType string
ActorID string
Name string
}
// UnregisterActorReminder would unregister the actor reminder.
func (c *GRPCClient) UnregisterActorReminder(ctx context.Context, in *UnregisterActorReminderRequest) error {
if in == nil {
return errors.New("actor unregister reminder invocation request param required")
}
if in.ActorType == "" {
return errors.New("actor unregister reminder invocation actorType required")
}
if in.ActorID == "" {
return errors.New("actor unregister reminder invocation actorID required")
}
if in.Name == "" {
return errors.New("actor unregister reminder invocation name required")
}
req := &pb.UnregisterActorReminderRequest{
ActorType: in.ActorType,
ActorId: in.ActorID,
Name: in.Name,
}
_, err := c.protoClient.UnregisterActorReminder(c.withAuthToken(ctx), req)
if err != nil {
return errors.Wrapf(err, "error invoking unregister actor reminder %s/%s", in.ActorType, in.ActorID)
}
return nil
}
type RegisterActorTimerRequest struct {
ActorType string
ActorID string
Name string
DueTime string
Period string
Data []byte
CallBack string
}
// RegisterActorTimer register actor timer as given param @in defined.
func (c *GRPCClient) RegisterActorTimer(ctx context.Context, in *RegisterActorTimerRequest) (err error) {
if in == nil {
return errors.New("actor register timer invocation request param required")
}
if in.ActorType == "" {
return errors.New("actor register timer invocation actorType required")
}
if in.ActorID == "" {
return errors.New("actor register timer invocation actorID required")
}
if in.Name == "" {
return errors.New("actor register timer invocation name required")
}
if in.DueTime == "" {
return errors.New("actor register timer invocation dueTime required")
}
if in.Period == "" {
return errors.New("actor register timer invocation period required")
}
if in.CallBack == "" {
return errors.New("actor register timer invocation callback function required")
}
req := &pb.RegisterActorTimerRequest{
ActorType: in.ActorType,
ActorId: in.ActorID,
Name: in.Name,
DueTime: in.DueTime,
Period: in.Period,
Data: in.Data,
Callback: in.CallBack,
}
_, err = c.protoClient.RegisterActorTimer(c.withAuthToken(ctx), req)
if err != nil {
return errors.Wrapf(err, "error invoking actor register timer %s/%s", in.ActorType, in.ActorID)
}
return nil
}
type UnregisterActorTimerRequest struct {
ActorType string
ActorID string
Name string
}
// UnregisterActorTimer unregisters actor timer.
func (c *GRPCClient) UnregisterActorTimer(ctx context.Context, in *UnregisterActorTimerRequest) error {
if in == nil {
return errors.New("actor unregister timer invocation request param required")
}
if in.ActorType == "" {
return errors.New("actor unregister timer invocation actorType required")
}
if in.ActorID == "" {
return errors.New("actor unregister timer invocation actorID required")
}
if in.Name == "" {
return errors.New("actor unregister timer invocation name required")
}
req := &pb.UnregisterActorTimerRequest{
ActorType: in.ActorType,
ActorId: in.ActorID,
Name: in.Name,
}
_, err := c.protoClient.UnregisterActorTimer(c.withAuthToken(ctx), req)
if err != nil {
return errors.Wrapf(err, "error invoking binding %s/%s", in.ActorType, in.ActorID)
}
return nil
}
func (c *GRPCClient) implActor(actor actor.Client, serializer codec.Codec) {
actorValue := reflect.ValueOf(actor)
valueOfActor := actorValue.Elem()
typeOfActor := valueOfActor.Type()
// check incoming interface, the incoming interface's elem must be a struct.
if typeOfActor.Kind() != reflect.Struct {
fmt.Println("[Actor] ERROR: imple actor client stub failed, incoming interface is not struct")
return
}
numField := valueOfActor.NumField()
for i := 0; i < numField; i++ {
t := typeOfActor.Field(i)
methodName := t.Name
if methodName == "Type" {
continue
}
f := valueOfActor.Field(i)
if f.Kind() == reflect.Func && f.IsValid() && f.CanSet() {
outNum := t.Type.NumOut()
if outNum != 1 && outNum != 2 {
fmt.Printf("[Actor] ERRROR: method %s of mtype %v has wrong number of in out parameters %d; needs exactly 1/2\n",
t.Name, t.Type.String(), outNum)
continue
}
// The latest return type of the method must be error.
if returnType := t.Type.Out(outNum - 1); returnType != reflect.Zero(reflect.TypeOf((*error)(nil)).Elem()).Type() {
fmt.Printf("[Actor] ERRROR: the latest return type %s of method %q is not error\n", returnType, t.Name)
continue
}
funcOuts := make([]reflect.Type, outNum)
for i := 0; i < outNum; i++ {
funcOuts[i] = t.Type.Out(i)
}
f.Set(reflect.MakeFunc(f.Type(), c.makeCallProxyFunction(actor, methodName, funcOuts, serializer)))
}
}
}
func (c *GRPCClient) makeCallProxyFunction(actor actor.Client, methodName string, outs []reflect.Type, serializer codec.Codec) func(in []reflect.Value) []reflect.Value {
return func(in []reflect.Value) []reflect.Value {
var (
err error
inIArr []interface{}
reply reflect.Value
)
if len(outs) == 2 {
if outs[0].Kind() == reflect.Ptr {
reply = reflect.New(outs[0].Elem())
} else {
reply = reflect.New(outs[0])
}
}
start := 0
end := len(in)
invCtx := context.Background()
if end > 0 {
if in[0].Type().String() == "context.Context" {
if !in[0].IsNil() {
invCtx = in[0].Interface().(context.Context)
}
start++
}
}
if end-start <= 0 {
inIArr = []interface{}{}
} else if end-start == 1 {
inIArr = []interface{}{in[start].Interface()}
} else {
fmt.Println("[Actor] ERROR: param nums is zero or one is allowed by actor")
return nil
}
var data []byte
if len(inIArr) > 0 {
data, err = json.Marshal(inIArr[0])
}
if err != nil {
panic(err)
}
rsp, err := c.InvokeActor(invCtx, &InvokeActorRequest{
ActorType: actor.Type(),
ActorID: actor.ID(),
Method: methodName,
Data: data,
})
if len(outs) == 1 {
return []reflect.Value{reflect.ValueOf(&err).Elem()}
}
response := reply.Interface()
if rsp != nil {
if err = serializer.Unmarshal(rsp.Data, response); err != nil {
fmt.Printf("[Actor] ERROR: unmarshal response err = %v\n", err)
}
}
if len(outs) == 2 && outs[0].Kind() != reflect.Ptr {
return []reflect.Value{reply.Elem(), reflect.ValueOf(&err).Elem()}
}
return []reflect.Value{reply, reflect.ValueOf(&err).Elem()}
}
}
type GetActorStateRequest struct {
ActorType string
ActorID string
KeyName string
}
type GetActorStateResponse struct {
Data []byte
}
func (c *GRPCClient) GetActorState(ctx context.Context, in *GetActorStateRequest) (*GetActorStateResponse, error) {
if in == nil {
return nil, errors.New("actor get state invocation request param required")
}
if in.ActorType == "" {
return nil, errors.New("actor get state invocation actorType required")
}
if in.ActorID == "" {
return nil, errors.New("actor get state invocation actorID required")
}
if in.KeyName == "" {
return nil, errors.New("actor get state invocation keyName required")
}
rsp, err := c.protoClient.GetActorState(c.withAuthToken(ctx), &pb.GetActorStateRequest{
ActorId: in.ActorID,
ActorType: in.ActorType,
Key: in.KeyName,
})
if err != nil {
return nil, errors.Wrapf(err, "error invoking actor get state %s/%s", in.ActorType, in.ActorID)
}
return &GetActorStateResponse{Data: rsp.Data}, nil
}
type ActorStateOperation struct {
OperationType string
Key string
Value []byte
}
func (c *GRPCClient) SaveStateTransactionally(ctx context.Context, actorType, actorID string, operations []*ActorStateOperation) error {
if len(operations) == 0 {
return errors.New("actor save state transactionally invocation request param operations is empty")
}
if actorType == "" {
return errors.New("actor save state transactionally invocation actorType required")
}
if actorID == "" {
return errors.New("actor save state transactionally invocation actorID required")
}
grpcOperations := make([]*pb.TransactionalActorStateOperation, 0)
for _, op := range operations {
grpcOperations = append(grpcOperations, &pb.TransactionalActorStateOperation{
OperationType: op.OperationType,
Key: op.Key,
Value: &anypb.Any{
Value: op.Value,
},
})
}
_, err := c.protoClient.ExecuteActorStateTransaction(c.withAuthToken(ctx), &pb.ExecuteActorStateTransactionRequest{
ActorType: actorType,
ActorId: actorID,
Operations: grpcOperations,
})
return err
}

274
client/actor_test.go Normal file
View File

@ -0,0 +1,274 @@
package client
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
)
const testActorType = "test"
func TestInvokeActor(t *testing.T) {
ctx := context.Background()
in := &InvokeActorRequest{
ActorID: "fn",
Method: "mockMethod",
Data: []byte(`{hello}`),
ActorType: testActorType,
}
t.Run("invoke actor without data ", func(t *testing.T) {
in.Data = nil
out, err := testClient.InvokeActor(ctx, in)
in.Data = []byte(`{hello}`)
assert.Nil(t, err)
assert.NotNil(t, out)
})
t.Run("invoke actor without method", func(t *testing.T) {
in.Method = ""
out, err := testClient.InvokeActor(ctx, in)
in.Method = "mockMethod"
assert.NotNil(t, err)
assert.Nil(t, out)
})
t.Run("invoke actor without id ", func(t *testing.T) {
in.ActorID = ""
out, err := testClient.InvokeActor(ctx, in)
in.ActorID = "fn"
assert.NotNil(t, err)
assert.Nil(t, out)
})
t.Run("invoke actor without type", func(t *testing.T) {
in.ActorType = ""
out, err := testClient.InvokeActor(ctx, in)
in.ActorType = testActorType
assert.NotNil(t, err)
assert.Nil(t, out)
})
t.Run("invoke actor without empty input", func(t *testing.T) {
in = nil
out, err := testClient.InvokeActor(ctx, in)
assert.NotNil(t, err)
assert.Nil(t, out)
})
}
func TestRegisterActorReminder(t *testing.T) {
ctx := context.Background()
in := &RegisterActorReminderRequest{
ActorID: "fn",
Data: []byte(`{hello}`),
ActorType: testActorType,
Name: "mockName",
Period: "2s",
DueTime: "4s",
}
t.Run("invoke register actor reminder without actorType", func(t *testing.T) {
in.ActorType = ""
err := testClient.RegisterActorReminder(ctx, in)
in.ActorType = testActorType
assert.NotNil(t, err)
})
t.Run("invoke register actor reminder without id ", func(t *testing.T) {
in.ActorID = ""
err := testClient.RegisterActorReminder(ctx, in)
in.ActorID = "fn"
assert.NotNil(t, err)
})
t.Run("invoke register actor reminder without Name ", func(t *testing.T) {
in.Name = ""
err := testClient.RegisterActorReminder(ctx, in)
in.Name = "mockName"
assert.NotNil(t, err)
})
t.Run("invoke register actor reminder without period ", func(t *testing.T) {
in.ActorType = ""
err := testClient.RegisterActorReminder(ctx, in)
in.ActorType = testActorType
assert.NotNil(t, err)
})
t.Run("invoke register actor reminder without dutTime ", func(t *testing.T) {
in.DueTime = ""
err := testClient.RegisterActorReminder(ctx, in)
in.DueTime = "2s"
assert.NotNil(t, err)
})
t.Run("invoke register actor reminder ", func(t *testing.T) {
assert.Nil(t, testClient.RegisterActorReminder(ctx, in))
})
t.Run("invoke register actor reminder with empty param", func(t *testing.T) {
assert.NotNil(t, testClient.RegisterActorReminder(ctx, nil))
})
}
func TestRegisterActorTimer(t *testing.T) {
ctx := context.Background()
in := &RegisterActorTimerRequest{
ActorID: "fn",
Data: []byte(`{hello}`),
ActorType: testActorType,
Name: "mockName",
Period: "2s",
DueTime: "4s",
CallBack: "mockFunc",
}
t.Run("invoke register actor timer without actorType", func(t *testing.T) {
in.ActorType = ""
err := testClient.RegisterActorTimer(ctx, in)
in.ActorType = testActorType
assert.NotNil(t, err)
})
t.Run("invoke register actor timer without id ", func(t *testing.T) {
in.ActorID = ""
err := testClient.RegisterActorTimer(ctx, in)
in.ActorID = "fn"
assert.NotNil(t, err)
})
t.Run("invoke register actor timer without Name ", func(t *testing.T) {
in.Name = ""
err := testClient.RegisterActorTimer(ctx, in)
in.Name = "mockName"
assert.NotNil(t, err)
})
t.Run("invoke register actor timer without period ", func(t *testing.T) {
in.ActorType = ""
err := testClient.RegisterActorTimer(ctx, in)
in.ActorType = testActorType
assert.NotNil(t, err)
})
t.Run("invoke register actor timer without dutTime ", func(t *testing.T) {
in.DueTime = ""
err := testClient.RegisterActorTimer(ctx, in)
in.DueTime = "2s"
assert.NotNil(t, err)
})
t.Run("invoke register actor timer without callBack ", func(t *testing.T) {
in.CallBack = ""
err := testClient.RegisterActorTimer(ctx, in)
in.CallBack = "mockFunc"
assert.NotNil(t, err)
})
t.Run("invoke register actor timer without data ", func(t *testing.T) {
in.Data = nil
err := testClient.RegisterActorTimer(ctx, in)
in.Data = []byte(`{hello}`)
assert.Nil(t, err)
})
t.Run("invoke register actor timer", func(t *testing.T) {
assert.Nil(t, testClient.RegisterActorTimer(ctx, in))
})
t.Run("invoke register actor timer with empty param", func(t *testing.T) {
assert.NotNil(t, testClient.RegisterActorTimer(ctx, nil))
})
}
func TestUnregisterActorReminder(t *testing.T) {
ctx := context.Background()
in := &UnregisterActorReminderRequest{
ActorID: "fn",
ActorType: testActorType,
Name: "mockName",
}
t.Run("invoke unregister actor reminder without actorType", func(t *testing.T) {
in.ActorType = ""
err := testClient.UnregisterActorReminder(ctx, in)
in.ActorType = testActorType
assert.NotNil(t, err)
})
t.Run("invoke unregister actor reminder without id ", func(t *testing.T) {
in.ActorID = ""
err := testClient.UnregisterActorReminder(ctx, in)
in.ActorID = "fn"
assert.NotNil(t, err)
})
t.Run("invoke unregister actor reminder without Name ", func(t *testing.T) {
in.Name = ""
err := testClient.UnregisterActorReminder(ctx, in)
in.Name = "mockName"
assert.NotNil(t, err)
})
t.Run("invoke unregister actor reminder without period ", func(t *testing.T) {
in.ActorType = ""
err := testClient.UnregisterActorReminder(ctx, in)
in.ActorType = testActorType
assert.NotNil(t, err)
})
t.Run("invoke unregister actor reminder ", func(t *testing.T) {
assert.Nil(t, testClient.UnregisterActorReminder(ctx, in))
})
t.Run("invoke unregister actor reminder with empty param", func(t *testing.T) {
assert.NotNil(t, testClient.UnregisterActorReminder(ctx, nil))
})
}
func TestUnregisterActorTimer(t *testing.T) {
ctx := context.Background()
in := &UnregisterActorTimerRequest{
ActorID: "fn",
ActorType: testActorType,
Name: "mockName",
}
t.Run("invoke unregister actor timer without actorType", func(t *testing.T) {
in.ActorType = ""
err := testClient.UnregisterActorTimer(ctx, in)
in.ActorType = testActorType
assert.NotNil(t, err)
})
t.Run("invoke register actor timer without id ", func(t *testing.T) {
in.ActorID = ""
err := testClient.UnregisterActorTimer(ctx, in)
in.ActorID = "fn"
assert.NotNil(t, err)
})
t.Run("invoke register actor timer without Name ", func(t *testing.T) {
in.Name = ""
err := testClient.UnregisterActorTimer(ctx, in)
in.Name = "mockName"
assert.NotNil(t, err)
})
t.Run("invoke register actor timer without period ", func(t *testing.T) {
in.ActorType = ""
err := testClient.UnregisterActorTimer(ctx, in)
in.ActorType = testActorType
assert.NotNil(t, err)
})
t.Run("invoke register actor timer ", func(t *testing.T) {
assert.Nil(t, testClient.UnregisterActorTimer(ctx, in))
})
t.Run("invoke register actor timer with empty param", func(t *testing.T) {
assert.NotNil(t, testClient.UnregisterActorTimer(ctx, nil))
})
}

View File

@ -8,12 +8,18 @@ import (
"sync"
"time"
"github.com/dapr/go-sdk/actor"
"github.com/dapr/go-sdk/actor/config"
"github.com/pkg/errors"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
"google.golang.org/protobuf/types/known/emptypb"
pb "github.com/dapr/dapr/pkg/proto/runtime/v1"
// used to import codec implements.
_ "github.com/dapr/go-sdk/actor/codec/impl"
)
const (
@ -104,6 +110,30 @@ type Client interface {
// Close cleans up all resources created by the client.
Close()
// RegisterActorTimer registers an actor timer.
RegisterActorTimer(ctx context.Context, req *RegisterActorTimerRequest) error
// UnregisterActorTimer unregisters an actor timer.
UnregisterActorTimer(ctx context.Context, req *UnregisterActorTimerRequest) error
// RegisterActorReminder registers an actor reminder.
RegisterActorReminder(ctx context.Context, req *RegisterActorReminderRequest) error
// UnregisterActorReminder unregisters an actor reminder.
UnregisterActorReminder(ctx context.Context, req *UnregisterActorReminderRequest) error
// InvokeActor calls a method on an actor.
InvokeActor(ctx context.Context, req *InvokeActorRequest) (*InvokeActorResponse, error)
// GetActorState get actor state
GetActorState(ctx context.Context, req *GetActorStateRequest) (data *GetActorStateResponse, err error)
// SaveStateTransactionally save actor state
SaveStateTransactionally(ctx context.Context, actorType, actorID string, operations []*ActorStateOperation) error
// ImplActorClientStub is to impl user defined actor client stub
ImplActorClientStub(actorClientStub actor.Client, opt ...config.Option)
}
// NewClient instantiates Dapr client using DAPR_GRPC_PORT environment variable as port.

View File

@ -8,7 +8,6 @@ import (
"testing"
"github.com/golang/protobuf/ptypes/empty"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc"
@ -214,16 +213,26 @@ func (s *testDaprServer) GetBulkSecret(ctx context.Context, req *pb.GetBulkSecre
}, nil
}
func (s *testDaprServer) RegisterActorReminder(ctx context.Context, req *pb.RegisterActorReminderRequest) (*empty.Empty, error) {
return &empty.Empty{}, nil
}
func (s *testDaprServer) UnregisterActorReminder(ctx context.Context, req *pb.UnregisterActorReminderRequest) (*empty.Empty, error) {
return &empty.Empty{}, nil
}
func (s *testDaprServer) InvokeActor(context.Context, *pb.InvokeActorRequest) (*pb.InvokeActorResponse, error) {
return nil, errors.New("actors not implemented in go SDK")
return &pb.InvokeActorResponse{
Data: []byte("mockValue"),
}, nil
}
func (s *testDaprServer) RegisterActorTimer(context.Context, *pb.RegisterActorTimerRequest) (*empty.Empty, error) {
return nil, errors.New("actors not implemented in go SDK")
return &empty.Empty{}, nil
}
func (s *testDaprServer) UnregisterActorTimer(context.Context, *pb.UnregisterActorTimerRequest) (*empty.Empty, error) {
return nil, errors.New("actors not implemented in go SDK")
return &empty.Empty{}, nil
}
func (s *testDaprServer) Shutdown(ctx context.Context, req *empty.Empty) (*empty.Empty, error) {

View File

@ -0,0 +1,845 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation and Dapr Contributors.
// Licensed under the MIT License.
// ------------------------------------------------------------
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.14.0
// source: dapr/proto/common/v1/common.proto
package common
import (
reflect "reflect"
sync "sync"
proto "github.com/golang/protobuf/proto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
anypb "google.golang.org/protobuf/types/known/anypb"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
// Type of HTTP 1.1 Methods
// RFC 7231: https://tools.ietf.org/html/rfc7231#page-24
type HTTPExtension_Verb int32
const (
HTTPExtension_NONE HTTPExtension_Verb = 0
HTTPExtension_GET HTTPExtension_Verb = 1
HTTPExtension_HEAD HTTPExtension_Verb = 2
HTTPExtension_POST HTTPExtension_Verb = 3
HTTPExtension_PUT HTTPExtension_Verb = 4
HTTPExtension_DELETE HTTPExtension_Verb = 5
HTTPExtension_CONNECT HTTPExtension_Verb = 6
HTTPExtension_OPTIONS HTTPExtension_Verb = 7
HTTPExtension_TRACE HTTPExtension_Verb = 8
)
// Enum value maps for HTTPExtension_Verb.
var (
HTTPExtension_Verb_name = map[int32]string{
0: "NONE",
1: "GET",
2: "HEAD",
3: "POST",
4: "PUT",
5: "DELETE",
6: "CONNECT",
7: "OPTIONS",
8: "TRACE",
}
HTTPExtension_Verb_value = map[string]int32{
"NONE": 0,
"GET": 1,
"HEAD": 2,
"POST": 3,
"PUT": 4,
"DELETE": 5,
"CONNECT": 6,
"OPTIONS": 7,
"TRACE": 8,
}
)
func (x HTTPExtension_Verb) Enum() *HTTPExtension_Verb {
p := new(HTTPExtension_Verb)
*p = x
return p
}
func (x HTTPExtension_Verb) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (HTTPExtension_Verb) Descriptor() protoreflect.EnumDescriptor {
return file_dapr_proto_common_v1_common_proto_enumTypes[0].Descriptor()
}
func (HTTPExtension_Verb) Type() protoreflect.EnumType {
return &file_dapr_proto_common_v1_common_proto_enumTypes[0]
}
func (x HTTPExtension_Verb) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use HTTPExtension_Verb.Descriptor instead.
func (HTTPExtension_Verb) EnumDescriptor() ([]byte, []int) {
return file_dapr_proto_common_v1_common_proto_rawDescGZIP(), []int{0, 0}
}
// Enum describing the supported concurrency for state.
type StateOptions_StateConcurrency int32
const (
StateOptions_CONCURRENCY_UNSPECIFIED StateOptions_StateConcurrency = 0
StateOptions_CONCURRENCY_FIRST_WRITE StateOptions_StateConcurrency = 1
StateOptions_CONCURRENCY_LAST_WRITE StateOptions_StateConcurrency = 2
)
// Enum value maps for StateOptions_StateConcurrency.
var (
StateOptions_StateConcurrency_name = map[int32]string{
0: "CONCURRENCY_UNSPECIFIED",
1: "CONCURRENCY_FIRST_WRITE",
2: "CONCURRENCY_LAST_WRITE",
}
StateOptions_StateConcurrency_value = map[string]int32{
"CONCURRENCY_UNSPECIFIED": 0,
"CONCURRENCY_FIRST_WRITE": 1,
"CONCURRENCY_LAST_WRITE": 2,
}
)
func (x StateOptions_StateConcurrency) Enum() *StateOptions_StateConcurrency {
p := new(StateOptions_StateConcurrency)
*p = x
return p
}
func (x StateOptions_StateConcurrency) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (StateOptions_StateConcurrency) Descriptor() protoreflect.EnumDescriptor {
return file_dapr_proto_common_v1_common_proto_enumTypes[1].Descriptor()
}
func (StateOptions_StateConcurrency) Type() protoreflect.EnumType {
return &file_dapr_proto_common_v1_common_proto_enumTypes[1]
}
func (x StateOptions_StateConcurrency) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use StateOptions_StateConcurrency.Descriptor instead.
func (StateOptions_StateConcurrency) EnumDescriptor() ([]byte, []int) {
return file_dapr_proto_common_v1_common_proto_rawDescGZIP(), []int{5, 0}
}
// Enum describing the supported consistency for state.
type StateOptions_StateConsistency int32
const (
StateOptions_CONSISTENCY_UNSPECIFIED StateOptions_StateConsistency = 0
StateOptions_CONSISTENCY_EVENTUAL StateOptions_StateConsistency = 1
StateOptions_CONSISTENCY_STRONG StateOptions_StateConsistency = 2
)
// Enum value maps for StateOptions_StateConsistency.
var (
StateOptions_StateConsistency_name = map[int32]string{
0: "CONSISTENCY_UNSPECIFIED",
1: "CONSISTENCY_EVENTUAL",
2: "CONSISTENCY_STRONG",
}
StateOptions_StateConsistency_value = map[string]int32{
"CONSISTENCY_UNSPECIFIED": 0,
"CONSISTENCY_EVENTUAL": 1,
"CONSISTENCY_STRONG": 2,
}
)
func (x StateOptions_StateConsistency) Enum() *StateOptions_StateConsistency {
p := new(StateOptions_StateConsistency)
*p = x
return p
}
func (x StateOptions_StateConsistency) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (StateOptions_StateConsistency) Descriptor() protoreflect.EnumDescriptor {
return file_dapr_proto_common_v1_common_proto_enumTypes[2].Descriptor()
}
func (StateOptions_StateConsistency) Type() protoreflect.EnumType {
return &file_dapr_proto_common_v1_common_proto_enumTypes[2]
}
func (x StateOptions_StateConsistency) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use StateOptions_StateConsistency.Descriptor instead.
func (StateOptions_StateConsistency) EnumDescriptor() ([]byte, []int) {
return file_dapr_proto_common_v1_common_proto_rawDescGZIP(), []int{5, 1}
}
// HTTPExtension includes HTTP verb and querystring
// when Dapr runtime delivers HTTP content.
//
// For example, when callers calls http invoke api
// POST http://localhost:3500/v1.0/invoke/<app_id>/method/<method>?query1=value1&query2=value2
//
// Dapr runtime will parse POST as a verb and extract querystring to quersytring map.
type HTTPExtension struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Required. HTTP verb.
Verb HTTPExtension_Verb `protobuf:"varint,1,opt,name=verb,proto3,enum=dapr.proto.common.v1.HTTPExtension_Verb" json:"verb,omitempty"`
// Optional. querystring represents an encoded HTTP url query string in the following format: name=value&name2=value2
Querystring string `protobuf:"bytes,2,opt,name=querystring,proto3" json:"querystring,omitempty"`
}
func (x *HTTPExtension) Reset() {
*x = HTTPExtension{}
if protoimpl.UnsafeEnabled {
mi := &file_dapr_proto_common_v1_common_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *HTTPExtension) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*HTTPExtension) ProtoMessage() {}
func (x *HTTPExtension) ProtoReflect() protoreflect.Message {
mi := &file_dapr_proto_common_v1_common_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use HTTPExtension.ProtoReflect.Descriptor instead.
func (*HTTPExtension) Descriptor() ([]byte, []int) {
return file_dapr_proto_common_v1_common_proto_rawDescGZIP(), []int{0}
}
func (x *HTTPExtension) GetVerb() HTTPExtension_Verb {
if x != nil {
return x.Verb
}
return HTTPExtension_NONE
}
func (x *HTTPExtension) GetQuerystring() string {
if x != nil {
return x.Querystring
}
return ""
}
// InvokeRequest is the message to invoke a method with the data.
// This message is used in InvokeService of Dapr gRPC Service and OnInvoke
// of AppCallback gRPC service.
type InvokeRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Required. method is a method name which will be invoked by caller.
Method string `protobuf:"bytes,1,opt,name=method,proto3" json:"method,omitempty"`
// Required. Bytes value or Protobuf message which caller sent.
// Dapr treats Any.value as bytes type if Any.type_url is unset.
Data *anypb.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
// The type of data content.
//
// This field is required if data delivers http request body
// Otherwise, this is optional.
ContentType string `protobuf:"bytes,3,opt,name=content_type,json=contentType,proto3" json:"content_type,omitempty"`
// HTTP specific fields if request conveys http-compatible request.
//
// This field is required for http-compatible request. Otherwise,
// this field is optional.
HttpExtension *HTTPExtension `protobuf:"bytes,4,opt,name=http_extension,json=httpExtension,proto3" json:"http_extension,omitempty"`
}
func (x *InvokeRequest) Reset() {
*x = InvokeRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_dapr_proto_common_v1_common_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *InvokeRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*InvokeRequest) ProtoMessage() {}
func (x *InvokeRequest) ProtoReflect() protoreflect.Message {
mi := &file_dapr_proto_common_v1_common_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use InvokeRequest.ProtoReflect.Descriptor instead.
func (*InvokeRequest) Descriptor() ([]byte, []int) {
return file_dapr_proto_common_v1_common_proto_rawDescGZIP(), []int{1}
}
func (x *InvokeRequest) GetMethod() string {
if x != nil {
return x.Method
}
return ""
}
func (x *InvokeRequest) GetData() *anypb.Any {
if x != nil {
return x.Data
}
return nil
}
func (x *InvokeRequest) GetContentType() string {
if x != nil {
return x.ContentType
}
return ""
}
func (x *InvokeRequest) GetHttpExtension() *HTTPExtension {
if x != nil {
return x.HttpExtension
}
return nil
}
// InvokeResponse is the response message inclduing data and its content type
// from app callback.
// This message is used in InvokeService of Dapr gRPC Service and OnInvoke
// of AppCallback gRPC service.
type InvokeResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Required. The content body of InvokeService response.
Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
// Required. The type of data content.
ContentType string `protobuf:"bytes,2,opt,name=content_type,json=contentType,proto3" json:"content_type,omitempty"`
}
func (x *InvokeResponse) Reset() {
*x = InvokeResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_dapr_proto_common_v1_common_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *InvokeResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*InvokeResponse) ProtoMessage() {}
func (x *InvokeResponse) ProtoReflect() protoreflect.Message {
mi := &file_dapr_proto_common_v1_common_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use InvokeResponse.ProtoReflect.Descriptor instead.
func (*InvokeResponse) Descriptor() ([]byte, []int) {
return file_dapr_proto_common_v1_common_proto_rawDescGZIP(), []int{2}
}
func (x *InvokeResponse) GetData() *anypb.Any {
if x != nil {
return x.Data
}
return nil
}
func (x *InvokeResponse) GetContentType() string {
if x != nil {
return x.ContentType
}
return ""
}
// StateItem represents state key, value, and additional options to save state.
type StateItem struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Required. The state key
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
// Required. The state data for key
Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
// The entity tag which represents the specific version of data.
// The exact ETag format is defined by the corresponding data store.
Etag *Etag `protobuf:"bytes,3,opt,name=etag,proto3" json:"etag,omitempty"`
// The metadata which will be passed to state store component.
Metadata map[string]string `protobuf:"bytes,4,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
// Options for concurrency and consistency to save the state.
Options *StateOptions `protobuf:"bytes,5,opt,name=options,proto3" json:"options,omitempty"`
}
func (x *StateItem) Reset() {
*x = StateItem{}
if protoimpl.UnsafeEnabled {
mi := &file_dapr_proto_common_v1_common_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *StateItem) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*StateItem) ProtoMessage() {}
func (x *StateItem) ProtoReflect() protoreflect.Message {
mi := &file_dapr_proto_common_v1_common_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use StateItem.ProtoReflect.Descriptor instead.
func (*StateItem) Descriptor() ([]byte, []int) {
return file_dapr_proto_common_v1_common_proto_rawDescGZIP(), []int{3}
}
func (x *StateItem) GetKey() string {
if x != nil {
return x.Key
}
return ""
}
func (x *StateItem) GetValue() []byte {
if x != nil {
return x.Value
}
return nil
}
func (x *StateItem) GetEtag() *Etag {
if x != nil {
return x.Etag
}
return nil
}
func (x *StateItem) GetMetadata() map[string]string {
if x != nil {
return x.Metadata
}
return nil
}
func (x *StateItem) GetOptions() *StateOptions {
if x != nil {
return x.Options
}
return nil
}
// Etag represents a state item version
type Etag struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// value sets the etag value
Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
}
func (x *Etag) Reset() {
*x = Etag{}
if protoimpl.UnsafeEnabled {
mi := &file_dapr_proto_common_v1_common_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Etag) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Etag) ProtoMessage() {}
func (x *Etag) ProtoReflect() protoreflect.Message {
mi := &file_dapr_proto_common_v1_common_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Etag.ProtoReflect.Descriptor instead.
func (*Etag) Descriptor() ([]byte, []int) {
return file_dapr_proto_common_v1_common_proto_rawDescGZIP(), []int{4}
}
func (x *Etag) GetValue() string {
if x != nil {
return x.Value
}
return ""
}
// StateOptions configures concurrency and consistency for state operations
type StateOptions struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Concurrency StateOptions_StateConcurrency `protobuf:"varint,1,opt,name=concurrency,proto3,enum=dapr.proto.common.v1.StateOptions_StateConcurrency" json:"concurrency,omitempty"`
Consistency StateOptions_StateConsistency `protobuf:"varint,2,opt,name=consistency,proto3,enum=dapr.proto.common.v1.StateOptions_StateConsistency" json:"consistency,omitempty"`
}
func (x *StateOptions) Reset() {
*x = StateOptions{}
if protoimpl.UnsafeEnabled {
mi := &file_dapr_proto_common_v1_common_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *StateOptions) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*StateOptions) ProtoMessage() {}
func (x *StateOptions) ProtoReflect() protoreflect.Message {
mi := &file_dapr_proto_common_v1_common_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use StateOptions.ProtoReflect.Descriptor instead.
func (*StateOptions) Descriptor() ([]byte, []int) {
return file_dapr_proto_common_v1_common_proto_rawDescGZIP(), []int{5}
}
func (x *StateOptions) GetConcurrency() StateOptions_StateConcurrency {
if x != nil {
return x.Concurrency
}
return StateOptions_CONCURRENCY_UNSPECIFIED
}
func (x *StateOptions) GetConsistency() StateOptions_StateConsistency {
if x != nil {
return x.Consistency
}
return StateOptions_CONSISTENCY_UNSPECIFIED
}
var File_dapr_proto_common_v1_common_proto protoreflect.FileDescriptor
var file_dapr_proto_common_v1_common_proto_rawDesc = []byte{
0x0a, 0x21, 0x64, 0x61, 0x70, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x6d,
0x6d, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x12, 0x14, 0x64, 0x61, 0x70, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c,
0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x22, 0xd8, 0x01, 0x0a, 0x0d, 0x48, 0x54, 0x54, 0x50, 0x45, 0x78, 0x74,
0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x3c, 0x0a, 0x04, 0x76, 0x65, 0x72, 0x62, 0x18, 0x01,
0x20, 0x01, 0x28, 0x0e, 0x32, 0x28, 0x2e, 0x64, 0x61, 0x70, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x48, 0x54, 0x54, 0x50,
0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x56, 0x65, 0x72, 0x62, 0x52, 0x04,
0x76, 0x65, 0x72, 0x62, 0x12, 0x20, 0x0a, 0x0b, 0x71, 0x75, 0x65, 0x72, 0x79, 0x73, 0x74, 0x72,
0x69, 0x6e, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x71, 0x75, 0x65, 0x72, 0x79,
0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x22, 0x67, 0x0a, 0x04, 0x56, 0x65, 0x72, 0x62, 0x12, 0x08,
0x0a, 0x04, 0x4e, 0x4f, 0x4e, 0x45, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x47, 0x45, 0x54, 0x10,
0x01, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x45, 0x41, 0x44, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x50,
0x4f, 0x53, 0x54, 0x10, 0x03, 0x12, 0x07, 0x0a, 0x03, 0x50, 0x55, 0x54, 0x10, 0x04, 0x12, 0x0a,
0x0a, 0x06, 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x10, 0x05, 0x12, 0x0b, 0x0a, 0x07, 0x43, 0x4f,
0x4e, 0x4e, 0x45, 0x43, 0x54, 0x10, 0x06, 0x12, 0x0b, 0x0a, 0x07, 0x4f, 0x50, 0x54, 0x49, 0x4f,
0x4e, 0x53, 0x10, 0x07, 0x12, 0x09, 0x0a, 0x05, 0x54, 0x52, 0x41, 0x43, 0x45, 0x10, 0x08, 0x22,
0xc0, 0x01, 0x0a, 0x0d, 0x49, 0x6e, 0x76, 0x6f, 0x6b, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x28, 0x0a, 0x04, 0x64, 0x61, 0x74,
0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x04, 0x64,
0x61, 0x74, 0x61, 0x12, 0x21, 0x0a, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x5f, 0x74,
0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x65,
0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x4a, 0x0a, 0x0e, 0x68, 0x74, 0x74, 0x70, 0x5f, 0x65,
0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23,
0x2e, 0x64, 0x61, 0x70, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d,
0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x48, 0x54, 0x54, 0x50, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73,
0x69, 0x6f, 0x6e, 0x52, 0x0d, 0x68, 0x74, 0x74, 0x70, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69,
0x6f, 0x6e, 0x22, 0x5d, 0x0a, 0x0e, 0x49, 0x6e, 0x76, 0x6f, 0x6b, 0x65, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x12, 0x28, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x21,
0x0a, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02,
0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70,
0x65, 0x22, 0xa9, 0x02, 0x0a, 0x09, 0x53, 0x74, 0x61, 0x74, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x12,
0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65,
0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c,
0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x2e, 0x0a, 0x04, 0x65, 0x74, 0x61, 0x67, 0x18,
0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x64, 0x61, 0x70, 0x72, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x74, 0x61,
0x67, 0x52, 0x04, 0x65, 0x74, 0x61, 0x67, 0x12, 0x49, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64,
0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x64, 0x61, 0x70, 0x72,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31,
0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64,
0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61,
0x74, 0x61, 0x12, 0x3c, 0x0a, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x05, 0x20,
0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x64, 0x61, 0x70, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65,
0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73,
0x1a, 0x3b, 0x0a, 0x0d, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72,
0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03,
0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01,
0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x1c, 0x0a,
0x04, 0x45, 0x74, 0x61, 0x67, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x89, 0x03, 0x0a, 0x0c,
0x53, 0x74, 0x61, 0x74, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x55, 0x0a, 0x0b,
0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28,
0x0e, 0x32, 0x33, 0x2e, 0x64, 0x61, 0x70, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63,
0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x4f, 0x70,
0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x63, 0x75,
0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65,
0x6e, 0x63, 0x79, 0x12, 0x55, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x73, 0x69, 0x73, 0x74, 0x65, 0x6e,
0x63, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x33, 0x2e, 0x64, 0x61, 0x70, 0x72, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e,
0x53, 0x74, 0x61, 0x74, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x74, 0x61,
0x74, 0x65, 0x43, 0x6f, 0x6e, 0x73, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x52, 0x0b, 0x63,
0x6f, 0x6e, 0x73, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x22, 0x68, 0x0a, 0x10, 0x53, 0x74,
0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x1b,
0x0a, 0x17, 0x43, 0x4f, 0x4e, 0x43, 0x55, 0x52, 0x52, 0x45, 0x4e, 0x43, 0x59, 0x5f, 0x55, 0x4e,
0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x1b, 0x0a, 0x17, 0x43,
0x4f, 0x4e, 0x43, 0x55, 0x52, 0x52, 0x45, 0x4e, 0x43, 0x59, 0x5f, 0x46, 0x49, 0x52, 0x53, 0x54,
0x5f, 0x57, 0x52, 0x49, 0x54, 0x45, 0x10, 0x01, 0x12, 0x1a, 0x0a, 0x16, 0x43, 0x4f, 0x4e, 0x43,
0x55, 0x52, 0x52, 0x45, 0x4e, 0x43, 0x59, 0x5f, 0x4c, 0x41, 0x53, 0x54, 0x5f, 0x57, 0x52, 0x49,
0x54, 0x45, 0x10, 0x02, 0x22, 0x61, 0x0a, 0x10, 0x53, 0x74, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e,
0x73, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x1b, 0x0a, 0x17, 0x43, 0x4f, 0x4e, 0x53,
0x49, 0x53, 0x54, 0x45, 0x4e, 0x43, 0x59, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46,
0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x18, 0x0a, 0x14, 0x43, 0x4f, 0x4e, 0x53, 0x49, 0x53, 0x54,
0x45, 0x4e, 0x43, 0x59, 0x5f, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x55, 0x41, 0x4c, 0x10, 0x01, 0x12,
0x16, 0x0a, 0x12, 0x43, 0x4f, 0x4e, 0x53, 0x49, 0x53, 0x54, 0x45, 0x4e, 0x43, 0x59, 0x5f, 0x53,
0x54, 0x52, 0x4f, 0x4e, 0x47, 0x10, 0x02, 0x42, 0x6c, 0x0a, 0x0a, 0x69, 0x6f, 0x2e, 0x64, 0x61,
0x70, 0x72, 0x2e, 0x76, 0x31, 0x42, 0x0c, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x50, 0x72, 0x6f,
0x74, 0x6f, 0x73, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f,
0x64, 0x61, 0x70, 0x72, 0x2f, 0x67, 0x6f, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x64, 0x61, 0x70, 0x72,
0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x76, 0x31,
0x3b, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0xaa, 0x02, 0x1b, 0x44, 0x61, 0x70, 0x72, 0x2e, 0x43,
0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x41, 0x75, 0x74, 0x6f, 0x67, 0x65, 0x6e, 0x2e, 0x47, 0x72,
0x70, 0x63, 0x2e, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_dapr_proto_common_v1_common_proto_rawDescOnce sync.Once
file_dapr_proto_common_v1_common_proto_rawDescData = file_dapr_proto_common_v1_common_proto_rawDesc
)
func file_dapr_proto_common_v1_common_proto_rawDescGZIP() []byte {
file_dapr_proto_common_v1_common_proto_rawDescOnce.Do(func() {
file_dapr_proto_common_v1_common_proto_rawDescData = protoimpl.X.CompressGZIP(file_dapr_proto_common_v1_common_proto_rawDescData)
})
return file_dapr_proto_common_v1_common_proto_rawDescData
}
var (
file_dapr_proto_common_v1_common_proto_enumTypes = make([]protoimpl.EnumInfo, 3)
file_dapr_proto_common_v1_common_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
file_dapr_proto_common_v1_common_proto_goTypes = []interface{}{
(HTTPExtension_Verb)(0), // 0: dapr.proto.common.v1.HTTPExtension.Verb
(StateOptions_StateConcurrency)(0), // 1: dapr.proto.common.v1.StateOptions.StateConcurrency
(StateOptions_StateConsistency)(0), // 2: dapr.proto.common.v1.StateOptions.StateConsistency
(*HTTPExtension)(nil), // 3: dapr.proto.common.v1.HTTPExtension
(*InvokeRequest)(nil), // 4: dapr.proto.common.v1.InvokeRequest
(*InvokeResponse)(nil), // 5: dapr.proto.common.v1.InvokeResponse
(*StateItem)(nil), // 6: dapr.proto.common.v1.StateItem
(*Etag)(nil), // 7: dapr.proto.common.v1.Etag
(*StateOptions)(nil), // 8: dapr.proto.common.v1.StateOptions
nil, // 9: dapr.proto.common.v1.StateItem.MetadataEntry
(*anypb.Any)(nil), // 10: google.protobuf.Any
}
)
var file_dapr_proto_common_v1_common_proto_depIdxs = []int32{
0, // 0: dapr.proto.common.v1.HTTPExtension.verb:type_name -> dapr.proto.common.v1.HTTPExtension.Verb
10, // 1: dapr.proto.common.v1.InvokeRequest.data:type_name -> google.protobuf.Any
3, // 2: dapr.proto.common.v1.InvokeRequest.http_extension:type_name -> dapr.proto.common.v1.HTTPExtension
10, // 3: dapr.proto.common.v1.InvokeResponse.data:type_name -> google.protobuf.Any
7, // 4: dapr.proto.common.v1.StateItem.etag:type_name -> dapr.proto.common.v1.Etag
9, // 5: dapr.proto.common.v1.StateItem.metadata:type_name -> dapr.proto.common.v1.StateItem.MetadataEntry
8, // 6: dapr.proto.common.v1.StateItem.options:type_name -> dapr.proto.common.v1.StateOptions
1, // 7: dapr.proto.common.v1.StateOptions.concurrency:type_name -> dapr.proto.common.v1.StateOptions.StateConcurrency
2, // 8: dapr.proto.common.v1.StateOptions.consistency:type_name -> dapr.proto.common.v1.StateOptions.StateConsistency
9, // [9:9] is the sub-list for method output_type
9, // [9:9] is the sub-list for method input_type
9, // [9:9] is the sub-list for extension type_name
9, // [9:9] is the sub-list for extension extendee
0, // [0:9] is the sub-list for field type_name
}
func init() { file_dapr_proto_common_v1_common_proto_init() }
func file_dapr_proto_common_v1_common_proto_init() {
if File_dapr_proto_common_v1_common_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_dapr_proto_common_v1_common_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*HTTPExtension); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_dapr_proto_common_v1_common_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*InvokeRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_dapr_proto_common_v1_common_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*InvokeResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_dapr_proto_common_v1_common_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*StateItem); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_dapr_proto_common_v1_common_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Etag); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_dapr_proto_common_v1_common_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*StateOptions); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_dapr_proto_common_v1_common_proto_rawDesc,
NumEnums: 3,
NumMessages: 7,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_dapr_proto_common_v1_common_proto_goTypes,
DependencyIndexes: file_dapr_proto_common_v1_common_proto_depIdxs,
EnumInfos: file_dapr_proto_common_v1_common_proto_enumTypes,
MessageInfos: file_dapr_proto_common_v1_common_proto_msgTypes,
}.Build()
File_dapr_proto_common_v1_common_proto = out.File
file_dapr_proto_common_v1_common_proto_rawDesc = nil
file_dapr_proto_common_v1_common_proto_goTypes = nil
file_dapr_proto_common_v1_common_proto_depIdxs = nil
}

View File

@ -0,0 +1,931 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation and Dapr Contributors.
// Licensed under the MIT License.
// ------------------------------------------------------------
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.14.0
// source: dapr/proto/runtime/v1/appcallback.proto
package runtime
import (
reflect "reflect"
sync "sync"
proto "github.com/golang/protobuf/proto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
emptypb "google.golang.org/protobuf/types/known/emptypb"
v1 "github.com/dapr/dapr/pkg/proto/common/v1"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
// TopicEventResponseStatus allows apps to have finer control over handling of the message.
type TopicEventResponse_TopicEventResponseStatus int32
const (
// SUCCESS is the default behavior: message is acknowledged and not retried or logged.
TopicEventResponse_SUCCESS TopicEventResponse_TopicEventResponseStatus = 0
// RETRY status signals Dapr to retry the message as part of an expected scenario (no warning is logged).
TopicEventResponse_RETRY TopicEventResponse_TopicEventResponseStatus = 1
// DROP status signals Dapr to drop the message as part of an unexpected scenario (warning is logged).
TopicEventResponse_DROP TopicEventResponse_TopicEventResponseStatus = 2
)
// Enum value maps for TopicEventResponse_TopicEventResponseStatus.
var (
TopicEventResponse_TopicEventResponseStatus_name = map[int32]string{
0: "SUCCESS",
1: "RETRY",
2: "DROP",
}
TopicEventResponse_TopicEventResponseStatus_value = map[string]int32{
"SUCCESS": 0,
"RETRY": 1,
"DROP": 2,
}
)
func (x TopicEventResponse_TopicEventResponseStatus) Enum() *TopicEventResponse_TopicEventResponseStatus {
p := new(TopicEventResponse_TopicEventResponseStatus)
*p = x
return p
}
func (x TopicEventResponse_TopicEventResponseStatus) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (TopicEventResponse_TopicEventResponseStatus) Descriptor() protoreflect.EnumDescriptor {
return file_dapr_proto_runtime_v1_appcallback_proto_enumTypes[0].Descriptor()
}
func (TopicEventResponse_TopicEventResponseStatus) Type() protoreflect.EnumType {
return &file_dapr_proto_runtime_v1_appcallback_proto_enumTypes[0]
}
func (x TopicEventResponse_TopicEventResponseStatus) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use TopicEventResponse_TopicEventResponseStatus.Descriptor instead.
func (TopicEventResponse_TopicEventResponseStatus) EnumDescriptor() ([]byte, []int) {
return file_dapr_proto_runtime_v1_appcallback_proto_rawDescGZIP(), []int{1, 0}
}
// BindingEventConcurrency is the kind of concurrency
type BindingEventResponse_BindingEventConcurrency int32
const (
// SEQUENTIAL sends data to output bindings specified in "to" sequentially.
BindingEventResponse_SEQUENTIAL BindingEventResponse_BindingEventConcurrency = 0
// PARALLEL sends data to output bindings specified in "to" in parallel.
BindingEventResponse_PARALLEL BindingEventResponse_BindingEventConcurrency = 1
)
// Enum value maps for BindingEventResponse_BindingEventConcurrency.
var (
BindingEventResponse_BindingEventConcurrency_name = map[int32]string{
0: "SEQUENTIAL",
1: "PARALLEL",
}
BindingEventResponse_BindingEventConcurrency_value = map[string]int32{
"SEQUENTIAL": 0,
"PARALLEL": 1,
}
)
func (x BindingEventResponse_BindingEventConcurrency) Enum() *BindingEventResponse_BindingEventConcurrency {
p := new(BindingEventResponse_BindingEventConcurrency)
*p = x
return p
}
func (x BindingEventResponse_BindingEventConcurrency) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (BindingEventResponse_BindingEventConcurrency) Descriptor() protoreflect.EnumDescriptor {
return file_dapr_proto_runtime_v1_appcallback_proto_enumTypes[1].Descriptor()
}
func (BindingEventResponse_BindingEventConcurrency) Type() protoreflect.EnumType {
return &file_dapr_proto_runtime_v1_appcallback_proto_enumTypes[1]
}
func (x BindingEventResponse_BindingEventConcurrency) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use BindingEventResponse_BindingEventConcurrency.Descriptor instead.
func (BindingEventResponse_BindingEventConcurrency) EnumDescriptor() ([]byte, []int) {
return file_dapr_proto_runtime_v1_appcallback_proto_rawDescGZIP(), []int{3, 0}
}
// TopicEventRequest message is compatible with CloudEvent spec v1.0
// https://github.com/cloudevents/spec/blob/v1.0/spec.md
type TopicEventRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// id identifies the event. Producers MUST ensure that source + id
// is unique for each distinct event. If a duplicate event is re-sent
// (e.g. due to a network error) it MAY have the same id.
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
// source identifies the context in which an event happened.
// Often this will include information such as the type of the
// event source, the organization publishing the event or the process
// that produced the event. The exact syntax and semantics behind
// the data encoded in the URI is defined by the event producer.
Source string `protobuf:"bytes,2,opt,name=source,proto3" json:"source,omitempty"`
// The type of event related to the originating occurrence.
Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"`
// The version of the CloudEvents specification.
SpecVersion string `protobuf:"bytes,4,opt,name=spec_version,json=specVersion,proto3" json:"spec_version,omitempty"`
// The content type of data value.
DataContentType string `protobuf:"bytes,5,opt,name=data_content_type,json=dataContentType,proto3" json:"data_content_type,omitempty"`
// The content of the event.
Data []byte `protobuf:"bytes,7,opt,name=data,proto3" json:"data,omitempty"`
// The pubsub topic which publisher sent to.
Topic string `protobuf:"bytes,6,opt,name=topic,proto3" json:"topic,omitempty"`
// The name of the pubsub the publisher sent to.
PubsubName string `protobuf:"bytes,8,opt,name=pubsub_name,json=pubsubName,proto3" json:"pubsub_name,omitempty"`
}
func (x *TopicEventRequest) Reset() {
*x = TopicEventRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *TopicEventRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*TopicEventRequest) ProtoMessage() {}
func (x *TopicEventRequest) ProtoReflect() protoreflect.Message {
mi := &file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use TopicEventRequest.ProtoReflect.Descriptor instead.
func (*TopicEventRequest) Descriptor() ([]byte, []int) {
return file_dapr_proto_runtime_v1_appcallback_proto_rawDescGZIP(), []int{0}
}
func (x *TopicEventRequest) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *TopicEventRequest) GetSource() string {
if x != nil {
return x.Source
}
return ""
}
func (x *TopicEventRequest) GetType() string {
if x != nil {
return x.Type
}
return ""
}
func (x *TopicEventRequest) GetSpecVersion() string {
if x != nil {
return x.SpecVersion
}
return ""
}
func (x *TopicEventRequest) GetDataContentType() string {
if x != nil {
return x.DataContentType
}
return ""
}
func (x *TopicEventRequest) GetData() []byte {
if x != nil {
return x.Data
}
return nil
}
func (x *TopicEventRequest) GetTopic() string {
if x != nil {
return x.Topic
}
return ""
}
func (x *TopicEventRequest) GetPubsubName() string {
if x != nil {
return x.PubsubName
}
return ""
}
// TopicEventResponse is response from app on published message
type TopicEventResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// The list of output bindings.
Status TopicEventResponse_TopicEventResponseStatus `protobuf:"varint,1,opt,name=status,proto3,enum=dapr.proto.runtime.v1.TopicEventResponse_TopicEventResponseStatus" json:"status,omitempty"`
}
func (x *TopicEventResponse) Reset() {
*x = TopicEventResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *TopicEventResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*TopicEventResponse) ProtoMessage() {}
func (x *TopicEventResponse) ProtoReflect() protoreflect.Message {
mi := &file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use TopicEventResponse.ProtoReflect.Descriptor instead.
func (*TopicEventResponse) Descriptor() ([]byte, []int) {
return file_dapr_proto_runtime_v1_appcallback_proto_rawDescGZIP(), []int{1}
}
func (x *TopicEventResponse) GetStatus() TopicEventResponse_TopicEventResponseStatus {
if x != nil {
return x.Status
}
return TopicEventResponse_SUCCESS
}
// BindingEventRequest represents input bindings event.
type BindingEventRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Required. The name of the input binding component.
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
// Required. The payload that the input bindings sent
Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
// The metadata set by the input binging components.
Metadata map[string]string `protobuf:"bytes,3,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
}
func (x *BindingEventRequest) Reset() {
*x = BindingEventRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *BindingEventRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*BindingEventRequest) ProtoMessage() {}
func (x *BindingEventRequest) ProtoReflect() protoreflect.Message {
mi := &file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use BindingEventRequest.ProtoReflect.Descriptor instead.
func (*BindingEventRequest) Descriptor() ([]byte, []int) {
return file_dapr_proto_runtime_v1_appcallback_proto_rawDescGZIP(), []int{2}
}
func (x *BindingEventRequest) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *BindingEventRequest) GetData() []byte {
if x != nil {
return x.Data
}
return nil
}
func (x *BindingEventRequest) GetMetadata() map[string]string {
if x != nil {
return x.Metadata
}
return nil
}
// BindingEventResponse includes operations to save state or
// send data to output bindings optionally.
type BindingEventResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// The name of state store where states are saved.
StoreName string `protobuf:"bytes,1,opt,name=store_name,json=storeName,proto3" json:"store_name,omitempty"`
// The state key values which will be stored in store_name.
States []*v1.StateItem `protobuf:"bytes,2,rep,name=states,proto3" json:"states,omitempty"`
// The list of output bindings.
To []string `protobuf:"bytes,3,rep,name=to,proto3" json:"to,omitempty"`
// The content which will be sent to "to" output bindings.
Data []byte `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"`
// The concurrency of output bindings to send data to
// "to" output bindings list. The default is SEQUENTIAL.
Concurrency BindingEventResponse_BindingEventConcurrency `protobuf:"varint,5,opt,name=concurrency,proto3,enum=dapr.proto.runtime.v1.BindingEventResponse_BindingEventConcurrency" json:"concurrency,omitempty"`
}
func (x *BindingEventResponse) Reset() {
*x = BindingEventResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *BindingEventResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*BindingEventResponse) ProtoMessage() {}
func (x *BindingEventResponse) ProtoReflect() protoreflect.Message {
mi := &file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use BindingEventResponse.ProtoReflect.Descriptor instead.
func (*BindingEventResponse) Descriptor() ([]byte, []int) {
return file_dapr_proto_runtime_v1_appcallback_proto_rawDescGZIP(), []int{3}
}
func (x *BindingEventResponse) GetStoreName() string {
if x != nil {
return x.StoreName
}
return ""
}
func (x *BindingEventResponse) GetStates() []*v1.StateItem {
if x != nil {
return x.States
}
return nil
}
func (x *BindingEventResponse) GetTo() []string {
if x != nil {
return x.To
}
return nil
}
func (x *BindingEventResponse) GetData() []byte {
if x != nil {
return x.Data
}
return nil
}
func (x *BindingEventResponse) GetConcurrency() BindingEventResponse_BindingEventConcurrency {
if x != nil {
return x.Concurrency
}
return BindingEventResponse_SEQUENTIAL
}
// ListTopicSubscriptionsResponse is the message including the list of the subscribing topics.
type ListTopicSubscriptionsResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// The list of topics.
Subscriptions []*TopicSubscription `protobuf:"bytes,1,rep,name=subscriptions,proto3" json:"subscriptions,omitempty"`
}
func (x *ListTopicSubscriptionsResponse) Reset() {
*x = ListTopicSubscriptionsResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ListTopicSubscriptionsResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListTopicSubscriptionsResponse) ProtoMessage() {}
func (x *ListTopicSubscriptionsResponse) ProtoReflect() protoreflect.Message {
mi := &file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ListTopicSubscriptionsResponse.ProtoReflect.Descriptor instead.
func (*ListTopicSubscriptionsResponse) Descriptor() ([]byte, []int) {
return file_dapr_proto_runtime_v1_appcallback_proto_rawDescGZIP(), []int{4}
}
func (x *ListTopicSubscriptionsResponse) GetSubscriptions() []*TopicSubscription {
if x != nil {
return x.Subscriptions
}
return nil
}
// TopicSubscription represents topic and metadata.
type TopicSubscription struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Required. The name of the pubsub containing the topic below to subscribe to.
PubsubName string `protobuf:"bytes,1,opt,name=pubsub_name,json=pubsubName,proto3" json:"pubsub_name,omitempty"`
// Required. The name of topic which will be subscribed
Topic string `protobuf:"bytes,2,opt,name=topic,proto3" json:"topic,omitempty"`
// The optional properties used for this topic's subscription e.g. session id
Metadata map[string]string `protobuf:"bytes,3,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
}
func (x *TopicSubscription) Reset() {
*x = TopicSubscription{}
if protoimpl.UnsafeEnabled {
mi := &file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *TopicSubscription) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*TopicSubscription) ProtoMessage() {}
func (x *TopicSubscription) ProtoReflect() protoreflect.Message {
mi := &file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use TopicSubscription.ProtoReflect.Descriptor instead.
func (*TopicSubscription) Descriptor() ([]byte, []int) {
return file_dapr_proto_runtime_v1_appcallback_proto_rawDescGZIP(), []int{5}
}
func (x *TopicSubscription) GetPubsubName() string {
if x != nil {
return x.PubsubName
}
return ""
}
func (x *TopicSubscription) GetTopic() string {
if x != nil {
return x.Topic
}
return ""
}
func (x *TopicSubscription) GetMetadata() map[string]string {
if x != nil {
return x.Metadata
}
return nil
}
// ListInputBindingsResponse is the message including the list of input bindings.
type ListInputBindingsResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// The list of input bindings.
Bindings []string `protobuf:"bytes,1,rep,name=bindings,proto3" json:"bindings,omitempty"`
}
func (x *ListInputBindingsResponse) Reset() {
*x = ListInputBindingsResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ListInputBindingsResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListInputBindingsResponse) ProtoMessage() {}
func (x *ListInputBindingsResponse) ProtoReflect() protoreflect.Message {
mi := &file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[6]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ListInputBindingsResponse.ProtoReflect.Descriptor instead.
func (*ListInputBindingsResponse) Descriptor() ([]byte, []int) {
return file_dapr_proto_runtime_v1_appcallback_proto_rawDescGZIP(), []int{6}
}
func (x *ListInputBindingsResponse) GetBindings() []string {
if x != nil {
return x.Bindings
}
return nil
}
var File_dapr_proto_runtime_v1_appcallback_proto protoreflect.FileDescriptor
var file_dapr_proto_runtime_v1_appcallback_proto_rawDesc = []byte{
0x0a, 0x27, 0x64, 0x61, 0x70, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x75, 0x6e,
0x74, 0x69, 0x6d, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x70, 0x70, 0x63, 0x61, 0x6c, 0x6c, 0x62,
0x61, 0x63, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x15, 0x64, 0x61, 0x70, 0x72, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31,
0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x21, 0x64,
0x61, 0x70, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e,
0x2f, 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x22, 0xe9, 0x01, 0x0a, 0x11, 0x54, 0x6f, 0x70, 0x69, 0x63, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65,
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x12,
0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79,
0x70, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x70, 0x65, 0x63, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69,
0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x70, 0x65, 0x63, 0x56, 0x65,
0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x2a, 0x0a, 0x11, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x63, 0x6f,
0x6e, 0x74, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09,
0x52, 0x0f, 0x64, 0x61, 0x74, 0x61, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70,
0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x52,
0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x18, 0x06,
0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x12, 0x1f, 0x0a, 0x0b, 0x70,
0x75, 0x62, 0x73, 0x75, 0x62, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09,
0x52, 0x0a, 0x70, 0x75, 0x62, 0x73, 0x75, 0x62, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0xae, 0x01, 0x0a,
0x12, 0x54, 0x6f, 0x70, 0x69, 0x63, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x12, 0x5a, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20,
0x01, 0x28, 0x0e, 0x32, 0x42, 0x2e, 0x64, 0x61, 0x70, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x6f, 0x70, 0x69,
0x63, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x54,
0x6f, 0x70, 0x69, 0x63, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22,
0x3c, 0x0a, 0x18, 0x54, 0x6f, 0x70, 0x69, 0x63, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x0b, 0x0a, 0x07, 0x53,
0x55, 0x43, 0x43, 0x45, 0x53, 0x53, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x52, 0x45, 0x54, 0x52,
0x59, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x44, 0x52, 0x4f, 0x50, 0x10, 0x02, 0x22, 0xd0, 0x01,
0x0a, 0x13, 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74,
0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x54, 0x0a,
0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32,
0x38, 0x2e, 0x64, 0x61, 0x70, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x75, 0x6e,
0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x45,
0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x4d, 0x65, 0x74, 0x61,
0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64,
0x61, 0x74, 0x61, 0x1a, 0x3b, 0x0a, 0x0d, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45,
0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28,
0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01,
0x22, 0xb2, 0x02, 0x0a, 0x14, 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x45, 0x76, 0x65, 0x6e,
0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x6f,
0x72, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73,
0x74, 0x6f, 0x72, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x37, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74,
0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x64, 0x61, 0x70, 0x72, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e,
0x53, 0x74, 0x61, 0x74, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x65,
0x73, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x02, 0x74,
0x6f, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52,
0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x65, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72,
0x65, 0x6e, 0x63, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x43, 0x2e, 0x64, 0x61, 0x70,
0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e,
0x76, 0x31, 0x2e, 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x45,
0x76, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x52,
0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x22, 0x37, 0x0a, 0x17,
0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x63,
0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x0e, 0x0a, 0x0a, 0x53, 0x45, 0x51, 0x55, 0x45,
0x4e, 0x54, 0x49, 0x41, 0x4c, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x50, 0x41, 0x52, 0x41, 0x4c,
0x4c, 0x45, 0x4c, 0x10, 0x01, 0x22, 0x70, 0x0a, 0x1e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x6f, 0x70,
0x69, 0x63, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4e, 0x0a, 0x0d, 0x73, 0x75, 0x62, 0x73, 0x63,
0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28,
0x2e, 0x64, 0x61, 0x70, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x75, 0x6e, 0x74,
0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x6f, 0x70, 0x69, 0x63, 0x53, 0x75, 0x62, 0x73,
0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0d, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72,
0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0xdb, 0x01, 0x0a, 0x11, 0x54, 0x6f, 0x70, 0x69,
0x63, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x0a,
0x0b, 0x70, 0x75, 0x62, 0x73, 0x75, 0x62, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x0a, 0x70, 0x75, 0x62, 0x73, 0x75, 0x62, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x14,
0x0a, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74,
0x6f, 0x70, 0x69, 0x63, 0x12, 0x52, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61,
0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x36, 0x2e, 0x64, 0x61, 0x70, 0x72, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54,
0x6f, 0x70, 0x69, 0x63, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e,
0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08,
0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x1a, 0x3b, 0x0a, 0x0d, 0x4d, 0x65, 0x74, 0x61,
0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79,
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76,
0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75,
0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x37, 0x0a, 0x19, 0x4c, 0x69, 0x73, 0x74, 0x49, 0x6e, 0x70,
0x75, 0x74, 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x62, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x01,
0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x62, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x32, 0x86,
0x04, 0x0a, 0x0b, 0x41, 0x70, 0x70, 0x43, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, 0x57,
0x0a, 0x08, 0x4f, 0x6e, 0x49, 0x6e, 0x76, 0x6f, 0x6b, 0x65, 0x12, 0x23, 0x2e, 0x64, 0x61, 0x70,
0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76,
0x31, 0x2e, 0x49, 0x6e, 0x76, 0x6f, 0x6b, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
0x24, 0x2e, 0x64, 0x61, 0x70, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d,
0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x76, 0x6f, 0x6b, 0x65, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x69, 0x0a, 0x16, 0x4c, 0x69, 0x73, 0x74, 0x54,
0x6f, 0x70, 0x69, 0x63, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e,
0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x35, 0x2e, 0x64, 0x61, 0x70, 0x72,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76,
0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x6f, 0x70, 0x69, 0x63, 0x53, 0x75, 0x62, 0x73, 0x63,
0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x22, 0x00, 0x12, 0x65, 0x0a, 0x0c, 0x4f, 0x6e, 0x54, 0x6f, 0x70, 0x69, 0x63, 0x45, 0x76, 0x65,
0x6e, 0x74, 0x12, 0x28, 0x2e, 0x64, 0x61, 0x70, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x6f, 0x70, 0x69, 0x63,
0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x64,
0x61, 0x70, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d,
0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x6f, 0x70, 0x69, 0x63, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5f, 0x0a, 0x11, 0x4c, 0x69, 0x73,
0x74, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x16,
0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x30, 0x2e, 0x64, 0x61, 0x70, 0x72, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c,
0x69, 0x73, 0x74, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x73,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x6b, 0x0a, 0x0e, 0x4f, 0x6e,
0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x2a, 0x2e, 0x64,
0x61, 0x70, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d,
0x65, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x45, 0x76, 0x65, 0x6e,
0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2b, 0x2e, 0x64, 0x61, 0x70, 0x72, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31,
0x2e, 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x7c, 0x0a, 0x0a, 0x69, 0x6f, 0x2e, 0x64, 0x61,
0x70, 0x72, 0x2e, 0x76, 0x31, 0x42, 0x15, 0x44, 0x61, 0x70, 0x72, 0x41, 0x70, 0x70, 0x43, 0x61,
0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x5a, 0x34, 0x67, 0x69,
0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x61, 0x70, 0x72, 0x2f, 0x67, 0x6f,
0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x64, 0x61, 0x70, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f,
0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x72, 0x75, 0x6e, 0x74, 0x69,
0x6d, 0x65, 0xaa, 0x02, 0x20, 0x44, 0x61, 0x70, 0x72, 0x2e, 0x41, 0x70, 0x70, 0x43, 0x61, 0x6c,
0x6c, 0x62, 0x61, 0x63, 0x6b, 0x2e, 0x41, 0x75, 0x74, 0x6f, 0x67, 0x65, 0x6e, 0x2e, 0x47, 0x72,
0x70, 0x63, 0x2e, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_dapr_proto_runtime_v1_appcallback_proto_rawDescOnce sync.Once
file_dapr_proto_runtime_v1_appcallback_proto_rawDescData = file_dapr_proto_runtime_v1_appcallback_proto_rawDesc
)
func file_dapr_proto_runtime_v1_appcallback_proto_rawDescGZIP() []byte {
file_dapr_proto_runtime_v1_appcallback_proto_rawDescOnce.Do(func() {
file_dapr_proto_runtime_v1_appcallback_proto_rawDescData = protoimpl.X.CompressGZIP(file_dapr_proto_runtime_v1_appcallback_proto_rawDescData)
})
return file_dapr_proto_runtime_v1_appcallback_proto_rawDescData
}
var (
file_dapr_proto_runtime_v1_appcallback_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
file_dapr_proto_runtime_v1_appcallback_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
file_dapr_proto_runtime_v1_appcallback_proto_goTypes = []interface{}{
(TopicEventResponse_TopicEventResponseStatus)(0), // 0: dapr.proto.runtime.v1.TopicEventResponse.TopicEventResponseStatus
(BindingEventResponse_BindingEventConcurrency)(0), // 1: dapr.proto.runtime.v1.BindingEventResponse.BindingEventConcurrency
(*TopicEventRequest)(nil), // 2: dapr.proto.runtime.v1.TopicEventRequest
(*TopicEventResponse)(nil), // 3: dapr.proto.runtime.v1.TopicEventResponse
(*BindingEventRequest)(nil), // 4: dapr.proto.runtime.v1.BindingEventRequest
(*BindingEventResponse)(nil), // 5: dapr.proto.runtime.v1.BindingEventResponse
(*ListTopicSubscriptionsResponse)(nil), // 6: dapr.proto.runtime.v1.ListTopicSubscriptionsResponse
(*TopicSubscription)(nil), // 7: dapr.proto.runtime.v1.TopicSubscription
(*ListInputBindingsResponse)(nil), // 8: dapr.proto.runtime.v1.ListInputBindingsResponse
nil, // 9: dapr.proto.runtime.v1.BindingEventRequest.MetadataEntry
nil, // 10: dapr.proto.runtime.v1.TopicSubscription.MetadataEntry
(*v1.StateItem)(nil), // 11: dapr.proto.common.v1.StateItem
(*v1.InvokeRequest)(nil), // 12: dapr.proto.common.v1.InvokeRequest
(*emptypb.Empty)(nil), // 13: google.protobuf.Empty
(*v1.InvokeResponse)(nil), // 14: dapr.proto.common.v1.InvokeResponse
}
)
var file_dapr_proto_runtime_v1_appcallback_proto_depIdxs = []int32{
0, // 0: dapr.proto.runtime.v1.TopicEventResponse.status:type_name -> dapr.proto.runtime.v1.TopicEventResponse.TopicEventResponseStatus
9, // 1: dapr.proto.runtime.v1.BindingEventRequest.metadata:type_name -> dapr.proto.runtime.v1.BindingEventRequest.MetadataEntry
11, // 2: dapr.proto.runtime.v1.BindingEventResponse.states:type_name -> dapr.proto.common.v1.StateItem
1, // 3: dapr.proto.runtime.v1.BindingEventResponse.concurrency:type_name -> dapr.proto.runtime.v1.BindingEventResponse.BindingEventConcurrency
7, // 4: dapr.proto.runtime.v1.ListTopicSubscriptionsResponse.subscriptions:type_name -> dapr.proto.runtime.v1.TopicSubscription
10, // 5: dapr.proto.runtime.v1.TopicSubscription.metadata:type_name -> dapr.proto.runtime.v1.TopicSubscription.MetadataEntry
12, // 6: dapr.proto.runtime.v1.AppCallback.OnInvoke:input_type -> dapr.proto.common.v1.InvokeRequest
13, // 7: dapr.proto.runtime.v1.AppCallback.ListTopicSubscriptions:input_type -> google.protobuf.Empty
2, // 8: dapr.proto.runtime.v1.AppCallback.OnTopicEvent:input_type -> dapr.proto.runtime.v1.TopicEventRequest
13, // 9: dapr.proto.runtime.v1.AppCallback.ListInputBindings:input_type -> google.protobuf.Empty
4, // 10: dapr.proto.runtime.v1.AppCallback.OnBindingEvent:input_type -> dapr.proto.runtime.v1.BindingEventRequest
14, // 11: dapr.proto.runtime.v1.AppCallback.OnInvoke:output_type -> dapr.proto.common.v1.InvokeResponse
6, // 12: dapr.proto.runtime.v1.AppCallback.ListTopicSubscriptions:output_type -> dapr.proto.runtime.v1.ListTopicSubscriptionsResponse
3, // 13: dapr.proto.runtime.v1.AppCallback.OnTopicEvent:output_type -> dapr.proto.runtime.v1.TopicEventResponse
8, // 14: dapr.proto.runtime.v1.AppCallback.ListInputBindings:output_type -> dapr.proto.runtime.v1.ListInputBindingsResponse
5, // 15: dapr.proto.runtime.v1.AppCallback.OnBindingEvent:output_type -> dapr.proto.runtime.v1.BindingEventResponse
11, // [11:16] is the sub-list for method output_type
6, // [6:11] is the sub-list for method input_type
6, // [6:6] is the sub-list for extension type_name
6, // [6:6] is the sub-list for extension extendee
0, // [0:6] is the sub-list for field type_name
}
func init() { file_dapr_proto_runtime_v1_appcallback_proto_init() }
func file_dapr_proto_runtime_v1_appcallback_proto_init() {
if File_dapr_proto_runtime_v1_appcallback_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*TopicEventRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*TopicEventResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*BindingEventRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*BindingEventResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListTopicSubscriptionsResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*TopicSubscription); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListInputBindingsResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_dapr_proto_runtime_v1_appcallback_proto_rawDesc,
NumEnums: 2,
NumMessages: 9,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_dapr_proto_runtime_v1_appcallback_proto_goTypes,
DependencyIndexes: file_dapr_proto_runtime_v1_appcallback_proto_depIdxs,
EnumInfos: file_dapr_proto_runtime_v1_appcallback_proto_enumTypes,
MessageInfos: file_dapr_proto_runtime_v1_appcallback_proto_msgTypes,
}.Build()
File_dapr_proto_runtime_v1_appcallback_proto = out.File
file_dapr_proto_runtime_v1_appcallback_proto_rawDesc = nil
file_dapr_proto_runtime_v1_appcallback_proto_goTypes = nil
file_dapr_proto_runtime_v1_appcallback_proto_depIdxs = nil
}

View File

@ -0,0 +1,268 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
package runtime
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
emptypb "google.golang.org/protobuf/types/known/emptypb"
v1 "github.com/dapr/dapr/pkg/proto/common/v1"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// AppCallbackClient is the client API for AppCallback service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type AppCallbackClient interface {
// Invokes service method with InvokeRequest.
OnInvoke(ctx context.Context, in *v1.InvokeRequest, opts ...grpc.CallOption) (*v1.InvokeResponse, error)
// Lists all topics subscribed by this app.
ListTopicSubscriptions(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*ListTopicSubscriptionsResponse, error)
// Subscribes events from Pubsub
OnTopicEvent(ctx context.Context, in *TopicEventRequest, opts ...grpc.CallOption) (*TopicEventResponse, error)
// Lists all input bindings subscribed by this app.
ListInputBindings(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*ListInputBindingsResponse, error)
// Listens events from the input bindings
//
// User application can save the states or send the events to the output
// bindings optionally by returning BindingEventResponse.
OnBindingEvent(ctx context.Context, in *BindingEventRequest, opts ...grpc.CallOption) (*BindingEventResponse, error)
}
type appCallbackClient struct {
cc grpc.ClientConnInterface
}
func NewAppCallbackClient(cc grpc.ClientConnInterface) AppCallbackClient {
return &appCallbackClient{cc}
}
func (c *appCallbackClient) OnInvoke(ctx context.Context, in *v1.InvokeRequest, opts ...grpc.CallOption) (*v1.InvokeResponse, error) {
out := new(v1.InvokeResponse)
err := c.cc.Invoke(ctx, "/dapr.proto.runtime.v1.AppCallback/OnInvoke", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *appCallbackClient) ListTopicSubscriptions(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*ListTopicSubscriptionsResponse, error) {
out := new(ListTopicSubscriptionsResponse)
err := c.cc.Invoke(ctx, "/dapr.proto.runtime.v1.AppCallback/ListTopicSubscriptions", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *appCallbackClient) OnTopicEvent(ctx context.Context, in *TopicEventRequest, opts ...grpc.CallOption) (*TopicEventResponse, error) {
out := new(TopicEventResponse)
err := c.cc.Invoke(ctx, "/dapr.proto.runtime.v1.AppCallback/OnTopicEvent", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *appCallbackClient) ListInputBindings(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*ListInputBindingsResponse, error) {
out := new(ListInputBindingsResponse)
err := c.cc.Invoke(ctx, "/dapr.proto.runtime.v1.AppCallback/ListInputBindings", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *appCallbackClient) OnBindingEvent(ctx context.Context, in *BindingEventRequest, opts ...grpc.CallOption) (*BindingEventResponse, error) {
out := new(BindingEventResponse)
err := c.cc.Invoke(ctx, "/dapr.proto.runtime.v1.AppCallback/OnBindingEvent", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// AppCallbackServer is the server API for AppCallback service.
// All implementations must embed UnimplementedAppCallbackServer
// for forward compatibility
type AppCallbackServer interface {
// Invokes service method with InvokeRequest.
OnInvoke(context.Context, *v1.InvokeRequest) (*v1.InvokeResponse, error)
// Lists all topics subscribed by this app.
ListTopicSubscriptions(context.Context, *emptypb.Empty) (*ListTopicSubscriptionsResponse, error)
// Subscribes events from Pubsub
OnTopicEvent(context.Context, *TopicEventRequest) (*TopicEventResponse, error)
// Lists all input bindings subscribed by this app.
ListInputBindings(context.Context, *emptypb.Empty) (*ListInputBindingsResponse, error)
// Listens events from the input bindings
//
// User application can save the states or send the events to the output
// bindings optionally by returning BindingEventResponse.
OnBindingEvent(context.Context, *BindingEventRequest) (*BindingEventResponse, error)
mustEmbedUnimplementedAppCallbackServer()
}
// UnimplementedAppCallbackServer must be embedded to have forward compatible implementations.
type UnimplementedAppCallbackServer struct{}
func (UnimplementedAppCallbackServer) OnInvoke(context.Context, *v1.InvokeRequest) (*v1.InvokeResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method OnInvoke not implemented")
}
func (UnimplementedAppCallbackServer) ListTopicSubscriptions(context.Context, *emptypb.Empty) (*ListTopicSubscriptionsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListTopicSubscriptions not implemented")
}
func (UnimplementedAppCallbackServer) OnTopicEvent(context.Context, *TopicEventRequest) (*TopicEventResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method OnTopicEvent not implemented")
}
func (UnimplementedAppCallbackServer) ListInputBindings(context.Context, *emptypb.Empty) (*ListInputBindingsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListInputBindings not implemented")
}
func (UnimplementedAppCallbackServer) OnBindingEvent(context.Context, *BindingEventRequest) (*BindingEventResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method OnBindingEvent not implemented")
}
func (UnimplementedAppCallbackServer) mustEmbedUnimplementedAppCallbackServer() {}
// UnsafeAppCallbackServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to AppCallbackServer will
// result in compilation errors.
type UnsafeAppCallbackServer interface {
mustEmbedUnimplementedAppCallbackServer()
}
func RegisterAppCallbackServer(s grpc.ServiceRegistrar, srv AppCallbackServer) {
s.RegisterService(&AppCallback_ServiceDesc, srv)
}
func _AppCallback_OnInvoke_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(v1.InvokeRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AppCallbackServer).OnInvoke(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/dapr.proto.runtime.v1.AppCallback/OnInvoke",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AppCallbackServer).OnInvoke(ctx, req.(*v1.InvokeRequest))
}
return interceptor(ctx, in, info, handler)
}
func _AppCallback_ListTopicSubscriptions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(emptypb.Empty)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AppCallbackServer).ListTopicSubscriptions(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/dapr.proto.runtime.v1.AppCallback/ListTopicSubscriptions",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AppCallbackServer).ListTopicSubscriptions(ctx, req.(*emptypb.Empty))
}
return interceptor(ctx, in, info, handler)
}
func _AppCallback_OnTopicEvent_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(TopicEventRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AppCallbackServer).OnTopicEvent(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/dapr.proto.runtime.v1.AppCallback/OnTopicEvent",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AppCallbackServer).OnTopicEvent(ctx, req.(*TopicEventRequest))
}
return interceptor(ctx, in, info, handler)
}
func _AppCallback_ListInputBindings_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(emptypb.Empty)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AppCallbackServer).ListInputBindings(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/dapr.proto.runtime.v1.AppCallback/ListInputBindings",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AppCallbackServer).ListInputBindings(ctx, req.(*emptypb.Empty))
}
return interceptor(ctx, in, info, handler)
}
func _AppCallback_OnBindingEvent_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(BindingEventRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AppCallbackServer).OnBindingEvent(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/dapr.proto.runtime.v1.AppCallback/OnBindingEvent",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AppCallbackServer).OnBindingEvent(ctx, req.(*BindingEventRequest))
}
return interceptor(ctx, in, info, handler)
}
// AppCallback_ServiceDesc is the grpc.ServiceDesc for AppCallback service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var AppCallback_ServiceDesc = grpc.ServiceDesc{
ServiceName: "dapr.proto.runtime.v1.AppCallback",
HandlerType: (*AppCallbackServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "OnInvoke",
Handler: _AppCallback_OnInvoke_Handler,
},
{
MethodName: "ListTopicSubscriptions",
Handler: _AppCallback_ListTopicSubscriptions_Handler,
},
{
MethodName: "OnTopicEvent",
Handler: _AppCallback_OnTopicEvent_Handler,
},
{
MethodName: "ListInputBindings",
Handler: _AppCallback_ListInputBindings_Handler,
},
{
MethodName: "OnBindingEvent",
Handler: _AppCallback_OnBindingEvent_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "dapr/proto/runtime/v1/appcallback.proto",
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,886 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
package runtime
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
emptypb "google.golang.org/protobuf/types/known/emptypb"
v1 "github.com/dapr/dapr/pkg/proto/common/v1"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// DaprClient is the client API for Dapr service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type DaprClient interface {
// Invokes a method on a remote Dapr app.
InvokeService(ctx context.Context, in *InvokeServiceRequest, opts ...grpc.CallOption) (*v1.InvokeResponse, error)
// Gets the state for a specific key.
GetState(ctx context.Context, in *GetStateRequest, opts ...grpc.CallOption) (*GetStateResponse, error)
// Gets a bulk of state items for a list of keys
GetBulkState(ctx context.Context, in *GetBulkStateRequest, opts ...grpc.CallOption) (*GetBulkStateResponse, error)
// Saves the state for a specific key.
SaveState(ctx context.Context, in *SaveStateRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
// Deletes the state for a specific key.
DeleteState(ctx context.Context, in *DeleteStateRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
// Deletes a bulk of state items for a list of keys
DeleteBulkState(ctx context.Context, in *DeleteBulkStateRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
// Executes transactions for a specified store
ExecuteStateTransaction(ctx context.Context, in *ExecuteStateTransactionRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
// Publishes events to the specific topic.
PublishEvent(ctx context.Context, in *PublishEventRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
// Invokes binding data to specific output bindings
InvokeBinding(ctx context.Context, in *InvokeBindingRequest, opts ...grpc.CallOption) (*InvokeBindingResponse, error)
// Gets secrets from secret stores.
GetSecret(ctx context.Context, in *GetSecretRequest, opts ...grpc.CallOption) (*GetSecretResponse, error)
// Gets a bulk of secrets
GetBulkSecret(ctx context.Context, in *GetBulkSecretRequest, opts ...grpc.CallOption) (*GetBulkSecretResponse, error)
// Register an actor timer.
RegisterActorTimer(ctx context.Context, in *RegisterActorTimerRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
// Unregister an actor timer.
UnregisterActorTimer(ctx context.Context, in *UnregisterActorTimerRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
// Register an actor reminder.
RegisterActorReminder(ctx context.Context, in *RegisterActorReminderRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
// Unregister an actor reminder.
UnregisterActorReminder(ctx context.Context, in *UnregisterActorReminderRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
// Gets the state for a specific actor.
GetActorState(ctx context.Context, in *GetActorStateRequest, opts ...grpc.CallOption) (*GetActorStateResponse, error)
// Executes state transactions for a specified actor
ExecuteActorStateTransaction(ctx context.Context, in *ExecuteActorStateTransactionRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
// InvokeActor calls a method on an actor.
InvokeActor(ctx context.Context, in *InvokeActorRequest, opts ...grpc.CallOption) (*InvokeActorResponse, error)
// Gets metadata of the sidecar
GetMetadata(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*GetMetadataResponse, error)
// Sets value in extended metadata of the sidecar
SetMetadata(ctx context.Context, in *SetMetadataRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
// Shutdown the sidecar
Shutdown(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error)
}
type daprClient struct {
cc grpc.ClientConnInterface
}
func NewDaprClient(cc grpc.ClientConnInterface) DaprClient {
return &daprClient{cc}
}
func (c *daprClient) InvokeService(ctx context.Context, in *InvokeServiceRequest, opts ...grpc.CallOption) (*v1.InvokeResponse, error) {
out := new(v1.InvokeResponse)
err := c.cc.Invoke(ctx, "/dapr.proto.runtime.v1.Dapr/InvokeService", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *daprClient) GetState(ctx context.Context, in *GetStateRequest, opts ...grpc.CallOption) (*GetStateResponse, error) {
out := new(GetStateResponse)
err := c.cc.Invoke(ctx, "/dapr.proto.runtime.v1.Dapr/GetState", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *daprClient) GetBulkState(ctx context.Context, in *GetBulkStateRequest, opts ...grpc.CallOption) (*GetBulkStateResponse, error) {
out := new(GetBulkStateResponse)
err := c.cc.Invoke(ctx, "/dapr.proto.runtime.v1.Dapr/GetBulkState", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *daprClient) SaveState(ctx context.Context, in *SaveStateRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, "/dapr.proto.runtime.v1.Dapr/SaveState", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *daprClient) DeleteState(ctx context.Context, in *DeleteStateRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, "/dapr.proto.runtime.v1.Dapr/DeleteState", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *daprClient) DeleteBulkState(ctx context.Context, in *DeleteBulkStateRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, "/dapr.proto.runtime.v1.Dapr/DeleteBulkState", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *daprClient) ExecuteStateTransaction(ctx context.Context, in *ExecuteStateTransactionRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, "/dapr.proto.runtime.v1.Dapr/ExecuteStateTransaction", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *daprClient) PublishEvent(ctx context.Context, in *PublishEventRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, "/dapr.proto.runtime.v1.Dapr/PublishEvent", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *daprClient) InvokeBinding(ctx context.Context, in *InvokeBindingRequest, opts ...grpc.CallOption) (*InvokeBindingResponse, error) {
out := new(InvokeBindingResponse)
err := c.cc.Invoke(ctx, "/dapr.proto.runtime.v1.Dapr/InvokeBinding", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *daprClient) GetSecret(ctx context.Context, in *GetSecretRequest, opts ...grpc.CallOption) (*GetSecretResponse, error) {
out := new(GetSecretResponse)
err := c.cc.Invoke(ctx, "/dapr.proto.runtime.v1.Dapr/GetSecret", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *daprClient) GetBulkSecret(ctx context.Context, in *GetBulkSecretRequest, opts ...grpc.CallOption) (*GetBulkSecretResponse, error) {
out := new(GetBulkSecretResponse)
err := c.cc.Invoke(ctx, "/dapr.proto.runtime.v1.Dapr/GetBulkSecret", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *daprClient) RegisterActorTimer(ctx context.Context, in *RegisterActorTimerRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, "/dapr.proto.runtime.v1.Dapr/RegisterActorTimer", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *daprClient) UnregisterActorTimer(ctx context.Context, in *UnregisterActorTimerRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, "/dapr.proto.runtime.v1.Dapr/UnregisterActorTimer", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *daprClient) RegisterActorReminder(ctx context.Context, in *RegisterActorReminderRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, "/dapr.proto.runtime.v1.Dapr/RegisterActorReminder", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *daprClient) UnregisterActorReminder(ctx context.Context, in *UnregisterActorReminderRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, "/dapr.proto.runtime.v1.Dapr/UnregisterActorReminder", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *daprClient) GetActorState(ctx context.Context, in *GetActorStateRequest, opts ...grpc.CallOption) (*GetActorStateResponse, error) {
out := new(GetActorStateResponse)
err := c.cc.Invoke(ctx, "/dapr.proto.runtime.v1.Dapr/GetActorState", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *daprClient) ExecuteActorStateTransaction(ctx context.Context, in *ExecuteActorStateTransactionRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, "/dapr.proto.runtime.v1.Dapr/ExecuteActorStateTransaction", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *daprClient) InvokeActor(ctx context.Context, in *InvokeActorRequest, opts ...grpc.CallOption) (*InvokeActorResponse, error) {
out := new(InvokeActorResponse)
err := c.cc.Invoke(ctx, "/dapr.proto.runtime.v1.Dapr/InvokeActor", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *daprClient) GetMetadata(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*GetMetadataResponse, error) {
out := new(GetMetadataResponse)
err := c.cc.Invoke(ctx, "/dapr.proto.runtime.v1.Dapr/GetMetadata", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *daprClient) SetMetadata(ctx context.Context, in *SetMetadataRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, "/dapr.proto.runtime.v1.Dapr/SetMetadata", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *daprClient) Shutdown(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, "/dapr.proto.runtime.v1.Dapr/Shutdown", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// DaprServer is the server API for Dapr service.
// All implementations must embed UnimplementedDaprServer
// for forward compatibility
type DaprServer interface {
// Invokes a method on a remote Dapr app.
InvokeService(context.Context, *InvokeServiceRequest) (*v1.InvokeResponse, error)
// Gets the state for a specific key.
GetState(context.Context, *GetStateRequest) (*GetStateResponse, error)
// Gets a bulk of state items for a list of keys
GetBulkState(context.Context, *GetBulkStateRequest) (*GetBulkStateResponse, error)
// Saves the state for a specific key.
SaveState(context.Context, *SaveStateRequest) (*emptypb.Empty, error)
// Deletes the state for a specific key.
DeleteState(context.Context, *DeleteStateRequest) (*emptypb.Empty, error)
// Deletes a bulk of state items for a list of keys
DeleteBulkState(context.Context, *DeleteBulkStateRequest) (*emptypb.Empty, error)
// Executes transactions for a specified store
ExecuteStateTransaction(context.Context, *ExecuteStateTransactionRequest) (*emptypb.Empty, error)
// Publishes events to the specific topic.
PublishEvent(context.Context, *PublishEventRequest) (*emptypb.Empty, error)
// Invokes binding data to specific output bindings
InvokeBinding(context.Context, *InvokeBindingRequest) (*InvokeBindingResponse, error)
// Gets secrets from secret stores.
GetSecret(context.Context, *GetSecretRequest) (*GetSecretResponse, error)
// Gets a bulk of secrets
GetBulkSecret(context.Context, *GetBulkSecretRequest) (*GetBulkSecretResponse, error)
// Register an actor timer.
RegisterActorTimer(context.Context, *RegisterActorTimerRequest) (*emptypb.Empty, error)
// Unregister an actor timer.
UnregisterActorTimer(context.Context, *UnregisterActorTimerRequest) (*emptypb.Empty, error)
// Register an actor reminder.
RegisterActorReminder(context.Context, *RegisterActorReminderRequest) (*emptypb.Empty, error)
// Unregister an actor reminder.
UnregisterActorReminder(context.Context, *UnregisterActorReminderRequest) (*emptypb.Empty, error)
// Gets the state for a specific actor.
GetActorState(context.Context, *GetActorStateRequest) (*GetActorStateResponse, error)
// Executes state transactions for a specified actor
ExecuteActorStateTransaction(context.Context, *ExecuteActorStateTransactionRequest) (*emptypb.Empty, error)
// InvokeActor calls a method on an actor.
InvokeActor(context.Context, *InvokeActorRequest) (*InvokeActorResponse, error)
// Gets metadata of the sidecar
GetMetadata(context.Context, *emptypb.Empty) (*GetMetadataResponse, error)
// Sets value in extended metadata of the sidecar
SetMetadata(context.Context, *SetMetadataRequest) (*emptypb.Empty, error)
// Shutdown the sidecar
Shutdown(context.Context, *emptypb.Empty) (*emptypb.Empty, error)
mustEmbedUnimplementedDaprServer()
}
// UnimplementedDaprServer must be embedded to have forward compatible implementations.
type UnimplementedDaprServer struct{}
func (UnimplementedDaprServer) InvokeService(context.Context, *InvokeServiceRequest) (*v1.InvokeResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method InvokeService not implemented")
}
func (UnimplementedDaprServer) GetState(context.Context, *GetStateRequest) (*GetStateResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetState not implemented")
}
func (UnimplementedDaprServer) GetBulkState(context.Context, *GetBulkStateRequest) (*GetBulkStateResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetBulkState not implemented")
}
func (UnimplementedDaprServer) SaveState(context.Context, *SaveStateRequest) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method SaveState not implemented")
}
func (UnimplementedDaprServer) DeleteState(context.Context, *DeleteStateRequest) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method DeleteState not implemented")
}
func (UnimplementedDaprServer) DeleteBulkState(context.Context, *DeleteBulkStateRequest) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method DeleteBulkState not implemented")
}
func (UnimplementedDaprServer) ExecuteStateTransaction(context.Context, *ExecuteStateTransactionRequest) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method ExecuteStateTransaction not implemented")
}
func (UnimplementedDaprServer) PublishEvent(context.Context, *PublishEventRequest) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method PublishEvent not implemented")
}
func (UnimplementedDaprServer) InvokeBinding(context.Context, *InvokeBindingRequest) (*InvokeBindingResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method InvokeBinding not implemented")
}
func (UnimplementedDaprServer) GetSecret(context.Context, *GetSecretRequest) (*GetSecretResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetSecret not implemented")
}
func (UnimplementedDaprServer) GetBulkSecret(context.Context, *GetBulkSecretRequest) (*GetBulkSecretResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetBulkSecret not implemented")
}
func (UnimplementedDaprServer) RegisterActorTimer(context.Context, *RegisterActorTimerRequest) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method RegisterActorTimer not implemented")
}
func (UnimplementedDaprServer) UnregisterActorTimer(context.Context, *UnregisterActorTimerRequest) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method UnregisterActorTimer not implemented")
}
func (UnimplementedDaprServer) RegisterActorReminder(context.Context, *RegisterActorReminderRequest) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method RegisterActorReminder not implemented")
}
func (UnimplementedDaprServer) UnregisterActorReminder(context.Context, *UnregisterActorReminderRequest) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method UnregisterActorReminder not implemented")
}
func (UnimplementedDaprServer) GetActorState(context.Context, *GetActorStateRequest) (*GetActorStateResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetActorState not implemented")
}
func (UnimplementedDaprServer) ExecuteActorStateTransaction(context.Context, *ExecuteActorStateTransactionRequest) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method ExecuteActorStateTransaction not implemented")
}
func (UnimplementedDaprServer) InvokeActor(context.Context, *InvokeActorRequest) (*InvokeActorResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method InvokeActor not implemented")
}
func (UnimplementedDaprServer) GetMetadata(context.Context, *emptypb.Empty) (*GetMetadataResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetMetadata not implemented")
}
func (UnimplementedDaprServer) SetMetadata(context.Context, *SetMetadataRequest) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method SetMetadata not implemented")
}
func (UnimplementedDaprServer) Shutdown(context.Context, *emptypb.Empty) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method Shutdown not implemented")
}
func (UnimplementedDaprServer) mustEmbedUnimplementedDaprServer() {}
// UnsafeDaprServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to DaprServer will
// result in compilation errors.
type UnsafeDaprServer interface {
mustEmbedUnimplementedDaprServer()
}
func RegisterDaprServer(s grpc.ServiceRegistrar, srv DaprServer) {
s.RegisterService(&Dapr_ServiceDesc, srv)
}
func _Dapr_InvokeService_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(InvokeServiceRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DaprServer).InvokeService(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/dapr.proto.runtime.v1.Dapr/InvokeService",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DaprServer).InvokeService(ctx, req.(*InvokeServiceRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Dapr_GetState_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetStateRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DaprServer).GetState(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/dapr.proto.runtime.v1.Dapr/GetState",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DaprServer).GetState(ctx, req.(*GetStateRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Dapr_GetBulkState_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetBulkStateRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DaprServer).GetBulkState(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/dapr.proto.runtime.v1.Dapr/GetBulkState",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DaprServer).GetBulkState(ctx, req.(*GetBulkStateRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Dapr_SaveState_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(SaveStateRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DaprServer).SaveState(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/dapr.proto.runtime.v1.Dapr/SaveState",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DaprServer).SaveState(ctx, req.(*SaveStateRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Dapr_DeleteState_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DeleteStateRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DaprServer).DeleteState(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/dapr.proto.runtime.v1.Dapr/DeleteState",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DaprServer).DeleteState(ctx, req.(*DeleteStateRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Dapr_DeleteBulkState_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DeleteBulkStateRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DaprServer).DeleteBulkState(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/dapr.proto.runtime.v1.Dapr/DeleteBulkState",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DaprServer).DeleteBulkState(ctx, req.(*DeleteBulkStateRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Dapr_ExecuteStateTransaction_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ExecuteStateTransactionRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DaprServer).ExecuteStateTransaction(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/dapr.proto.runtime.v1.Dapr/ExecuteStateTransaction",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DaprServer).ExecuteStateTransaction(ctx, req.(*ExecuteStateTransactionRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Dapr_PublishEvent_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(PublishEventRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DaprServer).PublishEvent(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/dapr.proto.runtime.v1.Dapr/PublishEvent",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DaprServer).PublishEvent(ctx, req.(*PublishEventRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Dapr_InvokeBinding_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(InvokeBindingRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DaprServer).InvokeBinding(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/dapr.proto.runtime.v1.Dapr/InvokeBinding",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DaprServer).InvokeBinding(ctx, req.(*InvokeBindingRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Dapr_GetSecret_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetSecretRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DaprServer).GetSecret(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/dapr.proto.runtime.v1.Dapr/GetSecret",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DaprServer).GetSecret(ctx, req.(*GetSecretRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Dapr_GetBulkSecret_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetBulkSecretRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DaprServer).GetBulkSecret(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/dapr.proto.runtime.v1.Dapr/GetBulkSecret",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DaprServer).GetBulkSecret(ctx, req.(*GetBulkSecretRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Dapr_RegisterActorTimer_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RegisterActorTimerRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DaprServer).RegisterActorTimer(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/dapr.proto.runtime.v1.Dapr/RegisterActorTimer",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DaprServer).RegisterActorTimer(ctx, req.(*RegisterActorTimerRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Dapr_UnregisterActorTimer_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(UnregisterActorTimerRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DaprServer).UnregisterActorTimer(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/dapr.proto.runtime.v1.Dapr/UnregisterActorTimer",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DaprServer).UnregisterActorTimer(ctx, req.(*UnregisterActorTimerRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Dapr_RegisterActorReminder_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RegisterActorReminderRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DaprServer).RegisterActorReminder(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/dapr.proto.runtime.v1.Dapr/RegisterActorReminder",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DaprServer).RegisterActorReminder(ctx, req.(*RegisterActorReminderRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Dapr_UnregisterActorReminder_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(UnregisterActorReminderRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DaprServer).UnregisterActorReminder(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/dapr.proto.runtime.v1.Dapr/UnregisterActorReminder",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DaprServer).UnregisterActorReminder(ctx, req.(*UnregisterActorReminderRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Dapr_GetActorState_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetActorStateRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DaprServer).GetActorState(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/dapr.proto.runtime.v1.Dapr/GetActorState",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DaprServer).GetActorState(ctx, req.(*GetActorStateRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Dapr_ExecuteActorStateTransaction_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ExecuteActorStateTransactionRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DaprServer).ExecuteActorStateTransaction(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/dapr.proto.runtime.v1.Dapr/ExecuteActorStateTransaction",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DaprServer).ExecuteActorStateTransaction(ctx, req.(*ExecuteActorStateTransactionRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Dapr_InvokeActor_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(InvokeActorRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DaprServer).InvokeActor(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/dapr.proto.runtime.v1.Dapr/InvokeActor",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DaprServer).InvokeActor(ctx, req.(*InvokeActorRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Dapr_GetMetadata_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(emptypb.Empty)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DaprServer).GetMetadata(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/dapr.proto.runtime.v1.Dapr/GetMetadata",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DaprServer).GetMetadata(ctx, req.(*emptypb.Empty))
}
return interceptor(ctx, in, info, handler)
}
func _Dapr_SetMetadata_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(SetMetadataRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DaprServer).SetMetadata(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/dapr.proto.runtime.v1.Dapr/SetMetadata",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DaprServer).SetMetadata(ctx, req.(*SetMetadataRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Dapr_Shutdown_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(emptypb.Empty)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DaprServer).Shutdown(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/dapr.proto.runtime.v1.Dapr/Shutdown",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DaprServer).Shutdown(ctx, req.(*emptypb.Empty))
}
return interceptor(ctx, in, info, handler)
}
// Dapr_ServiceDesc is the grpc.ServiceDesc for Dapr service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Dapr_ServiceDesc = grpc.ServiceDesc{
ServiceName: "dapr.proto.runtime.v1.Dapr",
HandlerType: (*DaprServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "InvokeService",
Handler: _Dapr_InvokeService_Handler,
},
{
MethodName: "GetState",
Handler: _Dapr_GetState_Handler,
},
{
MethodName: "GetBulkState",
Handler: _Dapr_GetBulkState_Handler,
},
{
MethodName: "SaveState",
Handler: _Dapr_SaveState_Handler,
},
{
MethodName: "DeleteState",
Handler: _Dapr_DeleteState_Handler,
},
{
MethodName: "DeleteBulkState",
Handler: _Dapr_DeleteBulkState_Handler,
},
{
MethodName: "ExecuteStateTransaction",
Handler: _Dapr_ExecuteStateTransaction_Handler,
},
{
MethodName: "PublishEvent",
Handler: _Dapr_PublishEvent_Handler,
},
{
MethodName: "InvokeBinding",
Handler: _Dapr_InvokeBinding_Handler,
},
{
MethodName: "GetSecret",
Handler: _Dapr_GetSecret_Handler,
},
{
MethodName: "GetBulkSecret",
Handler: _Dapr_GetBulkSecret_Handler,
},
{
MethodName: "RegisterActorTimer",
Handler: _Dapr_RegisterActorTimer_Handler,
},
{
MethodName: "UnregisterActorTimer",
Handler: _Dapr_UnregisterActorTimer_Handler,
},
{
MethodName: "RegisterActorReminder",
Handler: _Dapr_RegisterActorReminder_Handler,
},
{
MethodName: "UnregisterActorReminder",
Handler: _Dapr_UnregisterActorReminder_Handler,
},
{
MethodName: "GetActorState",
Handler: _Dapr_GetActorState_Handler,
},
{
MethodName: "ExecuteActorStateTransaction",
Handler: _Dapr_ExecuteActorStateTransaction_Handler,
},
{
MethodName: "InvokeActor",
Handler: _Dapr_InvokeActor_Handler,
},
{
MethodName: "GetMetadata",
Handler: _Dapr_GetMetadata_Handler,
},
{
MethodName: "SetMetadata",
Handler: _Dapr_SetMetadata_Handler,
},
{
MethodName: "Shutdown",
Handler: _Dapr_Shutdown_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "dapr/proto/runtime/v1/dapr.proto",
}

111
examples/actor/README.md Normal file
View File

@ -0,0 +1,111 @@
# Dapr Actor Example with go-sdk
## Step
### Prepare
- Dapr installed
### Run Actor Server
<!-- STEP
name: Run Actor server
output_match_mode: substring
expected_stdout_lines:
- '== APP == call get user req = &{abc 123}'
- '== APP == get req = laurence'
- '== APP == get post request = laurence'
- '== APP == get req = hello'
- '== APP == get req = hello'
- '== APP == receive reminder = testReminderName state = "hello" duetime = 5s period = 5s'
- '== APP == receive reminder = testReminderName state = "hello" duetime = 5s period = 5s'
background: true
sleep: 30
-->
```bash
dapr run --app-id actor-serving \
--app-protocol http \
--app-port 8080 \
--dapr-http-port 3500 \
--log-level debug \
--components-path ./config \
go run ./serving/main.go
```
<!-- END_STEP -->
### Run Actor Client
<!-- STEP
name: Run Actor Client
output_match_mode: substring
expected_stdout_lines:
- '== APP == get user result = &{abc 123}'
- '== APP == get invoke result = laurence'
- '== APP == get post result = laurence'
- '== APP == get result = get result'
- '== APP == start timer'
- '== APP == stop timer'
- '== APP == start reminder'
- '== APP == stop reminder'
- '== APP == get user = {Name: Age:1}'
- '== APP == get user = {Name: Age:2}'
background: true
sleep: 40
-->
```bash
dapr run --app-id actor-client \
--log-level debug \
--components-path ./config \
go run ./client/main.go
```
<!-- END_STEP -->
### Cleanup
<!-- STEP
expected_stdout_lines:
- '✅ app stopped successfully: actor-serving'
expected_stderr_lines:
name: Shutdown dapr
-->
```bash
dapr stop --app-id actor-serving
(lsof -i:8080 | grep main) | awk '{print $2}' | xargs kill
```
<!-- END_STEP -->
## Result
- client side
```
== APP == dapr client initializing for: 127.0.0.1:55776
== APP == get user result = &{abc 123}
== APP == get invoke result = laurence
== APP == get post result = laurence
== APP == get result = get result
== APP == start timer
== APP == stop timer
== APP == start reminder
== APP == stop reminder
== APP == get user = {Name: Age:1}
== APP == get user = {Name: Age:2}
✅ Exited App successfully
```
- server side
```
== APP == call get user req = &{abc 123}
== APP == get req = laurence
== APP == get post request = laurence
== APP == get req = hello
== APP == get req = hello
== APP == receive reminder = testReminderName state = "hello" duetime = 5s period = 5s
== APP == receive reminder = testReminderName state = "hello" duetime = 5s period = 5s
```

View File

@ -0,0 +1,43 @@
package api
import "context"
type ClientStub struct {
GetUser func(context.Context, *User) (*User, error)
Invoke func(context.Context, string) (string, error)
Get func(context.Context) (string, error)
Post func(context.Context, string) error
StartTimer func(context.Context, *TimerRequest) error
StopTimer func(context.Context, *TimerRequest) error
StartReminder func(context.Context, *ReminderRequest) error
StopReminder func(context.Context, *ReminderRequest) error
IncrementAndGet func(ctx context.Context, stateKey string) (*User, error)
}
func (a *ClientStub) Type() string {
return "testActorType"
}
func (a *ClientStub) ID() string {
return "ActorImplID123456"
}
type User struct {
Name string `json:"name"`
Age uint32 `json:"age"`
}
type TimerRequest struct {
TimerName string `json:"timer_name"`
CallBack string `json:"call_back"`
Duration string `json:"duration"`
Period string `json:"period"`
Data string `json:"data"`
}
type ReminderRequest struct {
ReminderName string `json:"reminder_name"`
Duration string `json:"duration"`
Period string `json:"period"`
Data string `json:"data"`
}

View File

@ -0,0 +1,113 @@
package main
import (
"context"
"fmt"
"time"
dapr "github.com/dapr/go-sdk/client"
"github.com/dapr/go-sdk/examples/actor/api"
)
func main() {
ctx := context.Background()
// create the client
client, err := dapr.NewClient()
if err != nil {
panic(err)
}
defer client.Close()
// implement actor client stub
myActor := new(api.ClientStub)
client.ImplActorClientStub(myActor)
// Invoke user defined method GetUser with user defined param api.User and response
// using default serializer type json
user, err := myActor.GetUser(ctx, &api.User{
Name: "abc",
Age: 123,
})
if err != nil {
panic(err)
}
fmt.Println("get user result = ", user)
// Invoke user defined method Invoke
rsp, err := myActor.Invoke(ctx, "laurence")
if err != nil {
panic(err)
}
fmt.Println("get invoke result = ", rsp)
// Invoke user defined method Post with empty response
err = myActor.Post(ctx, "laurence")
if err != nil {
panic(err)
}
fmt.Println("get post result = ", rsp)
// Invoke user defined method Get with empty request param
rsp, err = myActor.Get(ctx)
if err != nil {
panic(err)
}
fmt.Println("get result = ", rsp)
// Invoke user defined method StarTimer, and server side actor start actor timer with given params.
err = myActor.StartTimer(ctx, &api.TimerRequest{
TimerName: "testTimerName",
CallBack: "Invoke",
Period: "5s",
Duration: "5s",
Data: `"hello"`,
})
if err != nil {
panic(err)
}
fmt.Println("start timer")
<-time.After(time.Second * 10) // timer call for twice
// Invoke user defined method StopTimer, and server side actor stop actor timer with given params.
err = myActor.StopTimer(ctx, &api.TimerRequest{
TimerName: "testTimerName",
CallBack: "Invoke",
})
if err != nil {
panic(err)
}
fmt.Println("stop timer")
// Invoke user defined method StartReminder, and server side actor start actor reminder with given params.
err = myActor.StartReminder(ctx, &api.ReminderRequest{
ReminderName: "testReminderName",
Period: "5s",
Duration: "5s",
Data: `"hello"`,
})
if err != nil {
panic(err)
}
fmt.Println("start reminder")
<-time.After(time.Second * 10) // timer call for twice
// Invoke user defined method StopReminder, and server side actor stop actor reminder with given params.
err = myActor.StopReminder(ctx, &api.ReminderRequest{
ReminderName: "testReminderName",
})
if err != nil {
panic(err)
}
fmt.Println("stop reminder")
for i := 0; i < 2; i++ {
// Invoke user defined method IncrementAndGet, and server side actor increase the state named testStateKey and return.
usr, err := myActor.IncrementAndGet(ctx, "testStateKey")
if err != nil {
panic(err)
}
fmt.Printf("get user = %+v\n", *usr)
time.Sleep(time.Second)
}
}

View File

@ -0,0 +1,14 @@
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: statestore
spec:
type: state.redis
version: v1
metadata:
- name: redisHost
value: localhost:6379
- name: redisPassword
value: ""
- name: actorStateStore
value: "true"

View File

@ -0,0 +1,123 @@
package main
import (
"context"
"fmt"
"log"
"net/http"
"github.com/dapr/go-sdk/actor"
dapr "github.com/dapr/go-sdk/client"
"github.com/dapr/go-sdk/examples/actor/api"
daprd "github.com/dapr/go-sdk/service/http"
)
func testActorFactory() actor.Server {
client, err := dapr.NewClient()
if err != nil {
panic(err)
}
return &TestActor{
daprClient: client,
}
}
type TestActor struct {
actor.ServerImplBase
daprClient dapr.Client
}
func (t *TestActor) Type() string {
return "testActorType"
}
// user defined functions
func (t *TestActor) StopTimer(ctx context.Context, req *api.TimerRequest) error {
return t.daprClient.UnregisterActorTimer(ctx, &dapr.UnregisterActorTimerRequest{
ActorType: t.Type(),
ActorID: t.ID(),
Name: req.TimerName,
})
}
func (t *TestActor) StartTimer(ctx context.Context, req *api.TimerRequest) error {
return t.daprClient.RegisterActorTimer(ctx, &dapr.RegisterActorTimerRequest{
ActorType: t.Type(),
ActorID: t.ID(),
Name: req.TimerName,
DueTime: req.Duration,
Period: req.Period,
Data: []byte(req.Data),
CallBack: req.CallBack,
})
}
func (t *TestActor) StartReminder(ctx context.Context, req *api.ReminderRequest) error {
return t.daprClient.RegisterActorReminder(ctx, &dapr.RegisterActorReminderRequest{
ActorType: t.Type(),
ActorID: t.ID(),
Name: req.ReminderName,
DueTime: req.Duration,
Period: req.Period,
Data: []byte(req.Data),
})
}
func (t *TestActor) StopReminder(ctx context.Context, req *api.ReminderRequest) error {
return t.daprClient.UnregisterActorReminder(ctx, &dapr.UnregisterActorReminderRequest{
ActorType: t.Type(),
ActorID: t.ID(),
Name: req.ReminderName,
})
}
func (t *TestActor) Invoke(ctx context.Context, req string) (string, error) {
fmt.Println("get req = ", req)
return req, nil
}
func (t *TestActor) GetUser(ctx context.Context, user *api.User) (*api.User, error) {
fmt.Println("call get user req = ", user)
return user, nil
}
func (t *TestActor) Get(context.Context) (string, error) {
return "get result", nil
}
func (t *TestActor) Post(ctx context.Context, req string) error {
fmt.Println("get post request = ", req)
return nil
}
func (t *TestActor) IncrementAndGet(ctx context.Context, stateKey string) (*api.User, error) {
stateData := api.User{}
if exist, err := t.GetStateManager().Contains(stateKey); err != nil {
fmt.Println("state manager call contains with key " + stateKey + "err = " + err.Error())
return &stateData, err
} else if exist {
if err := t.GetStateManager().Get(stateKey, &stateData); err != nil {
fmt.Println("state manager call get with key " + stateKey + "err = " + err.Error())
return &stateData, err
}
}
stateData.Age++
if err := t.GetStateManager().Set(stateKey, stateData); err != nil {
fmt.Printf("state manager set get with key %s and state data = %+v, error = %s", stateKey, stateData, err.Error())
return &stateData, err
}
return &stateData, nil
}
func (t *TestActor) ReminderCall(reminderName string, state []byte, dueTime string, period string) {
fmt.Println("receive reminder = ", reminderName, " state = ", string(state), "duetime = ", dueTime, "period = ", period)
}
func main() {
s := daprd.NewService(":8080")
s.RegisterActorImplFactory(testActorFactory)
if err := s.Start(); err != nil && err != http.ErrServerClosed {
log.Fatalf("error listenning: %v", err)
}
}

View File

@ -7,8 +7,9 @@ import (
"strconv"
"time"
dapr "github.com/dapr/go-sdk/client"
"gopkg.in/alecthomas/kingpin.v2"
dapr "github.com/dapr/go-sdk/client"
)
const (

View File

@ -20,7 +20,7 @@ output_match_mode: substring
expected_stdout_lines:
- 'event - PubsubName: messages, Topic: neworder'
background: true
sleep: 5
sleep: 15
-->
```bash
@ -67,6 +67,7 @@ name: Shutdown dapr
```bash
dapr stop --app-id sub
(lsof -i:8080 | grep sub) | awk '{print $2}' | xargs kill
```
<!-- END_STEP -->

View File

@ -3,8 +3,9 @@ package main
import (
"context"
"fmt"
dapr "github.com/dapr/go-sdk/client"
"os"
dapr "github.com/dapr/go-sdk/client"
)
var (

View File

@ -16,7 +16,7 @@ output_match_mode: substring
expected_stdout_lines:
- "ContentType:text/plain, Verb:POST, QueryString:, hellow"
background: true
sleep: 5
sleep: 15
-->
```bash
@ -164,6 +164,7 @@ name: Shutdown dapr
```bash
dapr stop --app-id serving
(lsof -i:8080 | grep main) | awk '{print $2}' | xargs kill
```
<!-- END_STEP -->

View File

@ -3,11 +3,12 @@ package main
import (
"context"
"fmt"
"google.golang.org/grpc"
"net"
"os"
"time"
"google.golang.org/grpc"
dapr "github.com/dapr/go-sdk/client"
)
@ -29,7 +30,6 @@ func main() {
conn, err := grpc.Dial(net.JoinHostPort("127.0.0.1",
GetEnvValue("DAPR_GRPC_PORT", "50001")),
grpc.WithDefaultCallOptions(opts...), grpc.WithInsecure())
if err != nil {
panic(err)
}

12
go.mod
View File

@ -1,6 +1,6 @@
module github.com/dapr/go-sdk
go 1.17
go 1.16
require (
github.com/dapr/dapr v1.4.3
@ -12,11 +12,7 @@ require (
)
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 // indirect
golang.org/x/text v0.3.6 // indirect
google.golang.org/genproto v0.0.0-20210524171403-669157292da3 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
github.com/golang/mock v1.6.0
github.com/gorilla/mux v1.8.0
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
)

1422
go.sum

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,11 @@
package common
import "context"
import (
"context"
"github.com/dapr/go-sdk/actor"
"github.com/dapr/go-sdk/actor/config"
)
// Service represents Dapr callback service.
type Service interface {
@ -11,6 +16,8 @@ type Service interface {
AddTopicEventHandler(sub *Subscription, fn func(ctx context.Context, e *TopicEvent) (retry bool, err error)) error
// AddBindingInvocationHandler appends provided binding invocation handler with its name to the service.
AddBindingInvocationHandler(name string, fn func(ctx context.Context, in *BindingEvent) (out []byte, err error)) error
// RegisterActorImplFactory Register a new actor to actor runtime of go sdk
RegisterActorImplFactory(f actor.Factory, opts ...config.Option)
// Start starts service.
Start() error
// Stop stops the previously started service.

View File

@ -4,12 +4,14 @@ import (
"context"
"net"
pb "github.com/dapr/dapr/pkg/proto/runtime/v1"
"github.com/dapr/go-sdk/actor"
"github.com/dapr/go-sdk/actor/config"
"github.com/dapr/go-sdk/service/common"
"github.com/pkg/errors"
"google.golang.org/grpc"
pb "github.com/dapr/dapr/pkg/proto/runtime/v1"
"github.com/dapr/go-sdk/service/common"
)
// NewService creates new Service.
@ -49,6 +51,10 @@ type Server struct {
bindingHandlers map[string]func(ctx context.Context, in *common.BindingEvent) (out []byte, err error)
}
func (s *Server) RegisterActorImplFactory(f actor.Factory, opts ...config.Option) {
panic("Actor is not supported by gRPC API")
}
type topicEventHandler struct {
component string
topic string

View File

@ -5,6 +5,12 @@ import (
"net/http"
"time"
"github.com/gorilla/mux"
"github.com/dapr/go-sdk/actor"
"github.com/dapr/go-sdk/actor/config"
"github.com/dapr/go-sdk/actor/runtime"
"github.com/dapr/go-sdk/service/common"
)
@ -14,21 +20,21 @@ func NewService(address string) common.Service {
}
// NewServiceWithMux creates new Service with existing http mux.
func NewServiceWithMux(address string, mux *http.ServeMux) common.Service {
func NewServiceWithMux(address string, mux *mux.Router) common.Service {
return newServer(address, mux)
}
func newServer(address string, mux *http.ServeMux) *Server {
if mux == nil {
mux = http.NewServeMux()
func newServer(address string, router *mux.Router) *Server {
if router == nil {
router = mux.NewRouter()
}
return &Server{
address: address,
httpServer: &http.Server{
Addr: address,
Handler: mux,
Handler: router,
},
mux: mux,
mux: router,
topicSubscriptions: make([]*common.Subscription, 0),
}
}
@ -36,14 +42,18 @@ func newServer(address string, mux *http.ServeMux) *Server {
// Server is the HTTP server wrapping mux many Dapr helpers.
type Server struct {
address string
mux *http.ServeMux
mux *mux.Router
httpServer *http.Server
topicSubscriptions []*common.Subscription
}
func (s *Server) RegisterActorImplFactory(f actor.Factory, opts ...config.Option) {
runtime.GetActorRuntimeInstance().RegisterActorFactory(f, opts...)
}
// Start starts the HTTP handler. Blocks while serving.
func (s *Server) Start() error {
s.registerSubscribeHandler()
s.registerBaseHandler()
return s.httpServer.ListenAndServe()
}

View File

@ -1,6 +1,7 @@
package http
import (
"io"
"net/http"
"net/http/httptest"
"testing"
@ -63,3 +64,15 @@ func testRequest(t *testing.T, s *Server, r *http.Request, expectedStatusCode in
assert.NotNil(t, resp)
assert.Equal(t, expectedStatusCode, resp.StatusCode)
}
func testRequestWithResponseBody(t *testing.T, s *Server, r *http.Request, expectedStatusCode int, expectedBody []byte) {
rr := httptest.NewRecorder()
s.mux.ServeHTTP(rr, r)
rez := rr.Result()
defer rez.Body.Close()
rspBody, err := io.ReadAll(rez.Body)
assert.Nil(t, err)
assert.NotNil(t, rez)
assert.Equal(t, expectedStatusCode, rez.StatusCode)
assert.Equal(t, expectedBody, rspBody)
}

View File

@ -4,9 +4,15 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"strings"
"github.com/gorilla/mux"
actorErr "github.com/dapr/go-sdk/actor/error"
"github.com/dapr/go-sdk/actor/runtime"
"github.com/pkg/errors"
"github.com/dapr/go-sdk/service/common"
@ -23,7 +29,8 @@ const (
PubSubHandlerDropStatusCode int = http.StatusSeeOther
)
func (s *Server) registerSubscribeHandler() {
func (s *Server) registerBaseHandler() {
// register subscribe handler
f := func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(s.topicSubscriptions); err != nil {
@ -32,6 +39,100 @@ func (s *Server) registerSubscribeHandler() {
}
}
s.mux.HandleFunc("/dapr/subscribe", f)
// register health check handler
fHealth := func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
}
s.mux.HandleFunc("/healthz", fHealth).Methods(http.MethodGet)
// register actor config handler
fRegister := func(w http.ResponseWriter, r *http.Request) {
data, err := runtime.GetActorRuntimeInstance().GetJSONSerializedConfig()
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
return
}
if _, err = w.Write(data); err != nil {
w.WriteHeader(http.StatusInternalServerError)
return
}
w.WriteHeader(http.StatusOK)
}
s.mux.HandleFunc("/dapr/config", fRegister).Methods(http.MethodGet)
// register actor method invoke handler
fInvoke := func(w http.ResponseWriter, r *http.Request) {
varsMap := mux.Vars(r)
actorType := varsMap["actorType"]
actorID := varsMap["actorId"]
methodName := varsMap["methodName"]
reqData, _ := ioutil.ReadAll(r.Body)
rspData, err := runtime.GetActorRuntimeInstance().InvokeActorMethod(actorType, actorID, methodName, reqData)
if err == actorErr.ErrActorTypeNotFound {
w.WriteHeader(http.StatusNotFound)
return
}
if err != actorErr.Success {
w.WriteHeader(http.StatusInternalServerError)
return
}
w.WriteHeader(http.StatusOK)
_, _ = w.Write(rspData)
}
s.mux.HandleFunc("/actors/{actorType}/{actorId}/method/{methodName}", fInvoke).Methods(http.MethodPut)
// register deactivate actor handler
fDelete := func(w http.ResponseWriter, r *http.Request) {
varsMap := mux.Vars(r)
actorType := varsMap["actorType"]
actorID := varsMap["actorId"]
err := runtime.GetActorRuntimeInstance().Deactivate(actorType, actorID)
if err == actorErr.ErrActorTypeNotFound || err == actorErr.ErrActorIDNotFound {
w.WriteHeader(http.StatusNotFound)
}
if err != actorErr.Success {
w.WriteHeader(http.StatusInternalServerError)
}
w.WriteHeader(http.StatusOK)
}
s.mux.HandleFunc("/actors/{actorType}/{actorId}", fDelete).Methods(http.MethodDelete)
// register actor reminder invoke handler
fReminder := func(w http.ResponseWriter, r *http.Request) {
varsMap := mux.Vars(r)
actorType := varsMap["actorType"]
actorID := varsMap["actorId"]
reminderName := varsMap["reminderName"]
reqData, _ := ioutil.ReadAll(r.Body)
err := runtime.GetActorRuntimeInstance().InvokeReminder(actorType, actorID, reminderName, reqData)
if err == actorErr.ErrActorTypeNotFound {
w.WriteHeader(http.StatusNotFound)
}
if err != actorErr.Success {
w.WriteHeader(http.StatusInternalServerError)
}
w.WriteHeader(http.StatusOK)
}
s.mux.HandleFunc("/actors/{actorType}/{actorId}/method/remind/{reminderName}", fReminder).Methods(http.MethodPut)
// register actor timer invoke handler
fTimer := func(w http.ResponseWriter, r *http.Request) {
varsMap := mux.Vars(r)
actorType := varsMap["actorType"]
actorID := varsMap["actorId"]
timerName := varsMap["timerName"]
reqData, _ := ioutil.ReadAll(r.Body)
err := runtime.GetActorRuntimeInstance().InvokeTimer(actorType, actorID, timerName, reqData)
if err == actorErr.ErrActorTypeNotFound {
w.WriteHeader(http.StatusNotFound)
}
if err != actorErr.Success {
w.WriteHeader(http.StatusInternalServerError)
}
w.WriteHeader(http.StatusOK)
}
s.mux.HandleFunc("/actors/{actorType}/{actorId}/method/timer/{timerName}", fTimer).Methods(http.MethodPut)
}
// AddTopicEventHandler appends provided event handler with it's name to the service.
@ -69,7 +170,6 @@ func (s *Server) AddTopicEventHandler(sub *common.Subscription, fn func(ctx cont
// deserialize the event
var in common.TopicEvent
if err := json.NewDecoder(r.Body).Decode(&in); err != nil {
fmt.Println(err.Error())
http.Error(w, err.Error(), PubSubHandlerDropStatusCode)
return
}

View File

@ -2,12 +2,16 @@ package http
import (
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
"strings"
"testing"
"github.com/dapr/go-sdk/actor/api"
"github.com/dapr/go-sdk/actor/mock"
"github.com/stretchr/testify/assert"
"github.com/dapr/go-sdk/service/common"
@ -73,7 +77,7 @@ func TestEventHandler(t *testing.T) {
err = s.AddTopicEventHandler(sub2, testErrorTopicFunc)
assert.NoErrorf(t, err, "error adding error event handler")
s.registerSubscribeHandler()
s.registerBaseHandler()
makeEventRequest(t, s, "/", data, http.StatusOK)
makeEventRequest(t, s, "/", "", http.StatusSeeOther)
@ -81,6 +85,81 @@ func TestEventHandler(t *testing.T) {
makeEventRequest(t, s, "/errors", data, http.StatusOK)
}
func TestHealthCheck(t *testing.T) {
s := newServer("", nil)
s.registerBaseHandler()
makeRequest(t, s, "/healthz", "", http.MethodGet, http.StatusOK)
}
func TestActorConfig(t *testing.T) {
s := newServer("", nil)
s.registerBaseHandler()
makeRequest(t, s, "/dapr/config", "", http.MethodGet, http.StatusOK)
}
func TestActorHandler(t *testing.T) {
reminderReqData, _ := json.Marshal(api.ActorReminderParams{
Data: []byte("hello"),
DueTime: "5s",
Period: "5s",
})
timerReqData, _ := json.Marshal(api.ActorTimerParam{
CallBack: "Invoke",
DueTime: "5s",
Period: "5s",
Data: []byte(`"hello"`),
})
timerReqDataWithBadCallBackFunction, _ := json.Marshal(api.ActorTimerParam{
CallBack: "UnexistedFunc",
DueTime: "5s",
Period: "5s",
Data: []byte(`"hello"`),
})
s := newServer("", nil)
s.registerBaseHandler()
// invoke actor API without target actor defined
makeRequest(t, s, "/actors/testActorType/testActorID/method/Invoke", "", http.MethodPut, http.StatusNotFound)
makeRequest(t, s, "/actors/testActorType/testActorID", "", http.MethodDelete, http.StatusNotFound)
makeRequest(t, s, "/actors/testActorType/testActorID/method/remind/testReminderName", string(reminderReqData), http.MethodPut, http.StatusNotFound)
makeRequest(t, s, "/actors/testActorType/testActorID/method/timer/testTimerName", string(timerReqData), http.MethodPut, http.StatusNotFound)
// register test actor factory
s.RegisterActorImplFactory(mock.ActorImplFactory)
// invoke actor API with internal error
makeRequest(t, s, "/actors/testActorType/testActorID/method/remind/testReminderName", `{
"dueTime": "5s",
"period": "5s",
"data": "test data"`, http.MethodPut, http.StatusInternalServerError)
makeRequest(t, s, "/actors/testActorType/testActorID/method/Invoke", "bad request param", http.MethodPut, http.StatusInternalServerError)
makeRequest(t, s, "/actors/testActorType/testActorID/method/timer/testTimerName", string(timerReqDataWithBadCallBackFunction), http.MethodPut, http.StatusInternalServerError)
// invoke actor API with success status
makeRequestWithExpectedBody(t, s, "/actors/testActorType/testActorID/method/Invoke", `"invoke request"`, http.MethodPut, http.StatusOK, []byte(`"invoke request"`))
makeRequest(t, s, "/actors/testActorType/testActorID/method/remind/testReminderName", string(reminderReqData), http.MethodPut, http.StatusOK)
makeRequest(t, s, "/actors/testActorType/testActorID/method/timer/testTimerName", string(timerReqData), http.MethodPut, http.StatusOK)
makeRequest(t, s, "/actors/testActorType/testActorID", "", http.MethodDelete, http.StatusOK)
// register not reminder callee actor factory
s.RegisterActorImplFactory(mock.NotReminderCalleeActorFactory)
// invoke call reminder to not reminder callee actor type
makeRequest(t, s, "/actors/testActorNotReminderCalleeType/testActorID/method/remind/testReminderName", string(reminderReqData), http.MethodPut, http.StatusInternalServerError)
}
func makeRequest(t *testing.T, s *Server, route, data, method string, expectedStatusCode int) {
req, err := http.NewRequest(method, route, strings.NewReader(data))
assert.NoErrorf(t, err, "error creating request: %s", data)
testRequest(t, s, req, expectedStatusCode)
}
func makeRequestWithExpectedBody(t *testing.T, s *Server, route, data, method string, expectedStatusCode int, expectedBody []byte) {
req, err := http.NewRequest(method, route, strings.NewReader(data))
assert.NoErrorf(t, err, "error creating request: %s", data)
testRequestWithResponseBody(t, s, req, expectedStatusCode, expectedBody)
}
func makeEventRequest(t *testing.T, s *Server, route, data string, expectedStatusCode int) {
req, err := http.NewRequest(http.MethodPost, route, strings.NewReader(data))
assert.NoErrorf(t, err, "error creating request: %s", data)
@ -138,6 +217,6 @@ func TestRawPayloadDecode(t *testing.T) {
err := s.AddTopicEventHandler(sub3, testRawTopicFunc)
assert.NoErrorf(t, err, "error adding raw event handler")
s.registerSubscribeHandler()
s.registerBaseHandler()
makeEventRequest(t, s, "/raw", rawData, http.StatusOK)
}