Featurewise

Featurewise for .NET

A library for writing a service featurewise, in C#. Every feature has the same shape: a query, a command or a worker, taking a link and returning a result with cases. And the code that calls features has one way to call any of them.

dotnet add package Featurewise.Core --prerelease       # in the service's core
dotnet add package Featurewise.Hosting --prerelease    # in each entrypoint

A feature

public class CancelSend(IOutbox outbox) : Command<CancelSend.Args, CancelSend.Result>
{
    public record Args(string MessageId) : Link<CancelSend, Result>;

    public abstract record Result
    {
        private Result() { }

        public record Cancelled(Messages.Args LinkToMessages) : Result;
        public record AlreadySent(Messages.Args LinkToMessages) : Result;
    }

    public override async Task<Result> Invoke(Args args, CancellationToken cancellationToken)
    {
        if (await outbox.Find(args.MessageId, cancellationToken) is not { Status: MessageStatus.Queued } message)
            return new Result.AlreadySent(new Messages.Args());

        await outbox.Save(message with { Status = MessageStatus.Cancelled }, cancellationToken);
        return new Result.Cancelled(new Messages.Args());
    }
}

CancelSend.Args is the feature's input, and it's a link: a value naming the feature, with its arguments. Each result case says what happened, in words the stakeholders would recognise, and carries the links to what the caller can do next.

What it gives you

Getting started

The sample service is a minimal featurewise service, on AWS Lambda and runnable on a laptop: the place to start a new one. The demos are services built the same way, running live.