Add F# worker service template (#22042)

This commit is contained in:
Phillip Carter 2020-07-01 15:51:45 -07:00 committed by GitHub
parent 6c7c3b8772
commit a722c4cd7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 316 additions and 0 deletions

View File

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.Worker">
<PropertyGroup>
<TargetFramework>${DefaultNetCoreTargetFramework}</TargetFramework>
<UserSecretsId>dotnet-Company.Application1-53bc9b9d-9d6a-45d4-8429-2a2761773502</UserSecretsId>
<NoDefaultLaunchSettingsFile Condition="'$(ExcludeLaunchSettings)' == 'True'">True</NoDefaultLaunchSettingsFile>
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">Company.Application1</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="Worker.fs" />
<Compile Include="Program.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="${MicrosoftExtensionsHostingPackageVersion}" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,7 @@
{
"version": "1.0.0.0",
"strings": {
"name": "Služba pracovního procesu",
"description": "Šablona prázdného projektu pro vytvoření služby pracovního procesu"
}
}

View File

@ -0,0 +1,7 @@
{
"version": "1.0.0.0",
"strings": {
"name": "Workerdienst",
"description": "Eine leere Projektvorlage zum Erstellen eines Workerdiensts."
}
}

View File

@ -0,0 +1,19 @@
{
"$schema": "http://json.schemastore.org/dotnetcli.host",
"symbolInfo": {
"Framework": {
"longName": "framework"
},
"skipRestore": {
"longName": "no-restore",
"shortName": ""
},
"ExcludeLaunchSettings": {
"longName": "exclude-launch-settings",
"shortName": ""
}
},
"usageExamples": [
""
]
}

View File

@ -0,0 +1,7 @@
{
"version": "1.0.0.0",
"strings": {
"name": "Worker Service",
"description": "An empty project template for creating a worker service."
}
}

View File

@ -0,0 +1,7 @@
{
"version": "1.0.0.0",
"strings": {
"name": "Servicio de trabajo",
"description": "Una plantilla de proyecto vacío para crear un servicio de trabajo."
}
}

View File

@ -0,0 +1,7 @@
{
"version": "1.0.0.0",
"strings": {
"name": "Service Worker",
"description": "Modèle de projet vide pour la création d'un service Worker."
}
}

View File

@ -0,0 +1,7 @@
{
"version": "1.0.0.0",
"strings": {
"name": "Servizio di ruolo di lavoro",
"description": "Modello di progetto vuoto per la creazione di servizio del ruolo di lavoro."
}
}

View File

@ -0,0 +1,7 @@
{
"version": "1.0.0.0",
"strings": {
"name": "ワーカー サービス",
"description": "ワーカー サービスを作成するための空のプロジェクト テンプレート。"
}
}

View File

@ -0,0 +1,7 @@
{
"version": "1.0.0.0",
"strings": {
"name": "작업자 서비스",
"description": "작업자 서비스를 만들기 위한 빈 프로젝트의 템플릿입니다."
}
}

View File

@ -0,0 +1,7 @@
{
"version": "1.0.0.0",
"strings": {
"name": "Usługa procesu roboczego",
"description": "Szablon pustego projektu służący do tworzenia usługi procesu roboczego."
}
}

View File

@ -0,0 +1,7 @@
{
"version": "1.0.0.0",
"strings": {
"name": "Serviço de Trabalho",
"description": "Um modelo de projeto vazio para criar um serviço de trabalho."
}
}

View File

@ -0,0 +1,7 @@
{
"version": "1.0.0.0",
"strings": {
"name": "Служба рабочих ролей",
"description": "Шаблон пустого проекта для создания службы рабочих ролей."
}
}

View File

@ -0,0 +1,91 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "Microsoft",
"classifications": [
"Common",
"Worker",
"Web"
],
"name": "Worker Service",
"generatorVersions": "[1.0.0.0-*)",
"description": "An empty project template for creating a worker service.",
"groupIdentity": "Microsoft.Worker.Empty",
"precedence": "7000",
"identity": "Microsoft.Worker.Empty.FSharp.5.0",
"shortName": "worker",
"tags": {
"language": "F#",
"type": "project"
},
"sourceName": "Company.Application1",
"preferNameDirectory": true,
"guids": [
"53bc9b9d-9d6a-45d4-8429-2a2761773502"
],
"sources": [
{
"modifiers": [
{
"condition": "(ExcludeLaunchSettings)",
"exclude": [
"Properties/launchSettings.json"
]
}
]
}
],
"symbols": {
"ExcludeLaunchSettings": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "false",
"description": "Whether to exclude launchSettings.json from the generated template."
},
"Framework": {
"type": "parameter",
"description": "The target framework for the project.",
"datatype": "choice",
"choices": [
{
"choice": "net5.0",
"description": "Target net5.0"
}
],
"replaces": "net5.0",
"defaultValue": "net5.0"
},
"copyrightYear": {
"type": "generated",
"generator": "now",
"replaces": "copyrightYear",
"parameters": {
"format": "yyyy"
}
},
"skipRestore": {
"type": "parameter",
"datatype": "bool",
"description": "If specified, skips the automatic restore of the project on create.",
"defaultValue": "false"
}
},
"primaryOutputs": [
{
"path": "Company.Application1.fsproj"
}
],
"defaultName": "WorkerService",
"postActions": [
{
"condition": "(!skipRestore)",
"description": "Restore NuGet packages required by this project.",
"manualInstructions": [
{
"text": "Run 'dotnet restore'"
}
],
"actionId": "210D431B-A78B-4D2F-B762-4ED3E3EA9025",
"continueOnError": true
}
]
}

View File

@ -0,0 +1,7 @@
{
"version": "1.0.0.0",
"strings": {
"name": "Çalışan Hizmeti",
"description": "Çalışan hizmeti oluşturmaya yönelik bir boş proje şablonu."
}
}

View File

@ -0,0 +1,20 @@
{
"$schema": "http://json.schemastore.org/vs-2017.3.host",
"name": {
"text": "Worker Service",
"package": "{0CD94836-1526-4E85-87D3-FB5274C5AFC9}",
"id": "1025"
},
"description": {
"text": "An empty project template for creating a worker service.",
"package": "{0CD94836-1526-4E85-87D3-FB5274C5AFC9}",
"id": "1026"
},
"order": 300,
"icon": "vs-2017.3/Worker.png",
"learnMoreLink": "https://go.microsoft.com/fwlink/?linkid=2072778",
"uiFilters": [ "oneaspnet" ],
"supportsDocker": true,
"excludeLaunchSettings": false,
"minFullFrameworkVersion": "4.6.1"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 B

View File

@ -0,0 +1,7 @@
{
"version": "1.0.0.0",
"strings": {
"name": "辅助角色服务",
"description": "用于创建辅助角色服务的空项目模板。"
}
}

View File

@ -0,0 +1,7 @@
{
"version": "1.0.0.0",
"strings": {
"name": "背景工作服務",
"description": "用於建立背景工作服務的空白專案範本。"
}
}

View File

@ -0,0 +1,20 @@
namespace Company.Application1
open System
open System.Collections.Generic
open System.Linq
open System.Threading.Tasks
open Microsoft.Extensions.DependencyInjection
open Microsoft.Extensions.Hosting
module Program =
let createHostBuilder args =
Host.CreateDefaultBuilder(args)
.ConfigureServices(fun hostContext services ->
services.AddHostedService<Worker>() |> ignore)
[<EntryPoint>]
let main args =
createHostBuilder(args).Build().Run()
0 // exit code

View File

@ -0,0 +1,10 @@
{
"profiles": {
"Company.Application1": {
"commandName": "Project",
"environmentVariables": {
"DOTNET_ENVIRONMENT": "Development"
}
}
}
}

View File

@ -0,0 +1,21 @@
namespace Company.Application1
open System
open System.Collections.Generic
open System.Linq
open System.Threading
open System.Threading.Tasks
open Microsoft.Extensions.Hosting
open Microsoft.Extensions.Logging
type Worker(logger: ILogger<Worker>) =
inherit BackgroundService()
override _.ExecuteAsync(ct: CancellationToken) =
async {
while not ct.IsCancellationRequested do
logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now)
do! Async.Sleep(1000)
}
|> Async.StartAsTask
:> Task // need to convert into the parameter-less task

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}