-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: include Alice and Bob sample (#80)
- Loading branch information
1 parent
593357f
commit ce25abd
Showing
14 changed files
with
274 additions
and
1 deletion.
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 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,43 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.31313.79 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{177DF5E9-4645-4A7D-8988-111DAEAE825D}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Alice", "src\Alice\Alice.csproj", "{E883F79F-001B-45A4-A9D3-881FF1746F79}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bob", "src\Bob\Bob.csproj", "{C7EAA8D2-234C-4519-9056-93E03894A0F0}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Perper.WebJobs.Extensions", "..\..\functions\runtime\src\Perper.WebJobs.Extensions\Perper.WebJobs.Extensions.csproj", "{1F470F1D-17B6-457C-92BB-B5B271A3ACED}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{E883F79F-001B-45A4-A9D3-881FF1746F79}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{E883F79F-001B-45A4-A9D3-881FF1746F79}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{E883F79F-001B-45A4-A9D3-881FF1746F79}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{E883F79F-001B-45A4-A9D3-881FF1746F79}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{C7EAA8D2-234C-4519-9056-93E03894A0F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{C7EAA8D2-234C-4519-9056-93E03894A0F0}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{C7EAA8D2-234C-4519-9056-93E03894A0F0}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{C7EAA8D2-234C-4519-9056-93E03894A0F0}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{1F470F1D-17B6-457C-92BB-B5B271A3ACED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{1F470F1D-17B6-457C-92BB-B5B271A3ACED}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{1F470F1D-17B6-457C-92BB-B5B271A3ACED}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{1F470F1D-17B6-457C-92BB-B5B271A3ACED}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(NestedProjects) = preSolution | ||
{E883F79F-001B-45A4-A9D3-881FF1746F79} = {177DF5E9-4645-4A7D-8988-111DAEAE825D} | ||
{C7EAA8D2-234C-4519-9056-93E03894A0F0} = {177DF5E9-4645-4A7D-8988-111DAEAE825D} | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {0E497321-8F18-458F-88E1-2C2AF584296A} | ||
EndGlobalSection | ||
EndGlobal |
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,27 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
<AzureFunctionsVersion>v3</AzureFunctionsVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" /> | ||
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.11" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\..\functions\runtime\src\Perper.WebJobs.Extensions\Perper.WebJobs.Extensions.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="host.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Update="local.settings.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
<CopyToPublishDirectory>Never</CopyToPublishDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
</Project> |
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,36 @@ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Microsoft.Azure.WebJobs; | ||
using Microsoft.Extensions.Logging; | ||
using Perper.WebJobs.Extensions.Model; | ||
using Perper.WebJobs.Extensions.Triggers; | ||
|
||
namespace Alice | ||
{ | ||
public class Launcher | ||
{ | ||
[FunctionName("Alice")] | ||
public static async Task RunAsync( | ||
[PerperTrigger] object input, | ||
IContext context, | ||
ILogger logger) | ||
{ | ||
const string agentName = "Bob"; | ||
const string callerAgentNameParameter = "Alice"; | ||
|
||
var (agent, greeting) = await context.StartAgentAsync<string>(agentName, callerAgentNameParameter); | ||
logger.LogInformation(greeting); | ||
|
||
var randomNumber = await agent.CallFunctionAsync<int>("GetRandomNumber", (0, 100)); | ||
logger.LogInformation(randomNumber.ToString()); | ||
|
||
await agent.CallActionAsync("SaveMagicNumber", randomNumber); | ||
|
||
var randomNumbersStream = await agent.CallFunctionAsync<IAsyncEnumerable<int>>("GetRandomNumbers", (0, 100)); | ||
await foreach (var number in randomNumbersStream) | ||
{ | ||
logger.LogInformation(number.ToString()); | ||
} | ||
} | ||
} | ||
} |
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,8 @@ | ||
{ | ||
"version": "2.0", | ||
"logging": { | ||
"logLevel": { | ||
"Perper.WebJobs.Extensions": "Trace" | ||
} | ||
} | ||
} |
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,9 @@ | ||
{ | ||
"IsEncrypted": false, | ||
"Values": { | ||
"AzureWebJobsStorage": "UseDevelopmentStorage=true", | ||
"FUNCTIONS_WORKER_RUNTIME": "dotnet", | ||
"PERPER_AGENT_NAME": "Alice", | ||
"PERPER_ROOT_AGENT": "Alice" | ||
} | ||
} |
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,27 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
<AzureFunctionsVersion>v3</AzureFunctionsVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" /> | ||
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.11" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\..\functions\runtime\src\Perper.WebJobs.Extensions\Perper.WebJobs.Extensions.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="host.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Update="local.settings.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
<CopyToPublishDirectory>Never</CopyToPublishDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
</Project> |
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 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Microsoft.Azure.WebJobs; | ||
using Perper.WebJobs.Extensions.Triggers; | ||
|
||
namespace Bob.Calls | ||
{ | ||
public class GetRandomNumber | ||
{ | ||
[FunctionName("GetRandomNumber")] | ||
public static async Task<int> RunAsync([PerperTrigger] (int min, int max) parameters) | ||
{ | ||
var random = new Random(); | ||
return random.Next(parameters.min, parameters.max); | ||
} | ||
} | ||
} |
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,31 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Microsoft.Azure.WebJobs; | ||
using Perper.WebJobs.Extensions.Model; | ||
using Perper.WebJobs.Extensions.Triggers; | ||
|
||
namespace Bob.Calls | ||
{ | ||
public class GetRandomNumbers | ||
{ | ||
[FunctionName("GetRandomNumbers")] | ||
public static async Task<IAsyncEnumerable<int>> RunAsync([PerperTrigger] (int min, int max) parameters, | ||
IContext context) | ||
{ | ||
return await context.StreamFunctionAsync<int>("GetRandomNumbersStream", parameters); | ||
} | ||
|
||
[FunctionName("GetRandomNumbersStream")] | ||
public static async IAsyncEnumerable<int> GetRandomNumbersStream([PerperTrigger] (int min, int max) parameters) | ||
{ | ||
var random = new Random(); | ||
|
||
while (true) | ||
{ | ||
yield return random.Next(parameters.min, parameters.max); | ||
await Task.Delay(1000); | ||
} | ||
} | ||
} | ||
} |
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,16 @@ | ||
using System.Threading.Tasks; | ||
using Microsoft.Azure.WebJobs; | ||
using Microsoft.Extensions.Logging; | ||
using Perper.WebJobs.Extensions.Triggers; | ||
|
||
namespace Bob.Calls | ||
{ | ||
public class SaveMagicNumber | ||
{ | ||
[FunctionName("SaveMagicNumber")] | ||
public static async Task RunAsync([PerperTrigger] int number, ILogger logger) | ||
{ | ||
logger.LogInformation(number.ToString()); | ||
} | ||
} | ||
} |
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,15 @@ | ||
using System.Threading.Tasks; | ||
using Microsoft.Azure.WebJobs; | ||
using Perper.WebJobs.Extensions.Triggers; | ||
|
||
namespace Bob | ||
{ | ||
public class Launcher | ||
{ | ||
[FunctionName("Bob")] | ||
public static async Task<string> RunAsync([PerperTrigger] string callerAgentName) | ||
{ | ||
return $"Hello {callerAgentName}"; | ||
} | ||
} | ||
} |
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,8 @@ | ||
{ | ||
"profiles": { | ||
"Bob": { | ||
"commandName": "Project", | ||
"commandLineArgs": "host start --port 7072 --pause-on-error" | ||
} | ||
} | ||
} |
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,8 @@ | ||
{ | ||
"version": "2.0", | ||
"logging": { | ||
"logLevel": { | ||
"Perper.WebJobs.Extensions": "Trace" | ||
} | ||
} | ||
} |
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,8 @@ | ||
{ | ||
"IsEncrypted": false, | ||
"Values": { | ||
"AzureWebJobsStorage": "UseDevelopmentStorage=true", | ||
"FUNCTIONS_WORKER_RUNTIME": "dotnet", | ||
"PERPER_AGENT_NAME": "Bob" | ||
} | ||
} |