forked from Azure/iotedge
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update functions binding to 2.0 model (Azure#201)
- Loading branch information
1 parent
1ab956a
commit 1bc69d1
Showing
43 changed files
with
1,574 additions
and
262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
edge-modules/functions/binding/docker/linux/arm32v7/Dockerfile
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
edge-modules/functions/binding/docker/windows/amd64/Dockerfile
This file was deleted.
Oops, something went wrong.
49 changes: 0 additions & 49 deletions
49
...c/Microsoft.Azure.Devices.Edge.Functions.Binding/config/EdgeHubExtensionConfigProvider.cs
This file was deleted.
Oops, something went wrong.
32 changes: 0 additions & 32 deletions
32
.../src/Microsoft.Azure.Devices.Edge.Functions.Binding/config/EdgeHubHostConfigExtensions.cs
This file was deleted.
Oops, something went wrong.
62 changes: 62 additions & 0 deletions
62
edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/AsyncLock.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
namespace Microsoft.Azure.WebJobs.Extensions.EdgeHub | ||
{ | ||
// | ||
// Code ported from http://blogs.msdn.com/b/pfxteam/archive/2012/02/12/10266988.aspx | ||
// | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
sealed class AsyncLock : IDisposable | ||
{ | ||
readonly Task<Releaser> releaser; | ||
readonly SemaphoreSlim semaphore; | ||
|
||
public AsyncLock() | ||
: this(1) | ||
{ | ||
} | ||
|
||
public AsyncLock(int maximumConcurrency) | ||
{ | ||
this.releaser = Task.FromResult(new Releaser(this)); | ||
this.semaphore = new SemaphoreSlim(maximumConcurrency, maximumConcurrency); | ||
} | ||
|
||
public Task<Releaser> LockAsync() => this.LockAsync(CancellationToken.None); | ||
|
||
public Task<Releaser> LockAsync(CancellationToken token) | ||
{ | ||
Task wait = this.semaphore.WaitAsync(token); | ||
return wait.Status == TaskStatus.RanToCompletion ? this.releaser : | ||
wait.ContinueWith((_, state) => new Releaser((AsyncLock)state), | ||
this, CancellationToken.None, | ||
TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.OnlyOnRanToCompletion, TaskScheduler.Default); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public void Dispose() => this.semaphore.Dispose(); | ||
|
||
public struct Releaser : IDisposable | ||
{ | ||
readonly AsyncLock toRelease; | ||
int disposed; | ||
|
||
public Releaser(AsyncLock toRelease) | ||
{ | ||
this.toRelease = toRelease ?? throw new ArgumentNullException(nameof(toRelease)); | ||
this.disposed = 0; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
if (0 == Interlocked.Exchange(ref this.disposed, 1)) | ||
{ | ||
this.toRelease.semaphore.Release(); | ||
} | ||
} | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...unctions.Binding/EdgeHubAsyncCollector.cs → ...tensions.EdgeHub/EdgeHubAsyncCollector.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
...dge.Functions.Binding/EdgeHubAttribute.cs → ...bs.Extensions.EdgeHub/EdgeHubAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
namespace Microsoft.Azure.Devices.Edge.Functions.Binding | ||
namespace Microsoft.Azure.WebJobs.Extensions.EdgeHub | ||
{ | ||
using System; | ||
using Microsoft.Azure.WebJobs.Description; | ||
|
||
[Binding] | ||
[AttributeUsage(AttributeTargets.Parameter)] | ||
public class EdgeHubAttribute : Attribute | ||
{ | ||
public string OutputName { get; set; } | ||
|
||
public int BatchSize { get; set; } | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...ctions.Binding/EdgeHubTriggerAttribute.cs → ...nsions.EdgeHub/EdgeHubTriggerAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/EdgeHubWebJobsStartup.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
using Microsoft.Azure.WebJobs.Extensions.EdgeHub; | ||
using Microsoft.Azure.WebJobs.Hosting; | ||
|
||
[assembly: WebJobsStartup(typeof(EdgeHubWebJobsStartup))] | ||
|
||
namespace Microsoft.Azure.WebJobs.Extensions.EdgeHub | ||
{ | ||
using Microsoft.Azure.WebJobs.Extensions.EdgeHub.Config; | ||
using Microsoft.Azure.WebJobs.Hosting; | ||
|
||
public class EdgeHubWebJobsStartup : IWebJobsStartup | ||
{ | ||
public void Configure(IWebJobsBuilder builder) => builder.AddEdge(); | ||
} | ||
} |
Oops, something went wrong.