MethodContainerizer 1.0.0

dotnet add package MethodContainerizer --version 1.0.0                
NuGet\Install-Package MethodContainerizer -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MethodContainerizer" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MethodContainerizer --version 1.0.0                
#r "nuget: MethodContainerizer, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MethodContainerizer as a Cake Addin
#addin nuget:?package=MethodContainerizer&version=1.0.0

// Install MethodContainerizer as a Cake Tool
#tool nuget:?package=MethodContainerizer&version=1.0.0                

Method Containerizer

A library for automatically scaling a codebase by dynamically replacing class methods with containerized APIs during runtime.

Prerequisites

Currently requires Docker to be running on the machine running your application. In the future, I plan to support remote docker instances and Kubernetes clusters.

Usage

Add MethodContainerizer and MethodContainerizer.Docker to your project.

Example Startup.cs:
services
    .AddSingleton<SomeComplexJob>()
    .ContainerizeMethod<SomeComplexJob>(x => x.Start(default), 1)
    .UseDockerOrchestration()
    .BuildContainers();

If you would like to make sure all containers are terminated when the host closes, add the following:

app.TerminateMethodContainersOnExit();

How it works

When you mark a method to be containerized, a lot happens behind the scenes.

  1. A new "shallow assembly" is dynamically generated containing the marked method and only the direct dependencies needed for that method to function properly. This means, while this library does work by creating assemblies based off of the master application, these assemblies are small, build quickly, and run fast. There is no bloat from other actions happening within the application.
  2. A dynamic ASP.NET Core project is generated containing Program.cs with a main method, and a single HTTP Post controller endpoint
  3. A docker image is built with the aforementioned API project and shallow assembly inside
  4. A container is built and started containing the isolated method environment
  5. The original method is replaced with a proxy method which calls the respective API

Future Plans

  • Add support for building of Dockerfiles remotely
  • Docker Swarm
  • Kubernetes
  • Load monitoring / Multiple instances
  • Analytics / Monitoring
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on MethodContainerizer:

Package Downloads
MethodContainerizer.Docker

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 420 10/27/2021