Giter VIP home page Giter VIP logo

cleanarchitecture.workerservice's Introduction

CleanArchitecture.WorkerService

A solution template using Clean Architecture for building a .NET 7.0 Worker Service.

Give a Star! โญ

If you like or are using this project to learn or start your solution, please give it a star. Thanks!

Credits

Big thanks to all of the great contributors to this project!

Build Status

.NET Core

Getting Started

Clone or download the repository.

Install the ef core cli tools dotnet tool install --global dotnet-ef. If you already have an old version, first try dotnet tool update --global dotnet-ef --version 6.0.0-*, if that doesn't work, see Updating Ef Core Cli First, delete C:\Users{yourUser}.dotnet\tools.store\dotnet-ef tool.

This app is currently configured to run against a localdb SQL Server instance. To initialized the database, you will need to run this command in the /src/CleanArchitecture.Worker folder:

dotnet ef database update -c appdbcontext -p ../CleanArchitecture.Infrastructure/CleanArchitecture.Infrastructure.csproj -s CleanArchitecture.Worker.csproj

Check the connection string in appsettings.json in the CleanArchitecture.Worker project to verify its details if you have problems.

Open the solution in Visual Studio and run it with ctrl-F5 (the CleanArchitecture.Worker project should be the startup project) or in the console go to the src/CleanArchitecture.Worker folder and run dotnet run.

On startup the app queues up 10 URLs to hit (google.com) and you should see it make 10 requests and save them to the database and then do nothing, logging each second.

Using this for your own worker service

To use this as a template for your own worker server projects, make the following changes:

  • Rename CleanArchitecture to YourAppName or YourCompany.YourAppName
  • Configure the connection string to your database if you're using one
  • Replace InMemory queue implementations with Azure, AWS, Rabbit, etc. actual queues you're using
  • Remove UrlStatusHistory and related services and interfaces

References

Useful Pluralsight courses:

cleanarchitecture.workerservice's People

Contributors

aligneddev avatar angelodotnet avatar ardalis avatar dependabot-preview[bot] avatar kylemcmaster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cleanarchitecture.workerservice's Issues

How to use a DbContext service in the Worker Template

I want to know how to use a dbcontext in this clean architecture worker service, because dbcontext is a scoped service and this will be a singleton.
I know that I need to use the Services.CreateScope thing, but the challenge is which project should it go? In the worker project? Core? or Infrastructure? and how?

For an ongoing project I'm creating a scope in Worker project, but I need to pass the scope service as a parameter, and that doesn't seem me right.

Need an example of Faking IServiceScopeFactory and testing in ExecuteAsync

In the existing EntryPointServiceExecute test, null is passed into the new EntryPointService(.....).

How do I fake IServiceScopeFactory, so that I can test pieces inside of the using in ExecuteAsync of EntryPointService?

using (var scope = _serviceScopeFactory.CreateScope())
{
  // test my code here...

.NET 8 and C#12 Updates

  • Update Target Framework to net8.0
  • Use C# 12 features as applicable (primary constructors mostly)

Add Support For FastEndpoints

We already have support for Minimal API results so it would be awesome to see what work is needed to also support FastEndpoints like we do for Controllers/APIEndpoints. If any code is needed it could probably be added to the AspNetCore package unless we would like to add an Ardalis.Result.FastEndpoints package

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.