In the state API there's an existing DeleteStateWithETag() convenience
function but there does not appear to be an equivalent
SaveStateWithETag(). This commit adds SetStateWithETag() so that
consumers of the SDK don't have to employ the more verbose
SaveBulkState() when they only need to update a singular item.
Client code updating a single item with an etag prior to this commit
looks like:
--
item := &dapr.SetStateItem{
Etag: &dapr.ETag{
Value: "deadbeef",
},
Key: "order_1",
Value: []byte(data),
}
err := client.SaveBulkState(ctx, store, item)
--
Client code after this commit can reduce to:
--
err := client.SaveStateWithEtag(ctx, store, "order_1", []byte(data), "deadbeef")
--
Signed-off-by: Mike Brown <github@torvosoft.com>
Signed-off-by: Mike Brown <github@torvosoft.com>
I was debugging a panic in a local application I was developing and noticed this issue. A validation failure isn't correctly handled as a failure, and we insert a nil value into the map. This value in this map is later dereferenced, resulting in the following panic:
```
http: panic serving 127.0.0.1:45598: runtime error: invalid memory address or nil pointer dereference
goroutine 248 [running]:
net/http.(*conn).serve.func1()
/home/linuxbrew/.linuxbrew/Cellar/go/1.19.1/libexec/src/net/http/server.go:1850 +0xbf
panic({0x9558a0, 0xe4d7c0})
/home/linuxbrew/.linuxbrew/Cellar/go/1.19.1/libexec/src/runtime/panic.go:890 +0x262
github.com/dapr/go-sdk/actor/manager.(*DefaultActorContainer).Invoke(0xc0000be810, {0xc000048126?, 0x9?}, {0xc0003fc000, 0x4, 0x200})
/home/cgillum/go/pkg/mod/github.com/dapr/go-sdk@v1.5.0/actor/manager/container.go:75 +0x299
github.com/dapr/go-sdk/actor/manager.(*DefaultActorManager).InvokeMethod(0xc000112300, {0xc000048115?, 0xc0000a3888?}, {0xc000048126, 0x4}, {0xc0003fc000, 0x4, 0x200})
/home/cgillum/go/pkg/mod/github.com/dapr/go-sdk@v1.5.0/actor/manager/manager.go:92 +0xb2
github.com/dapr/go-sdk/actor/runtime.(*ActorRunTime).InvokeActorMethod(0xa?, {0xc00004810c?, 0x7f71edd544a0?}, {0xc000048115, 0x9}, {0xc000048126, 0x4}, {0xc0003fc000, 0x4, 0x200})
/home/cgillum/go/pkg/mod/github.com/dapr/go-sdk@v1.5.0/actor/runtime/actor_runtime.go:75 +0xba
github.com/dapr/go-sdk/service/http.(*Server).registerBaseHandler.func4({0xad7298, 0xc0003b0000}, 0xc0004e4100)
/home/cgillum/go/pkg/mod/github.com/dapr/go-sdk@v1.5.0/service/http/topic.go:112 +0x1be
net/http.HandlerFunc.ServeHTTP(0xc0004e4000?, {0xad7298?, 0xc0003b0000?}, 0x800?)
/home/linuxbrew/.linuxbrew/Cellar/go/1.19.1/libexec/src/net/http/server.go:2109 +0x2f
github.com/gorilla/mux.(*Router).ServeHTTP(0xc000218240, {0xad7298, 0xc0003b0000}, 0xc0003b4600)
/home/cgillum/go/pkg/mod/github.com/gorilla/mux@v1.8.0/mux.go:210 +0x1cf
net/http.serverHandler.ServeHTTP({0xad62e8?}, {0xad7298, 0xc0003b0000}, 0xc0003b4600)
/home/linuxbrew/.linuxbrew/Cellar/go/1.19.1/libexec/src/net/http/server.go:2947 +0x30c
net/http.(*conn).serve(0xc0000001e0, {0xad7a00, 0xc00012b380})
/home/linuxbrew/.linuxbrew/Cellar/go/1.19.1/libexec/src/net/http/server.go:1991 +0x607
created by net/http.(*Server).Serve
/home/linuxbrew/.linuxbrew/Cellar/go/1.19.1/libexec/src/net/http/server.go:3102 +0x4db
```
The issue appears to be the error handling logic, which I've fixed in this PR.
Signed-off-by: Chris Gillum <cgillum@gmail.com>
Signed-off-by: Chris Gillum <cgillum@gmail.com>
* add distributed lock api support
Signed-off-by: yaron2 <schneider.yaron@live.com>
* go mod tidy for pub/sub
Signed-off-by: yaron2 <schneider.yaron@live.com>
* go mod tidy for state
Signed-off-by: yaron2 <schneider.yaron@live.com>
* go mod tidy for service invocation
Signed-off-by: yaron2 <schneider.yaron@live.com>
* linter
Signed-off-by: yaron2 <schneider.yaron@live.com>
* added unlock tests
Signed-off-by: yaron2 <schneider.yaron@live.com>
* Update golangci-lint-action
Signed-off-by: Shubham Sharma <shubhash@microsoft.com>
* Use the correct go version
Signed-off-by: Shubham Sharma <shubhash@microsoft.com>
* Decode CloudEvent Data consistently between HTTP and gRPC
Signed-off-by: Phil Kedy <phil.kedy@gmail.com>
* linter issue
Signed-off-by: Phil Kedy <phil.kedy@gmail.com>
* Added parsing media type
Signed-off-by: Phil Kedy <phil.kedy@gmail.com>
* Adding extension json media type handling
Signed-off-by: Phil Kedy <phil.kedy@gmail.com>
* add TTL to actor timer/reminder requests (#225)
Signed-off-by: Phil Kedy <phil.kedy@gmail.com>
* Adding more tests
Signed-off-by: Phil Kedy <phil.kedy@gmail.com>
* Tweak
Signed-off-by: Phil Kedy <phil.kedy@gmail.com>
Co-authored-by: Dmitry Shmulevich <dmitry.shmulevich@gmail.com>
* 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>
* Make client init fail if server connection fails
This prevents client/server connectivity issues from resulting in silent
failure modes and ensures they're caught as early as possible
* Fix linter errors
Co-authored-by: Yaron Schneider <yaronsc@microsoft.com>
* Rationalize PublishEvent* APIs
Allow passing options such as Content-Type and Metadata in a flexible and future-proof way.
The method `PublishEventfromCustomContent` is now deprecated and shows a warning in the console when used.
Fixes#174, #164
* Do not wrap errors for invocations
Fix#186
* Updated variable name
* Added error check
* Oops
* Linting
Co-authored-by: Yaron Schneider <yaronsc@microsoft.com>
Co-authored-by: Phil Kedy <phil.kedy@gmail.com>