initial commit

This commit is contained in:
yaron2 2019-10-10 22:06:33 -07:00
parent 8dff3ccb10
commit dfeb77eef2
5 changed files with 2139 additions and 0 deletions

29
Readme.md Normal file
View File

@ -0,0 +1,29 @@
# Dapr SDK for Go
This is the Dapr SDK for Go, based on the auto-generated proto client.
## Installation
```
go get github.com/dapr/go-sdk
```
## Usage
The `example` folder contains a Dapr enabled app that receives events (client), and a caller that invokes the Dapr API (caller).
1. Run the client
```
cd example/client
dapr run --app-id client --protocol grpc --app-port 4000 go run main.go
```
2. Run the caller
```
cd example/caller
dapr run --app-id caller go run main.go
```
*Note: If you don't setup a Dapr binding, expect the error message `rpc error: code = Unknown desc = ERR_INVOKE_OUTPUT_BINDING: couldn't find output binding storage`*

1103
dapr/dapr.pb.go Normal file

File diff suppressed because it is too large Load Diff

819
daprclient/daprclient.pb.go Normal file
View File

@ -0,0 +1,819 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: daprclient.proto
package daprclient
import (
context "context"
fmt "fmt"
math "math"
proto "github.com/golang/protobuf/proto"
any "github.com/golang/protobuf/ptypes/any"
duration "github.com/golang/protobuf/ptypes/duration"
empty "github.com/golang/protobuf/ptypes/empty"
grpc "google.golang.org/grpc"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
type CloudEventEnvelope struct {
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Source string `protobuf:"bytes,2,opt,name=source,proto3" json:"source,omitempty"`
Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"`
SpecVersion string `protobuf:"bytes,4,opt,name=specVersion,proto3" json:"specVersion,omitempty"`
DataContentType string `protobuf:"bytes,5,opt,name=dataContentType,proto3" json:"dataContentType,omitempty"`
Topic string `protobuf:"bytes,6,opt,name=topic,proto3" json:"topic,omitempty"`
Data *any.Any `protobuf:"bytes,7,opt,name=data,proto3" json:"data,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CloudEventEnvelope) Reset() { *m = CloudEventEnvelope{} }
func (m *CloudEventEnvelope) String() string { return proto.CompactTextString(m) }
func (*CloudEventEnvelope) ProtoMessage() {}
func (*CloudEventEnvelope) Descriptor() ([]byte, []int) {
return fileDescriptor_127d5244029ccc8f, []int{0}
}
func (m *CloudEventEnvelope) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CloudEventEnvelope.Unmarshal(m, b)
}
func (m *CloudEventEnvelope) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CloudEventEnvelope.Marshal(b, m, deterministic)
}
func (m *CloudEventEnvelope) XXX_Merge(src proto.Message) {
xxx_messageInfo_CloudEventEnvelope.Merge(m, src)
}
func (m *CloudEventEnvelope) XXX_Size() int {
return xxx_messageInfo_CloudEventEnvelope.Size(m)
}
func (m *CloudEventEnvelope) XXX_DiscardUnknown() {
xxx_messageInfo_CloudEventEnvelope.DiscardUnknown(m)
}
var xxx_messageInfo_CloudEventEnvelope proto.InternalMessageInfo
func (m *CloudEventEnvelope) GetId() string {
if m != nil {
return m.Id
}
return ""
}
func (m *CloudEventEnvelope) GetSource() string {
if m != nil {
return m.Source
}
return ""
}
func (m *CloudEventEnvelope) GetType() string {
if m != nil {
return m.Type
}
return ""
}
func (m *CloudEventEnvelope) GetSpecVersion() string {
if m != nil {
return m.SpecVersion
}
return ""
}
func (m *CloudEventEnvelope) GetDataContentType() string {
if m != nil {
return m.DataContentType
}
return ""
}
func (m *CloudEventEnvelope) GetTopic() string {
if m != nil {
return m.Topic
}
return ""
}
func (m *CloudEventEnvelope) GetData() *any.Any {
if m != nil {
return m.Data
}
return nil
}
type BindingEventEnvelope struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Data *any.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
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"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *BindingEventEnvelope) Reset() { *m = BindingEventEnvelope{} }
func (m *BindingEventEnvelope) String() string { return proto.CompactTextString(m) }
func (*BindingEventEnvelope) ProtoMessage() {}
func (*BindingEventEnvelope) Descriptor() ([]byte, []int) {
return fileDescriptor_127d5244029ccc8f, []int{1}
}
func (m *BindingEventEnvelope) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_BindingEventEnvelope.Unmarshal(m, b)
}
func (m *BindingEventEnvelope) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_BindingEventEnvelope.Marshal(b, m, deterministic)
}
func (m *BindingEventEnvelope) XXX_Merge(src proto.Message) {
xxx_messageInfo_BindingEventEnvelope.Merge(m, src)
}
func (m *BindingEventEnvelope) XXX_Size() int {
return xxx_messageInfo_BindingEventEnvelope.Size(m)
}
func (m *BindingEventEnvelope) XXX_DiscardUnknown() {
xxx_messageInfo_BindingEventEnvelope.DiscardUnknown(m)
}
var xxx_messageInfo_BindingEventEnvelope proto.InternalMessageInfo
func (m *BindingEventEnvelope) GetName() string {
if m != nil {
return m.Name
}
return ""
}
func (m *BindingEventEnvelope) GetData() *any.Any {
if m != nil {
return m.Data
}
return nil
}
func (m *BindingEventEnvelope) GetMetadata() map[string]string {
if m != nil {
return m.Metadata
}
return nil
}
type BindingResponseEnvelope struct {
Data *any.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
To []string `protobuf:"bytes,2,rep,name=to,proto3" json:"to,omitempty"`
State []*State `protobuf:"bytes,3,rep,name=state,proto3" json:"state,omitempty"`
Concurrency string `protobuf:"bytes,4,opt,name=concurrency,proto3" json:"concurrency,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *BindingResponseEnvelope) Reset() { *m = BindingResponseEnvelope{} }
func (m *BindingResponseEnvelope) String() string { return proto.CompactTextString(m) }
func (*BindingResponseEnvelope) ProtoMessage() {}
func (*BindingResponseEnvelope) Descriptor() ([]byte, []int) {
return fileDescriptor_127d5244029ccc8f, []int{2}
}
func (m *BindingResponseEnvelope) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_BindingResponseEnvelope.Unmarshal(m, b)
}
func (m *BindingResponseEnvelope) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_BindingResponseEnvelope.Marshal(b, m, deterministic)
}
func (m *BindingResponseEnvelope) XXX_Merge(src proto.Message) {
xxx_messageInfo_BindingResponseEnvelope.Merge(m, src)
}
func (m *BindingResponseEnvelope) XXX_Size() int {
return xxx_messageInfo_BindingResponseEnvelope.Size(m)
}
func (m *BindingResponseEnvelope) XXX_DiscardUnknown() {
xxx_messageInfo_BindingResponseEnvelope.DiscardUnknown(m)
}
var xxx_messageInfo_BindingResponseEnvelope proto.InternalMessageInfo
func (m *BindingResponseEnvelope) GetData() *any.Any {
if m != nil {
return m.Data
}
return nil
}
func (m *BindingResponseEnvelope) GetTo() []string {
if m != nil {
return m.To
}
return nil
}
func (m *BindingResponseEnvelope) GetState() []*State {
if m != nil {
return m.State
}
return nil
}
func (m *BindingResponseEnvelope) GetConcurrency() string {
if m != nil {
return m.Concurrency
}
return ""
}
type InvokeEnvelope struct {
Method string `protobuf:"bytes,1,opt,name=method,proto3" json:"method,omitempty"`
Data *any.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
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"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *InvokeEnvelope) Reset() { *m = InvokeEnvelope{} }
func (m *InvokeEnvelope) String() string { return proto.CompactTextString(m) }
func (*InvokeEnvelope) ProtoMessage() {}
func (*InvokeEnvelope) Descriptor() ([]byte, []int) {
return fileDescriptor_127d5244029ccc8f, []int{3}
}
func (m *InvokeEnvelope) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_InvokeEnvelope.Unmarshal(m, b)
}
func (m *InvokeEnvelope) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_InvokeEnvelope.Marshal(b, m, deterministic)
}
func (m *InvokeEnvelope) XXX_Merge(src proto.Message) {
xxx_messageInfo_InvokeEnvelope.Merge(m, src)
}
func (m *InvokeEnvelope) XXX_Size() int {
return xxx_messageInfo_InvokeEnvelope.Size(m)
}
func (m *InvokeEnvelope) XXX_DiscardUnknown() {
xxx_messageInfo_InvokeEnvelope.DiscardUnknown(m)
}
var xxx_messageInfo_InvokeEnvelope proto.InternalMessageInfo
func (m *InvokeEnvelope) GetMethod() string {
if m != nil {
return m.Method
}
return ""
}
func (m *InvokeEnvelope) GetData() *any.Any {
if m != nil {
return m.Data
}
return nil
}
func (m *InvokeEnvelope) GetMetadata() map[string]string {
if m != nil {
return m.Metadata
}
return nil
}
type GetTopicSubscriptionsEnvelope struct {
Topics []string `protobuf:"bytes,1,rep,name=topics,proto3" json:"topics,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GetTopicSubscriptionsEnvelope) Reset() { *m = GetTopicSubscriptionsEnvelope{} }
func (m *GetTopicSubscriptionsEnvelope) String() string { return proto.CompactTextString(m) }
func (*GetTopicSubscriptionsEnvelope) ProtoMessage() {}
func (*GetTopicSubscriptionsEnvelope) Descriptor() ([]byte, []int) {
return fileDescriptor_127d5244029ccc8f, []int{4}
}
func (m *GetTopicSubscriptionsEnvelope) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetTopicSubscriptionsEnvelope.Unmarshal(m, b)
}
func (m *GetTopicSubscriptionsEnvelope) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetTopicSubscriptionsEnvelope.Marshal(b, m, deterministic)
}
func (m *GetTopicSubscriptionsEnvelope) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetTopicSubscriptionsEnvelope.Merge(m, src)
}
func (m *GetTopicSubscriptionsEnvelope) XXX_Size() int {
return xxx_messageInfo_GetTopicSubscriptionsEnvelope.Size(m)
}
func (m *GetTopicSubscriptionsEnvelope) XXX_DiscardUnknown() {
xxx_messageInfo_GetTopicSubscriptionsEnvelope.DiscardUnknown(m)
}
var xxx_messageInfo_GetTopicSubscriptionsEnvelope proto.InternalMessageInfo
func (m *GetTopicSubscriptionsEnvelope) GetTopics() []string {
if m != nil {
return m.Topics
}
return nil
}
type GetBindingsSubscriptionsEnvelope struct {
Bindings []string `protobuf:"bytes,1,rep,name=bindings,proto3" json:"bindings,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GetBindingsSubscriptionsEnvelope) Reset() { *m = GetBindingsSubscriptionsEnvelope{} }
func (m *GetBindingsSubscriptionsEnvelope) String() string { return proto.CompactTextString(m) }
func (*GetBindingsSubscriptionsEnvelope) ProtoMessage() {}
func (*GetBindingsSubscriptionsEnvelope) Descriptor() ([]byte, []int) {
return fileDescriptor_127d5244029ccc8f, []int{5}
}
func (m *GetBindingsSubscriptionsEnvelope) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetBindingsSubscriptionsEnvelope.Unmarshal(m, b)
}
func (m *GetBindingsSubscriptionsEnvelope) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetBindingsSubscriptionsEnvelope.Marshal(b, m, deterministic)
}
func (m *GetBindingsSubscriptionsEnvelope) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetBindingsSubscriptionsEnvelope.Merge(m, src)
}
func (m *GetBindingsSubscriptionsEnvelope) XXX_Size() int {
return xxx_messageInfo_GetBindingsSubscriptionsEnvelope.Size(m)
}
func (m *GetBindingsSubscriptionsEnvelope) XXX_DiscardUnknown() {
xxx_messageInfo_GetBindingsSubscriptionsEnvelope.DiscardUnknown(m)
}
var xxx_messageInfo_GetBindingsSubscriptionsEnvelope proto.InternalMessageInfo
func (m *GetBindingsSubscriptionsEnvelope) GetBindings() []string {
if m != nil {
return m.Bindings
}
return nil
}
type State struct {
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
Value *any.Any `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
Etag string `protobuf:"bytes,3,opt,name=etag,proto3" json:"etag,omitempty"`
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 *StateOptions `protobuf:"bytes,5,opt,name=options,proto3" json:"options,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *State) Reset() { *m = State{} }
func (m *State) String() string { return proto.CompactTextString(m) }
func (*State) ProtoMessage() {}
func (*State) Descriptor() ([]byte, []int) {
return fileDescriptor_127d5244029ccc8f, []int{6}
}
func (m *State) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_State.Unmarshal(m, b)
}
func (m *State) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_State.Marshal(b, m, deterministic)
}
func (m *State) XXX_Merge(src proto.Message) {
xxx_messageInfo_State.Merge(m, src)
}
func (m *State) XXX_Size() int {
return xxx_messageInfo_State.Size(m)
}
func (m *State) XXX_DiscardUnknown() {
xxx_messageInfo_State.DiscardUnknown(m)
}
var xxx_messageInfo_State proto.InternalMessageInfo
func (m *State) GetKey() string {
if m != nil {
return m.Key
}
return ""
}
func (m *State) GetValue() *any.Any {
if m != nil {
return m.Value
}
return nil
}
func (m *State) GetEtag() string {
if m != nil {
return m.Etag
}
return ""
}
func (m *State) GetMetadata() map[string]string {
if m != nil {
return m.Metadata
}
return nil
}
func (m *State) GetOptions() *StateOptions {
if m != nil {
return m.Options
}
return nil
}
type StateOptions struct {
Concurrency string `protobuf:"bytes,1,opt,name=concurrency,proto3" json:"concurrency,omitempty"`
Consistency string `protobuf:"bytes,2,opt,name=consistency,proto3" json:"consistency,omitempty"`
RetryPolicy *RetryPolicy `protobuf:"bytes,3,opt,name=retryPolicy,proto3" json:"retryPolicy,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *StateOptions) Reset() { *m = StateOptions{} }
func (m *StateOptions) String() string { return proto.CompactTextString(m) }
func (*StateOptions) ProtoMessage() {}
func (*StateOptions) Descriptor() ([]byte, []int) {
return fileDescriptor_127d5244029ccc8f, []int{7}
}
func (m *StateOptions) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_StateOptions.Unmarshal(m, b)
}
func (m *StateOptions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_StateOptions.Marshal(b, m, deterministic)
}
func (m *StateOptions) XXX_Merge(src proto.Message) {
xxx_messageInfo_StateOptions.Merge(m, src)
}
func (m *StateOptions) XXX_Size() int {
return xxx_messageInfo_StateOptions.Size(m)
}
func (m *StateOptions) XXX_DiscardUnknown() {
xxx_messageInfo_StateOptions.DiscardUnknown(m)
}
var xxx_messageInfo_StateOptions proto.InternalMessageInfo
func (m *StateOptions) GetConcurrency() string {
if m != nil {
return m.Concurrency
}
return ""
}
func (m *StateOptions) GetConsistency() string {
if m != nil {
return m.Consistency
}
return ""
}
func (m *StateOptions) GetRetryPolicy() *RetryPolicy {
if m != nil {
return m.RetryPolicy
}
return nil
}
type RetryPolicy struct {
Threshold int32 `protobuf:"varint,1,opt,name=threshold,proto3" json:"threshold,omitempty"`
Pattern string `protobuf:"bytes,2,opt,name=pattern,proto3" json:"pattern,omitempty"`
Interval *duration.Duration `protobuf:"bytes,3,opt,name=interval,proto3" json:"interval,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *RetryPolicy) Reset() { *m = RetryPolicy{} }
func (m *RetryPolicy) String() string { return proto.CompactTextString(m) }
func (*RetryPolicy) ProtoMessage() {}
func (*RetryPolicy) Descriptor() ([]byte, []int) {
return fileDescriptor_127d5244029ccc8f, []int{8}
}
func (m *RetryPolicy) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_RetryPolicy.Unmarshal(m, b)
}
func (m *RetryPolicy) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_RetryPolicy.Marshal(b, m, deterministic)
}
func (m *RetryPolicy) XXX_Merge(src proto.Message) {
xxx_messageInfo_RetryPolicy.Merge(m, src)
}
func (m *RetryPolicy) XXX_Size() int {
return xxx_messageInfo_RetryPolicy.Size(m)
}
func (m *RetryPolicy) XXX_DiscardUnknown() {
xxx_messageInfo_RetryPolicy.DiscardUnknown(m)
}
var xxx_messageInfo_RetryPolicy proto.InternalMessageInfo
func (m *RetryPolicy) GetThreshold() int32 {
if m != nil {
return m.Threshold
}
return 0
}
func (m *RetryPolicy) GetPattern() string {
if m != nil {
return m.Pattern
}
return ""
}
func (m *RetryPolicy) GetInterval() *duration.Duration {
if m != nil {
return m.Interval
}
return nil
}
func init() {
proto.RegisterType((*CloudEventEnvelope)(nil), "daprclient.CloudEventEnvelope")
proto.RegisterType((*BindingEventEnvelope)(nil), "daprclient.BindingEventEnvelope")
proto.RegisterMapType((map[string]string)(nil), "daprclient.BindingEventEnvelope.MetadataEntry")
proto.RegisterType((*BindingResponseEnvelope)(nil), "daprclient.BindingResponseEnvelope")
proto.RegisterType((*InvokeEnvelope)(nil), "daprclient.InvokeEnvelope")
proto.RegisterMapType((map[string]string)(nil), "daprclient.InvokeEnvelope.MetadataEntry")
proto.RegisterType((*GetTopicSubscriptionsEnvelope)(nil), "daprclient.GetTopicSubscriptionsEnvelope")
proto.RegisterType((*GetBindingsSubscriptionsEnvelope)(nil), "daprclient.GetBindingsSubscriptionsEnvelope")
proto.RegisterType((*State)(nil), "daprclient.State")
proto.RegisterMapType((map[string]string)(nil), "daprclient.State.MetadataEntry")
proto.RegisterType((*StateOptions)(nil), "daprclient.StateOptions")
proto.RegisterType((*RetryPolicy)(nil), "daprclient.RetryPolicy")
}
func init() { proto.RegisterFile("daprclient.proto", fileDescriptor_127d5244029ccc8f) }
var fileDescriptor_127d5244029ccc8f = []byte{
// 759 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xdd, 0x6a, 0xdb, 0x4a,
0x10, 0xb6, 0xe4, 0xdf, 0x8c, 0x73, 0x7c, 0x72, 0x86, 0x9c, 0x44, 0x51, 0xce, 0x49, 0x8d, 0x7a,
0x51, 0xb7, 0x14, 0x07, 0x5c, 0x4a, 0x7f, 0x02, 0x81, 0x26, 0x31, 0x69, 0x0b, 0xc5, 0x41, 0x09,
0x85, 0x42, 0x6f, 0x64, 0x79, 0xeb, 0x88, 0xc8, 0xbb, 0x62, 0xb5, 0x36, 0x08, 0x7a, 0xdf, 0xab,
0xbe, 0x42, 0x5f, 0xa2, 0xcf, 0xd2, 0xbb, 0xf6, 0x5d, 0x8a, 0x56, 0x2b, 0x7b, 0xe3, 0x9f, 0x84,
0x52, 0x7a, 0xa7, 0x9d, 0xef, 0x9b, 0x9d, 0xf9, 0xe6, 0x67, 0x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xcb, 0x61, 0x2f, 0x9d, 0x11, 0xa7, 0x80, 0xef, 0xe1, 0xdf,
0xa5, 0xf3, 0x8d, 0x5b, 0x0b, 0x0e, 0xdd, 0xf4, 0x77, 0x63, 0xdf, 0xd7, 0x83, 0xdc, 0xb8, 0x1a,
0x4e, 0x01, 0xfb, 0x60, 0xad, 0x5a, 0x82, 0x95, 0x01, 0x1e, 0xce, 0x05, 0xb8, 0x71, 0x85, 0x9c,
0x02, 0xbe, 0x83, 0x46, 0x8f, 0xea, 0x2f, 0x31, 0x36, 0x6f, 0x7b, 0xa3, 0xed, 0xbb, 0x4b, 0x18,
0xf3, 0xef, 0xaa, 0x53, 0xc0, 0x97, 0xb0, 0xde, 0xa3, 0x52, 0x60, 0x76, 0xf1, 0x9e, 0xee, 0xb6,
0xf8, 0x37, 0xb5, 0x57, 0x48, 0x72, 0x0a, 0x47, 0xbb, 0x50, 0x0d, 0x98, 0xf4, 0x3e, 0xda, 0x98,
0x75, 0xef, 0x2c, 0xa5, 0xc5, 0xfd, 0x8a, 0xa4, 0x3f, 0xfa, 0x19, 0x00, 0x00, 0xff, 0xff, 0x30,
0x41, 0xfe, 0xa9, 0x1a, 0x08, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConn
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion4
// DaprClientClient is the client API for DaprClient service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type DaprClientClient interface {
OnInvoke(ctx context.Context, in *InvokeEnvelope, opts ...grpc.CallOption) (*any.Any, error)
GetTopicSubscriptions(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*GetTopicSubscriptionsEnvelope, error)
GetBindingsSubscriptions(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*GetBindingsSubscriptionsEnvelope, error)
OnBindingEvent(ctx context.Context, in *BindingEventEnvelope, opts ...grpc.CallOption) (*BindingResponseEnvelope, error)
OnTopicEvent(ctx context.Context, in *CloudEventEnvelope, opts ...grpc.CallOption) (*empty.Empty, error)
}
type daprClientClient struct {
cc *grpc.ClientConn
}
func NewDaprClientClient(cc *grpc.ClientConn) DaprClientClient {
return &daprClientClient{cc}
}
func (c *daprClientClient) OnInvoke(ctx context.Context, in *InvokeEnvelope, opts ...grpc.CallOption) (*any.Any, error) {
out := new(any.Any)
err := c.cc.Invoke(ctx, "/daprclient.DaprClient/OnInvoke", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *daprClientClient) GetTopicSubscriptions(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*GetTopicSubscriptionsEnvelope, error) {
out := new(GetTopicSubscriptionsEnvelope)
err := c.cc.Invoke(ctx, "/daprclient.DaprClient/GetTopicSubscriptions", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *daprClientClient) GetBindingsSubscriptions(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*GetBindingsSubscriptionsEnvelope, error) {
out := new(GetBindingsSubscriptionsEnvelope)
err := c.cc.Invoke(ctx, "/daprclient.DaprClient/GetBindingsSubscriptions", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *daprClientClient) OnBindingEvent(ctx context.Context, in *BindingEventEnvelope, opts ...grpc.CallOption) (*BindingResponseEnvelope, error) {
out := new(BindingResponseEnvelope)
err := c.cc.Invoke(ctx, "/daprclient.DaprClient/OnBindingEvent", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *daprClientClient) OnTopicEvent(ctx context.Context, in *CloudEventEnvelope, opts ...grpc.CallOption) (*empty.Empty, error) {
out := new(empty.Empty)
err := c.cc.Invoke(ctx, "/daprclient.DaprClient/OnTopicEvent", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// DaprClientServer is the server API for DaprClient service.
type DaprClientServer interface {
OnInvoke(context.Context, *InvokeEnvelope) (*any.Any, error)
GetTopicSubscriptions(context.Context, *empty.Empty) (*GetTopicSubscriptionsEnvelope, error)
GetBindingsSubscriptions(context.Context, *empty.Empty) (*GetBindingsSubscriptionsEnvelope, error)
OnBindingEvent(context.Context, *BindingEventEnvelope) (*BindingResponseEnvelope, error)
OnTopicEvent(context.Context, *CloudEventEnvelope) (*empty.Empty, error)
}
func RegisterDaprClientServer(s *grpc.Server, srv DaprClientServer) {
s.RegisterService(&_DaprClient_serviceDesc, srv)
}
func _DaprClient_OnInvoke_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(InvokeEnvelope)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DaprClientServer).OnInvoke(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/daprclient.DaprClient/OnInvoke",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DaprClientServer).OnInvoke(ctx, req.(*InvokeEnvelope))
}
return interceptor(ctx, in, info, handler)
}
func _DaprClient_GetTopicSubscriptions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(empty.Empty)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DaprClientServer).GetTopicSubscriptions(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/daprclient.DaprClient/GetTopicSubscriptions",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DaprClientServer).GetTopicSubscriptions(ctx, req.(*empty.Empty))
}
return interceptor(ctx, in, info, handler)
}
func _DaprClient_GetBindingsSubscriptions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(empty.Empty)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DaprClientServer).GetBindingsSubscriptions(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/daprclient.DaprClient/GetBindingsSubscriptions",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DaprClientServer).GetBindingsSubscriptions(ctx, req.(*empty.Empty))
}
return interceptor(ctx, in, info, handler)
}
func _DaprClient_OnBindingEvent_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(BindingEventEnvelope)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DaprClientServer).OnBindingEvent(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/daprclient.DaprClient/OnBindingEvent",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DaprClientServer).OnBindingEvent(ctx, req.(*BindingEventEnvelope))
}
return interceptor(ctx, in, info, handler)
}
func _DaprClient_OnTopicEvent_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CloudEventEnvelope)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DaprClientServer).OnTopicEvent(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/daprclient.DaprClient/OnTopicEvent",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DaprClientServer).OnTopicEvent(ctx, req.(*CloudEventEnvelope))
}
return interceptor(ctx, in, info, handler)
}
var _DaprClient_serviceDesc = grpc.ServiceDesc{
ServiceName: "daprclient.DaprClient",
HandlerType: (*DaprClientServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "OnInvoke",
Handler: _DaprClient_OnInvoke_Handler,
},
{
MethodName: "GetTopicSubscriptions",
Handler: _DaprClient_GetTopicSubscriptions_Handler,
},
{
MethodName: "GetBindingsSubscriptions",
Handler: _DaprClient_GetBindingsSubscriptions_Handler,
},
{
MethodName: "OnBindingEvent",
Handler: _DaprClient_OnBindingEvent_Handler,
},
{
MethodName: "OnTopicEvent",
Handler: _DaprClient_OnTopicEvent_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "daprclient.proto",
}

102
example/caller/main.go Normal file
View File

@ -0,0 +1,102 @@
package main
import (
"context"
"fmt"
"os"
pb "github.com/dapr/go-sdk/dapr"
"github.com/golang/protobuf/ptypes/any"
"google.golang.org/grpc"
)
func main() {
// Get the Dapr port and create a connection
daprPort := os.Getenv("DAPR_GRPC_PORT")
daprAddress := fmt.Sprintf("localhost:%s", daprPort)
conn, err := grpc.Dial(daprAddress, grpc.WithInsecure())
if err != nil {
fmt.Println(err)
return
}
defer conn.Close()
// Create the client
client := pb.NewDaprClient(conn)
// Invoke a method called MyMethod on another Dapr enabled service with id client
resp, err := client.InvokeService(context.Background(), &pb.InvokeServiceEnvelope{
Id: "client",
Data: &any.Any{Value: []byte("Hello")},
Method: "MyMethod",
})
if err != nil {
fmt.Println(err)
} else {
fmt.Println(string(resp.Data.Value))
}
// Publish a message to the topic TopicA
_, err = client.PublishEvent(context.Background(), &pb.PublishEventEnvelope{
Topic: "TopicA",
Data: &any.Any{
Value: []byte("Hi from Pub Sub"),
},
})
if err != nil {
fmt.Println(err)
} else {
fmt.Println("Published message!")
}
// Save state with the key myKey
_, err = client.SaveState(context.Background(), &pb.SaveStateEnvelope{
Requests: []*pb.StateRequest{
&pb.StateRequest{
Key: "myKey",
Value: &any.Any{
Value: []byte("My State"),
},
},
},
})
if err != nil {
fmt.Println(err)
} else {
fmt.Println("Saved state!")
}
// Get state for key myKey
r, err := client.GetState(context.Background(), &pb.GetStateEnvelope{
Key: "myKey",
})
if err != nil {
fmt.Println(err)
} else {
fmt.Println("Got state!")
fmt.Println(string(r.Data.Value))
}
// Delete state for key myKey
_, err = client.DeleteState(context.Background(), &pb.DeleteStateEnvelope{
Key: "myKey",
})
if err != nil {
fmt.Println(err)
} else {
fmt.Println("State deleted")
}
// Invoke output binding named storage. Make sure you set up a Dapr binding, otherwise this will fail
_, err = client.InvokeBinding(context.Background(), &pb.InvokeBindingEnvelope{
Name: "storage",
Data: &any.Any{
Value: []byte("some data"),
},
})
if err != nil {
fmt.Println(err)
} else {
fmt.Println("Binding invoked")
}
}

86
example/client/main.go Normal file
View File

@ -0,0 +1,86 @@
package main
import (
"context"
"fmt"
"log"
"net"
"github.com/golang/protobuf/ptypes/any"
"github.com/golang/protobuf/ptypes/empty"
pb "github.com/dapr/go-sdk/daprclient"
"google.golang.org/grpc"
)
// server is our user app
type server struct {
}
func main() {
// create listiner
lis, err := net.Listen("tcp", ":4000")
if err != nil {
log.Fatalf("failed to listen: %v", err)
}
// create grpc server
s := grpc.NewServer()
pb.RegisterDaprClientServer(s, &server{})
fmt.Println("Client starting...")
// and start...
if err := s.Serve(lis); err != nil {
log.Fatalf("failed to serve: %v", err)
}
}
// Sample method to invoke
func (s *server) MyMethod() string {
return "Hi there!"
}
// This method gets invoked when a remote service has called the app through Dapr
// The payload carries a Method to identify the method, a set of metadata properties and an optional payload
func (s *server) OnInvoke(ctx context.Context, in *pb.InvokeEnvelope) (*any.Any, error) {
var response string
fmt.Println(fmt.Sprintf("Got invoked with: %s", string(in.Data.Value)))
switch in.Method {
case "MyMethod":
response = s.MyMethod()
}
return &any.Any{
Value: []byte(response),
}, nil
}
// Dapr will call this method to get the list of topics the app wants to subscribe to. In this example, we are telling Dapr
// To subscribe to a topic named TopicA
func (s *server) GetTopicSubscriptions(ctx context.Context, in *empty.Empty) (*pb.GetTopicSubscriptionsEnvelope, error) {
return &pb.GetTopicSubscriptionsEnvelope{
Topics: []string{"TopicA"},
}, nil
}
// Dapper will call this method to get the list of bindings the app will get invoked by. In this example, we are telling Dapr
// To invoke our app with a binding named storage
func (s *server) GetBindingsSubscriptions(ctx context.Context, in *empty.Empty) (*pb.GetBindingsSubscriptionsEnvelope, error) {
return &pb.GetBindingsSubscriptionsEnvelope{
Bindings: []string{"storage"},
}, nil
}
// This method gets invoked every time a new event is fired from a registerd binding. The message carries the binding name, a payload and optional metadata
func (s *server) OnBindingEvent(ctx context.Context, in *pb.BindingEventEnvelope) (*pb.BindingResponseEnvelope, error) {
fmt.Println("Invoked from binding")
return &pb.BindingResponseEnvelope{}, nil
}
// This method is fired whenever a message has been published to a topic that has been subscribed. Dapr sends published messages in a CloudEvents 0.3 envelope.
func (s *server) OnTopicEvent(ctx context.Context, in *pb.CloudEventEnvelope) (*empty.Empty, error) {
fmt.Println("Topic message arrived")
return &empty.Empty{}, nil
}