diff --git a/examples/Client/DistributedLock/Controllers/BindingController.cs b/examples/Client/DistributedLock/Controllers/BindingController.cs index 64228df43..bd056564b 100644 --- a/examples/Client/DistributedLock/Controllers/BindingController.cs +++ b/examples/Client/DistributedLock/Controllers/BindingController.cs @@ -18,6 +18,7 @@ public class BindingController(DaprClient client, ILogger log private string appId = Environment.GetEnvironmentVariable("APP_ID"); [HttpPost("cronbinding")] + [Obsolete] public async Task HandleBindingEvent() { logger.LogInformation("Received binding event on {appId}, scanning for work.", appId); @@ -39,6 +40,7 @@ public async Task HandleBindingEvent() return Ok(); } + [Obsolete] private async Task AttemptToProcessFile(string fileName) { // Locks are Disposable and will automatically unlock at the end of a 'using' statement. @@ -76,6 +78,7 @@ private async Task AttemptToProcessFile(string fileName) } } + [Obsolete] private async Task GetFile(string fileName) { try diff --git a/examples/Client/DistributedLock/Services/GeneratorService.cs b/examples/Client/DistributedLock/Services/GeneratorService.cs index 4d5c0a3ff..345ce2247 100644 --- a/examples/Client/DistributedLock/Services/GeneratorService.cs +++ b/examples/Client/DistributedLock/Services/GeneratorService.cs @@ -9,6 +9,7 @@ public class GeneratorService { Timer generateDataTimer; + [Obsolete] public GeneratorService() { // Generate some data every second. @@ -18,6 +19,7 @@ public GeneratorService() } } + [Obsolete] public async void GenerateData(Object stateInfo) { using (var client = new DaprClientBuilder().Build()) @@ -25,7 +27,8 @@ public async void GenerateData(Object stateInfo) var rand = new Random(); var state = new StateData(rand.Next(100)); + // NOTE: It is no longer best practice to use this method - this example will be modified in the 1.18 release await client.InvokeBindingAsync("localstorage", "create", state); } } -} \ No newline at end of file +} diff --git a/examples/Client/DistributedLock/Startup.cs b/examples/Client/DistributedLock/Startup.cs index 0e2e0df3a..daf9ee469 100644 --- a/examples/Client/DistributedLock/Startup.cs +++ b/examples/Client/DistributedLock/Startup.cs @@ -1,4 +1,4 @@ -using Dapr.AspNetCore; +using System; using DistributedLock.Services; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -18,6 +18,7 @@ public Startup(IConfiguration configuration) public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. + [Obsolete] public void ConfigureServices(IServiceCollection services) { services.AddControllers().AddDapr(); @@ -42,4 +43,4 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) endpoints.MapControllers(); }); } -} \ No newline at end of file +} diff --git a/src/Dapr.Client/DaprClient.cs b/src/Dapr.Client/DaprClient.cs index a988bd8c0..8929d2786 100644 --- a/src/Dapr.Client/DaprClient.cs +++ b/src/Dapr.Client/DaprClient.cs @@ -256,6 +256,7 @@ public abstract Task PublishByteEventAsync( /// A collection of metadata key-value pairs that will be provided to the binding. The valid metadata keys and values are determined by the type of binding used. /// A that can be used to cancel the operation. /// A that will complete when the operation has completed. + [Obsolete("Recommended guidance is to use a native HTTP or gRPC client for service invocation")] public abstract Task InvokeBindingAsync( string bindingName, string operation, @@ -274,6 +275,7 @@ public abstract Task InvokeBindingAsync( /// A collection of metadata key-value pairs that will be provided to the binding. The valid metadata keys and values are determined by the type of binding used. /// A that can be used to cancel the operation. /// A that will complete when the operation has completed. + [Obsolete("Recommended guidance is to use a native HTTP or gRPC client for service invocation")] public abstract Task InvokeBindingAsync( string bindingName, string operation, @@ -288,6 +290,7 @@ public abstract Task InvokeBindingAsync( /// The to send. /// A that can be used to cancel the operation. /// A that will complete when the operation has completed. + [Obsolete("Recommended guidance is to use a native HTTP or gRPC client for service invocation")] public abstract Task InvokeBindingAsync( BindingRequest request, CancellationToken cancellationToken = default); diff --git a/src/Dapr.Client/DaprClientGrpc.cs b/src/Dapr.Client/DaprClientGrpc.cs index 88ebeccc3..0cc5f796b 100644 --- a/src/Dapr.Client/DaprClientGrpc.cs +++ b/src/Dapr.Client/DaprClientGrpc.cs @@ -273,6 +273,7 @@ private async Task> MakeBulkPublishRequest( #region InvokeBinding Apis /// + [Obsolete("Recommended guidance is to use a native HTTP or gRPC client for service invocation")] public override async Task InvokeBindingAsync( string bindingName, string operation, @@ -288,6 +289,7 @@ public override async Task InvokeBindingAsync( } /// + [Obsolete("Recommended guidance is to use a native HTTP or gRPC client for service invocation")] public override async Task InvokeBindingAsync( string bindingName, string operation, @@ -313,6 +315,7 @@ public override async Task InvokeBindingAsync( } } + [Obsolete("Recommended guidance is to use a native HTTP or gRPC client for service invocation")] public override async Task InvokeBindingAsync(BindingRequest request, CancellationToken cancellationToken = default) { @@ -2283,7 +2286,7 @@ private CallOptions CreateCallOptions(Metadata headers, CancellationToken cancel { options.Headers.Add("User-Agent", UserAgent().ToString()); - // add token for dapr api token based authentication + // add token for dapr api token-based authentication if (this.apiTokenHeader is not null) { options.Headers.Add(this.apiTokenHeader.Value.Key, this.apiTokenHeader.Value.Value); diff --git a/test/Dapr.Client.Test/InvokeBindingApiTest.cs b/test/Dapr.Client.Test/InvokeBindingApiTest.cs index d721045d3..2e0b50253 100644 --- a/test/Dapr.Client.Test/InvokeBindingApiTest.cs +++ b/test/Dapr.Client.Test/InvokeBindingApiTest.cs @@ -11,6 +11,7 @@ // limitations under the License. // ------------------------------------------------------------------------ +#pragma warning disable CS0618 // Type or member is obsolete namespace Dapr.Client.Test; using System; @@ -308,4 +309,4 @@ private class Widget { public string Color { get; set; } } -} \ No newline at end of file +}