Fixes: #574
Changes ActorHost constructor to be public again. Now the state manager
and http interactor are set via properties. This means that code in unit
tests won't be able to cover the methods that interact with timers or
reminders - however this was already the case. Testing state management
is covered by replacing the `IActorStateManager` with a mock.
Logged an issue to improve this.
Also added validation. If you try to use something that's not fully
initialized it will result in an exception with a meaningful message
instead of a null reference.
Also skips tests that are failing due to #573. We know the cause of why
these are failing, and these tests have not been stable since they were
introduced. Failing additional CI builds is not giving us new
information.
* Add raw API for using bindings with non-text data
Fixes: #560
This change adds some new data types and a new overload of
`InvokeBindingAsync` that can work with raw data (non-text) as bytes.
* PR feedback
* Unify DaprException classes
We have two classes called DaprException.
It makes way more sense for us to have DaprException in the Dapr.Client
project, and it also makes sense for Dapr.Actors to reference
Dapr.Client (it did not for some reason).
There's some additional cleanup of code related to
JsonSerializerOptions. The Actors code was not referencing the 5.0.0
version of the package, and so it's now got access to some new stuff,
so we could remove a polyfill.
* Throw DaprException for errors
Fixes: #516
This updates all of the locations in DaprClient that handle networking
or serialization to throw DaprException instead of the underlying
exception type. This allows for simpler error handling.
* Add one more unit test
Fixes: #559
This change adds disposable support to DaprClient, and updates samples
to dispose it.
I didn't update tests because there are literally hundreds of
non-find-and-replacable cases, and we're not actually doing networking
in our tests so it won't cause an issue.
Fixes: #442
We're making it absolutely clear which methods do JSON (most of them)
and which do gRPC. We have the ability to do both 'raw' functionality
and optimized paths for JSON+HTTP and gRPC+Protobuf for invoke. We're
not going to add 'raw' or Protobuf support for other building blocks
until there's a specific use case.
For the most part the functionality that's being removed here isn't used
anymore since that was part of the invoke changes.
Fixes: #549
This change mixes up the service invocation APIs to reflect some changes
that are coming down the pipe in dapr/dapr#2683.
We're now using HTTP's semantics and JSON for the main functionality in
`InvokeMethodAsync`. This means that the error handling is simplified
and base on HTTP's status codes rather than trying to abstract over HTTP
and gRPC's different error models. This also means that we're free to
expose HttpRequestMessage and related types in the API because it's no
longer an abstraction.
You can still use `InvokeMethodAsync` to invoke gRPC services, but you
will get a status code in the response, and it will expect JSON, etc,
similar to how gRPC gateway works.
In addition to that we're added `InvokeMethodGrpcAsync` for cases where
you really want *gRPC's* semantics. These methods do Protobuf
serialization, as is a natural choice for gRPC. I do not recommend using
this approach to invoke HTTP services.
---
I also mad updates and improvments to various infrastructure where
necessary (like InvocationException). Also, the gRPC sample in the repo
now uses the new `InvokeMethodGrpcAsync` APIs.
* Add IActorProxyFactory to DI
Fixes: #532
This change adds IActorProxyFactory to DI when used with ASP.NET Core,
and makes it also available as a property on the Actor base class. This
way if you've configured the ActorRuntimeOptions with your JSON
settings, its easy to have them picked up in Actors client use cases as
well.
This doesn't quite go all the way to unifying the settings with
DaprClient - we don't want to make a change that disruptive this close
to release.
* Fix registration and add test
- Adds a new message handler for HttpClient interop
- Adds an easy way to create HttpClient instances
- A bunch of sample cleanup/polish/simplification
The main thing here is the added ability to interop with HttpClient. We'll be making some future changes to the service invocation APIs in DaprClient to address dapr/dapr#2342 since that issues greatly simplifies the interface we're dealing with.
Fixes: #526
* do not swallow all exceptions
Co-authored-by: Ryan Nowak <nowakra@gmail.com>
Co-authored-by: Per Ökvist <perokvist@users.noreply.github.com>
Co-authored-by: Sander Molenkamp <a.molenkamp@gmail.com>
* Documentation/comment fixes
* Add customizable JsonSerializerOptions for actors
- Added ability to set or customize the ActorRuntime's JsonSerializerOptions
- Added ability to set or customize the ActorClient's JsonSerializerOptions
* Fix unit test helper for BadStartup
* Add ActorProxy JsonSerializerOptions tests
* Add unit tests for RuntimeOptions and ProxyOptions
* Made fixes requested by Ryan Nowak
- Renamed ActorProxyTests to be more explicit about their purpose
- Added more ActorProxyTests to account for all static Create overloads
- Added explicit JsonSerializerOptions checks in tests
Fixes: #395
This change uses the IReadOnlyDictionary<> interface type where
possible, in particularly where we accept metadata. This allows the use
of the immutable collection types as parameters, as well as communicates
the contract - the SDK will read the metadata but not write to it. This
is helpful, because it communicates clearly to the user that they can
create a shared metadata collection instance and reuse them across
calls.
These are just extra maintenance. The root cause of this regression is
that we didn't add the tests to all of the right solutions. Life is
simpler if we just use one. The `dotnet` commands already do the right
thing.
Fixes: #53
This API was intended to query the state store for all existing state
entries for the actor. However support for this in the dapr runtime has
not be implemented. We're removing this API to avoid confusion since
it does not behave as expected. We can revisit this in the future based
on feedback.
Fixes: #410
This change removes code that would write the exception message and call
stack to the response body when a non-remoting invoke is used. While
this kind of thing can be helpful for debugging, the best thing to do is
actually just let the exception bubble. This allows users to use the
ASP.NET Core error handling features that are much richer and have
security related guidance built-in.
* state operation overload with meta #412
* added metadata to bulk state
* getStateAndEtag with metadata test
* an -> a keyvalue pair
* Added GetBulkStateAsync_ValidateRequest
* update
* update
* removed backup files
* metadata docs
* state store metadata docs
Co-authored-by: Ryan Nowak <nowakra@gmail.com>
Fixes: #434
This change introduces new APIs for registering Actors DI and with
the HTTP pipeline based on the ASP.NET Core Startup.cs model. This
replaces `UseActors()` in Program.cs and delivers better integration
between the ASP.NET Core framework and Actors.
The bug that motivated this change was that the actors HTTP handlers
were separate from the application's main routing table. This meant that
certain routing patterns were totally broken (such as Blazor Server)
when used in the same project as actors. There was no real way to fix
this without a change in how we register the framework to make it more
consistent with other features that build on ASP.NET Core.
We've had a list of linting-related messages piling up for a while now.
This change bulk-applies these suggestions with usually relate to
simplification or use or newer language features like ??=
The only changes I did manually here are:
Removing some usage of Task.GetAwaiter().GetResult() where it was
just laziness
Removing some dead code in methods and parameters of internal APIs.