mirror of https://github.com/dapr/go-sdk.git
fix some typo (#131)
* fix some typo * log format * remove useless code
This commit is contained in:
parent
7a4b57c436
commit
ee170a232a
|
@ -48,16 +48,16 @@ type Client interface {
|
||||||
// InvokeMethodWithCustomContent invokes app with custom content (struct + content type).
|
// InvokeMethodWithCustomContent invokes app with custom content (struct + content type).
|
||||||
InvokeMethodWithCustomContent(ctx context.Context, appID, methodName, verb string, contentType string, content interface{}) (out []byte, err error)
|
InvokeMethodWithCustomContent(ctx context.Context, appID, methodName, verb string, contentType string, content interface{}) (out []byte, err error)
|
||||||
|
|
||||||
// PublishEvent pubishes data onto topic in specific pubsub component.
|
// PublishEvent publishes data onto topic in specific pubsub component.
|
||||||
PublishEvent(ctx context.Context, pubsubName, topicName string, data []byte) error
|
PublishEvent(ctx context.Context, pubsubName, topicName string, data []byte) error
|
||||||
|
|
||||||
// PublishEventfromCustomContent serializes an struct and pubishes its contents as data (JSON) onto topic in specific pubsub component.
|
// PublishEventfromCustomContent serializes an struct and publishes its contents as data (JSON) onto topic in specific pubsub component.
|
||||||
PublishEventfromCustomContent(ctx context.Context, pubsubName, topicName string, data interface{}) error
|
PublishEventfromCustomContent(ctx context.Context, pubsubName, topicName string, data interface{}) error
|
||||||
|
|
||||||
// GetSecret retrieves preconfigred secret from specified store using key.
|
// GetSecret retrieves preconfigured secret from specified store using key.
|
||||||
GetSecret(ctx context.Context, storeName, key string, meta map[string]string) (data map[string]string, err error)
|
GetSecret(ctx context.Context, storeName, key string, meta map[string]string) (data map[string]string, err error)
|
||||||
|
|
||||||
// GetBulkSecret retrieves all preconfigred secrets for this application.
|
// GetBulkSecret retrieves all preconfigured secrets for this application.
|
||||||
GetBulkSecret(ctx context.Context, storeName string, meta map[string]string) (data map[string]string, err error)
|
GetBulkSecret(ctx context.Context, storeName string, meta map[string]string) (data map[string]string, err error)
|
||||||
|
|
||||||
// SaveState saves the raw data into store using default state options.
|
// SaveState saves the raw data into store using default state options.
|
||||||
|
@ -124,7 +124,7 @@ func NewClientWithPort(port string) (client Client, err error) {
|
||||||
return NewClientWithAddress(net.JoinHostPort("127.0.0.1", port))
|
return NewClientWithAddress(net.JoinHostPort("127.0.0.1", port))
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewClientWithAddress instantiates Dapr using specific address (inclding port).
|
// NewClientWithAddress instantiates Dapr using specific address (including port).
|
||||||
func NewClientWithAddress(address string) (client Client, err error) {
|
func NewClientWithAddress(address string) (client Client, err error) {
|
||||||
if address == "" {
|
if address == "" {
|
||||||
return nil, errors.New("nil address")
|
return nil, errors.New("nil address")
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PublishEvent pubishes data onto specific pubsub topic.
|
// PublishEvent publishes data onto specific pubsub topic.
|
||||||
func (c *GRPCClient) PublishEvent(ctx context.Context, pubsubName, topicName string, data []byte) error {
|
func (c *GRPCClient) PublishEvent(ctx context.Context, pubsubName, topicName string, data []byte) error {
|
||||||
if pubsubName == "" {
|
if pubsubName == "" {
|
||||||
return errors.New("pubsubName name required")
|
return errors.New("pubsubName name required")
|
||||||
|
@ -31,7 +31,7 @@ func (c *GRPCClient) PublishEvent(ctx context.Context, pubsubName, topicName str
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// PublishEventfromCustomContent serializes an struct and pubishes its contents as data (JSON) onto topic in specific pubsub component.
|
// PublishEventfromCustomContent serializes an struct and publishes its contents as data (JSON) onto topic in specific pubsub component.
|
||||||
func (c *GRPCClient) PublishEventfromCustomContent(ctx context.Context, pubsubName, topicName string, data interface{}) error {
|
func (c *GRPCClient) PublishEventfromCustomContent(ctx context.Context, pubsubName, topicName string, data interface{}) error {
|
||||||
if pubsubName == "" {
|
if pubsubName == "" {
|
||||||
return errors.New("pubsubName name required")
|
return errors.New("pubsubName name required")
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetSecret retrieves preconfigred secret from specified store using key.
|
// GetSecret retrieves preconfigured secret from specified store using key.
|
||||||
func (c *GRPCClient) GetSecret(ctx context.Context, storeName, key string, meta map[string]string) (data map[string]string, err error) {
|
func (c *GRPCClient) GetSecret(ctx context.Context, storeName, key string, meta map[string]string) (data map[string]string, err error) {
|
||||||
if storeName == "" {
|
if storeName == "" {
|
||||||
return nil, errors.New("nil storeName")
|
return nil, errors.New("nil storeName")
|
||||||
|
@ -34,7 +34,7 @@ func (c *GRPCClient) GetSecret(ctx context.Context, storeName, key string, meta
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetBulkSecret retrieves all preconfigred secrets for this application.
|
// GetBulkSecret retrieves all preconfigured secrets for this application.
|
||||||
func (c *GRPCClient) GetBulkSecret(ctx context.Context, storeName string, meta map[string]string) (data map[string]string, err error) {
|
func (c *GRPCClient) GetBulkSecret(ctx context.Context, storeName string, meta map[string]string) (data map[string]string, err error) {
|
||||||
if storeName == "" {
|
if storeName == "" {
|
||||||
return nil, errors.New("nil storeName")
|
return nil, errors.New("nil storeName")
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
|
|
||||||
v1 "github.com/dapr/go-sdk/dapr/proto/common/v1"
|
v1 "github.com/dapr/go-sdk/dapr/proto/common/v1"
|
||||||
pb "github.com/dapr/go-sdk/dapr/proto/runtime/v1"
|
pb "github.com/dapr/go-sdk/dapr/proto/runtime/v1"
|
||||||
duration "github.com/golang/protobuf/ptypes/duration"
|
"github.com/golang/protobuf/ptypes/duration"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -146,8 +146,8 @@ func toProtoStateOptions(so *StateOptions) (opts *v1.StateOptions) {
|
||||||
return stateOptionDefault
|
return stateOptionDefault
|
||||||
}
|
}
|
||||||
return &v1.StateOptions{
|
return &v1.StateOptions{
|
||||||
Concurrency: (v1.StateOptions_StateConcurrency(so.Concurrency)),
|
Concurrency: v1.StateOptions_StateConcurrency(so.Concurrency),
|
||||||
Consistency: (v1.StateOptions_StateConsistency(so.Consistency)),
|
Consistency: v1.StateOptions_StateConsistency(so.Consistency),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,7 +278,7 @@ func (c *GRPCClient) GetStateWithConsistency(ctx context.Context, storeName, key
|
||||||
req := &pb.GetStateRequest{
|
req := &pb.GetStateRequest{
|
||||||
StoreName: storeName,
|
StoreName: storeName,
|
||||||
Key: key,
|
Key: key,
|
||||||
Consistency: (v1.StateOptions_StateConsistency(sc)),
|
Consistency: v1.StateOptions_StateConsistency(sc),
|
||||||
Metadata: meta,
|
Metadata: meta,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ dapr run --app-id serving \
|
||||||
|
|
||||||
## Client
|
## Client
|
||||||
|
|
||||||
Once one of the above services is running is running, launch the client:
|
Once one of the above services is running, launch the client:
|
||||||
|
|
||||||
```
|
```
|
||||||
cd example/client
|
cd example/client
|
||||||
|
|
|
@ -76,7 +76,7 @@ func main() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
fmt.Printf("service method invoked, response: %s", string(resp))
|
fmt.Printf("service method invoked, response: %s\n", string(resp))
|
||||||
|
|
||||||
in := &dapr.InvokeBindingRequest{
|
in := &dapr.InvokeBindingRequest{
|
||||||
Name: "example-http-binding",
|
Name: "example-http-binding",
|
||||||
|
@ -86,5 +86,6 @@ func main() {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
fmt.Println("output binding invoked")
|
fmt.Println("output binding invoked")
|
||||||
|
|
||||||
fmt.Println("DONE (CTRL+C to Exit)")
|
fmt.Println("DONE (CTRL+C to Exit)")
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,18 +29,16 @@ func (s *Server) OnInvoke(ctx context.Context, in *cpb.InvokeRequest) (*cpb.Invo
|
||||||
}
|
}
|
||||||
if fn, ok := s.invokeHandlers[in.Method]; ok {
|
if fn, ok := s.invokeHandlers[in.Method]; ok {
|
||||||
e := &cc.InvocationEvent{}
|
e := &cc.InvocationEvent{}
|
||||||
if in != nil {
|
e.ContentType = in.ContentType
|
||||||
e.ContentType = in.ContentType
|
|
||||||
|
|
||||||
if in.Data != nil {
|
if in.Data != nil {
|
||||||
e.Data = in.Data.Value
|
e.Data = in.Data.Value
|
||||||
e.DataTypeURL = in.Data.TypeUrl
|
e.DataTypeURL = in.Data.TypeUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
if in.HttpExtension != nil {
|
if in.HttpExtension != nil {
|
||||||
e.Verb = in.HttpExtension.Verb.String()
|
e.Verb = in.HttpExtension.Verb.String()
|
||||||
e.QueryString = in.HttpExtension.Querystring
|
e.QueryString = in.HttpExtension.Querystring
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ct, er := fn(ctx, e)
|
ct, er := fn(ctx, e)
|
||||||
|
|
Loading…
Reference in New Issue