mirror of https://github.com/dapr/docs.git
commit
88ce79f374
|
@ -86,7 +86,7 @@ data := []byte("ping")
|
||||||
// create the client
|
// create the client
|
||||||
client, err := dapr.NewClient()
|
client, err := dapr.NewClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Panic(err)
|
log.Panic(err)
|
||||||
}
|
}
|
||||||
defer client.Close()
|
defer client.Close()
|
||||||
```
|
```
|
||||||
|
@ -95,11 +95,11 @@ defer client.Close()
|
||||||
|
|
||||||
```go
|
```go
|
||||||
// save state with the key key1
|
// save state with the key key1
|
||||||
err = client.SaveStateData(ctx, "statestore", "key1", "1", data)
|
err = client.SaveState(ctx, "statestore", "key1", data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Panic(err)
|
log.Panic(err)
|
||||||
}
|
}
|
||||||
logger.Println("data saved")
|
log.Println("data saved")
|
||||||
```
|
```
|
||||||
|
|
||||||
Hooray!
|
Hooray!
|
||||||
|
@ -135,6 +135,7 @@ import (
|
||||||
```go
|
```go
|
||||||
// server is our user app
|
// server is our user app
|
||||||
type server struct {
|
type server struct {
|
||||||
|
pb.UnimplementedAppCallbackServer
|
||||||
}
|
}
|
||||||
|
|
||||||
// EchoMethod is a simple demo method to invoke
|
// EchoMethod is a simple demo method to invoke
|
||||||
|
@ -183,9 +184,9 @@ func (s *server) OnBindingEvent(ctx context.Context, in *pb.BindingEventRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.
|
// 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.TopicEventRequest) (*empty.Empty, error) {
|
func (s *server) OnTopicEvent(ctx context.Context, in *pb.TopicEventRequest) (*pb.TopicEventResponse, error) {
|
||||||
fmt.Println("Topic message arrived")
|
fmt.Println("Topic message arrived")
|
||||||
return &empty.Empty{}, nil
|
return &pb.TopicEventResponse{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in New Issue