Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is this SDK for Javascript? No Async/Await #116

Open
GiddyNaya opened this issue Aug 27, 2020 · 2 comments
Open

Is this SDK for Javascript? No Async/Await #116

GiddyNaya opened this issue Aug 27, 2020 · 2 comments

Comments

@GiddyNaya
Copy link

There is literally no Async/Await interface for operations. This definitely kills the whole essence of having an SDK for netcore.
Individual methods with Begin... End... (What is this?) It really makes no sense!

It's only in Java or Javascript we have the need to pass callbacks to methods. In C# netcore we use Async/Await, hence when a task is completed it returns the expected result and we make use of it, not the other way round.

We really need the team to build the interfaces like it was meant for C# developers. Thank you.

This is wrong (Begin... & End...)

        /// <inheritdoc/>
        public IAsyncResult BeginCopyObject(CopyObjectRequest copyObjectRequst, AsyncCallback callback, Object state)
        {
            ThrowIfNullRequest(copyObjectRequst);

            var cmd = CopyObjectCommand.Create(_serviceClient, _endpoint,
                                              CreateContext(HttpMethod.Put, copyObjectRequst.DestinationBucketName, copyObjectRequst.DestinationKey),
                                              copyObjectRequst);
            return OssUtils.BeginOperationHelper(cmd, callback, state);
        }

        /// <inheritdoc/>
        public CopyObjectResult EndCopyResult(IAsyncResult asyncResult)
        {
            return OssUtils.EndOperationHelper<CopyObjectResult>(_serviceClient, asyncResult);
        }

This is what we expect (Async/Await)

        /// <inheritdoc/>
        public async Task<CopyObjectResult> CopyObjectAsync(CopyObjectRequest copyObjectRequst)
        {
            ThrowIfNullRequest(copyObjectRequst);

            var cmd = CopyObjectCommand.Create(_serviceClient, _endpoint,
                                              CreateContext(HttpMethod.Put, copyObjectRequst.DestinationBucketName, copyObjectRequst.DestinationKey),
                                              copyObjectRequst);
            return await OssUtils.ProccessCommandAsync<CopyObjectResult>(cmd);
        }
@LeaFrock
Copy link

You can follow this repo. The underlying layer uses HttpClient so the surface APIs are async.

You can search AlibabaCloud.SDK.Oss20190517 on Nuget。

@kyo8598CC
Copy link

连个async/await都没有 还是回调的异步 真的搞笑

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants