Table of Contents

Class FireflyAbstractionsExtensions

Namespace
Phoesion.Glow.SDK.Firefly
Assembly
Phoesion.Glow.SDK.Firefly.Abstractions.dll
public static class FireflyAbstractionsExtensions
Inheritance
object
FireflyAbstractionsExtensions

Methods

Accepted(IActionContext)

public static void Accepted(this IActionContext ctx)

Parameters

ctx IActionContext

Accepted<T>(IActionContext, T)

public static T Accepted<T>(this IActionContext ctx, T response)

Parameters

ctx IActionContext
response T

Returns

T

Type Parameters

T

AddAppJobWorker<TWorker>(IServiceCollection, GlowAppScope)

Add an AppJob worker.

public static IAppJobWorkerBuilder AddAppJobWorker<TWorker>(this IServiceCollection services, GlowAppScope scope = GlowAppScope.Service) where TWorker : class, IAppJobWorker

Parameters

services IServiceCollection
scope GlowAppScope

Returns

IAppJobWorkerBuilder

Type Parameters

TWorker

AddAppJobWorker<TWorker>(IServiceCollection, string, GlowAppScope)

Add an AppJob worker.

public static IAppJobWorkerBuilder AddAppJobWorker<TWorker>(this IServiceCollection services, string queue, GlowAppScope scope = GlowAppScope.Service) where TWorker : class, IAppJobWorker

Parameters

services IServiceCollection
queue string
scope GlowAppScope

Returns

IAppJobWorkerBuilder

Type Parameters

TWorker

AddAppJobWorker<TWorker, TJob>(IServiceCollection, GlowAppScope)

Add an AppJob worker.

public static IAppJobWorkerBuilder AddAppJobWorker<TWorker, TJob>(this IServiceCollection services, GlowAppScope scope = GlowAppScope.Service) where TWorker : class, IAppJobWorker<TJob>

Parameters

services IServiceCollection
scope GlowAppScope

Returns

IAppJobWorkerBuilder

Type Parameters

TWorker
TJob

AddAppStateMachineWorker<TWorker>(IServiceCollection, GlowAppScope)

Add an AppStateMachine worker.

public static IAppStateMachineWorkerBuilder AddAppStateMachineWorker<TWorker>(this IServiceCollection services, GlowAppScope scope = GlowAppScope.Service) where TWorker : class, IAppStateMachineWorker

Parameters

services IServiceCollection
scope GlowAppScope

Returns

IAppStateMachineWorkerBuilder

Type Parameters

TWorker

AddAppStateMachineWorker<TWorker>(IServiceCollection, string, GlowAppScope)

Add an AppStateMachine worker.

public static IAppStateMachineWorkerBuilder AddAppStateMachineWorker<TWorker>(this IServiceCollection services, string queue, GlowAppScope scope = GlowAppScope.Service) where TWorker : class, IAppStateMachineWorker

Parameters

services IServiceCollection
queue string
scope GlowAppScope

Returns

IAppStateMachineWorkerBuilder

Type Parameters

TWorker

AddAppStateMachineWorker<TWorker, TStateMachine>(IServiceCollection, GlowAppScope)

Add an AppStateMachine worker.

public static IAppStateMachineWorkerBuilder AddAppStateMachineWorker<TWorker, TStateMachine>(this IServiceCollection services, GlowAppScope scope = GlowAppScope.Service) where TWorker : class, IAppStateMachineWorker<TStateMachine> where TStateMachine : struct, Enum

Parameters

services IServiceCollection
scope GlowAppScope

Returns

IAppStateMachineWorkerBuilder

Type Parameters

TWorker
TStateMachine

AddBackgroundWorker<THostedWorker>(IServiceCollection, bool)

Add a hosted background worker service. It can also be registered as a singleton, so it can be injected to other classes.

public static IServiceCollection AddBackgroundWorker<THostedWorker>(this IServiceCollection services, bool AddSingleton = true) where THostedWorker : FireflyBackgroundWorker

Parameters

services IServiceCollection
AddSingleton bool

Returns

IServiceCollection

Type Parameters

THostedWorker

AddBackgroundWorker<THostedWorker>(IServiceCollection, THostedWorker, bool)

Add a hosted background worker service instance to services. It can also be registered as a singleton, so it can be injected to other classes.

public static IServiceCollection AddBackgroundWorker<THostedWorker>(this IServiceCollection services, THostedWorker instance, bool AddSingleton = true) where THostedWorker : FireflyBackgroundWorker

Parameters

services IServiceCollection
instance THostedWorker
AddSingleton bool

Returns

IServiceCollection

Type Parameters

THostedWorker

AddInteropMessagePackResolver(IServiceCollection, IFormatterResolver)

public static IServiceCollection AddInteropMessagePackResolver(this IServiceCollection services, IFormatterResolver resolver)

Parameters

services IServiceCollection
resolver IFormatterResolver

Returns

IServiceCollection

AddSingletonHostedService<THostedService>(IServiceCollection)

Add a hosted service and register it a singleton, so it can be injected to other classes

public static IServiceCollection AddSingletonHostedService<THostedService>(this IServiceCollection services) where THostedService : class, IHostedService

Parameters

services IServiceCollection

Returns

IServiceCollection

Type Parameters

THostedService

AddSingletonHostedService<THostedService>(IServiceCollection, THostedService)

Add a hosted service and register it a singleton, so it can be injected to other classes

public static IServiceCollection AddSingletonHostedService<THostedService>(this IServiceCollection services, THostedService instance) where THostedService : class, IHostedService

Parameters

services IServiceCollection
instance THostedService

Returns

IServiceCollection

Type Parameters

THostedService

AddSingletonHostedService<TService, THostedService>(IServiceCollection)

Add a hosted service and register it a singleton, so it can be injected to other classes

public static IServiceCollection AddSingletonHostedService<TService, THostedService>(this IServiceCollection services) where TService : class where THostedService : class, TService, IHostedService

Parameters

services IServiceCollection

Returns

IServiceCollection

Type Parameters

TService
THostedService

AddSingletonHostedService<TService, THostedService>(IServiceCollection, THostedService)

Add a hosted service and register it a singleton, so it can be injected to other classes

public static IServiceCollection AddSingletonHostedService<TService, THostedService>(this IServiceCollection services, THostedService instance) where TService : class where THostedService : class, TService, IHostedService

Parameters

services IServiceCollection
instance THostedService

Returns

IServiceCollection

Type Parameters

TService
THostedService

BadGateway(IActionContext)

public static void BadGateway(this IActionContext ctx)

Parameters

ctx IActionContext

BadGateway(IActionContext, ProblemDetails)

public static void BadGateway(this IActionContext ctx, ProblemDetails problem)

Parameters

ctx IActionContext
problem ProblemDetails

BadGateway<T>(IActionContext, T)

public static T BadGateway<T>(this IActionContext ctx, T response)

Parameters

ctx IActionContext
response T

Returns

T

Type Parameters

T

BadRequest(IActionContext)

public static void BadRequest(this IActionContext ctx)

Parameters

ctx IActionContext

BadRequest(IActionContext, ProblemDetails)

public static void BadRequest(this IActionContext ctx, ProblemDetails problem)

Parameters

ctx IActionContext
problem ProblemDetails

BadRequest<T>(IActionContext, T)

public static T BadRequest<T>(this IActionContext ctx, T response)

Parameters

ctx IActionContext
response T

Returns

T

Type Parameters

T

ExpectationFailed(IActionContext)

public static void ExpectationFailed(this IActionContext ctx)

Parameters

ctx IActionContext

ExpectationFailed(IActionContext, ProblemDetails)

public static void ExpectationFailed(this IActionContext ctx, ProblemDetails problem)

Parameters

ctx IActionContext
problem ProblemDetails

ExpectationFailed<T>(IActionContext, T)

public static T ExpectationFailed<T>(this IActionContext ctx, T response)

Parameters

ctx IActionContext
response T

Returns

T

Type Parameters

T

Forbidden(IActionContext)

public static void Forbidden(this IActionContext ctx)

Parameters

ctx IActionContext

Forbidden(IActionContext, ProblemDetails)

public static void Forbidden(this IActionContext ctx, ProblemDetails problem)

Parameters

ctx IActionContext
problem ProblemDetails

Forbidden<T>(IActionContext, T)

public static T Forbidden<T>(this IActionContext ctx, T response)

Parameters

ctx IActionContext
response T

Returns

T

Type Parameters

T

GetAssemblyQualifiedKey(MethodInfo)

public static string GetAssemblyQualifiedKey(this MethodInfo m)

Parameters

m MethodInfo

Returns

string

GetMemberType(MemberInfo)

public static Type? GetMemberType(this MemberInfo mi)

Parameters

mi MemberInfo

Returns

Type

GetValue(MemberInfo?, object?)

public static object? GetValue(this MemberInfo? mi, object? Instance)

Parameters

mi MemberInfo
Instance object

Returns

object

InternalServerError(IActionContext)

public static void InternalServerError(this IActionContext ctx)

Parameters

ctx IActionContext

InternalServerError(IActionContext, ProblemDetails)

public static void InternalServerError(this IActionContext ctx, ProblemDetails problem)

Parameters

ctx IActionContext
problem ProblemDetails

InternalServerError<T>(IActionContext, T)

public static T InternalServerError<T>(this IActionContext ctx, T response)

Parameters

ctx IActionContext
response T

Returns

T

Type Parameters

T

IsReadable(MemberInfo)

public static bool IsReadable(this MemberInfo mi)

Parameters

mi MemberInfo

Returns

bool

IsStatic(MemberInfo?)

public static bool IsStatic(this MemberInfo? mi)

Parameters

mi MemberInfo

Returns

bool

IsWriteable(MemberInfo)

public static bool IsWriteable(this MemberInfo mi)

Parameters

mi MemberInfo

Returns

bool

NotAcceptable(IActionContext)

public static void NotAcceptable(this IActionContext ctx)

Parameters

ctx IActionContext

NotAcceptable(IActionContext, ProblemDetails)

public static void NotAcceptable(this IActionContext ctx, ProblemDetails problem)

Parameters

ctx IActionContext
problem ProblemDetails

NotAcceptable<T>(IActionContext, T)

public static T NotAcceptable<T>(this IActionContext ctx, T response)

Parameters

ctx IActionContext
response T

Returns

T

Type Parameters

T

NotFound(IActionContext)

public static void NotFound(this IActionContext ctx)

Parameters

ctx IActionContext

NotFound(IActionContext, ProblemDetails)

public static void NotFound(this IActionContext ctx, ProblemDetails problem)

Parameters

ctx IActionContext
problem ProblemDetails

NotFound<T>(IActionContext, T)

public static T NotFound<T>(this IActionContext ctx, T response)

Parameters

ctx IActionContext
response T

Returns

T

Type Parameters

T

NotImplemented(IActionContext)

public static void NotImplemented(this IActionContext ctx)

Parameters

ctx IActionContext

NotImplemented(IActionContext, ProblemDetails)

public static void NotImplemented(this IActionContext ctx, ProblemDetails problem)

Parameters

ctx IActionContext
problem ProblemDetails

NotImplemented<T>(IActionContext, T)

public static T NotImplemented<T>(this IActionContext ctx, T response)

Parameters

ctx IActionContext
response T

Returns

T

Type Parameters

T

OK(IActionContext)

public static void OK(this IActionContext ctx)

Parameters

ctx IActionContext

OK<T>(IActionContext, T)

public static T OK<T>(this IActionContext ctx, T response)

Parameters

ctx IActionContext
response T

Returns

T

Type Parameters

T

SetRayAppUserEmail(ILogger, string)

Tag the ray with an application user email string, that can used later for filtering logs.

public static void SetRayAppUserEmail(this ILogger logger, string email)

Parameters

logger ILogger
email string

SetRayAppUserId(ILogger, string)

Tag the ray with an application user id string, that can used later for filtering logs.

public static void SetRayAppUserId(this ILogger logger, string id)

Parameters

logger ILogger
id string

SetRayAppUserName(ILogger, string)

Tag the ray with an application user name string, that can used later for filtering logs.

public static void SetRayAppUserName(this ILogger logger, string username)

Parameters

logger ILogger
username string

SetRayTag(ILogger, string)

Tag the ray with a user-defined string, that can used later for filtering logs.

public static void SetRayTag(this ILogger logger, string tag)

Parameters

logger ILogger
tag string

SetValue(MemberInfo?, object?, object?)

public static bool SetValue(this MemberInfo? mi, object? Instance, object? Value)

Parameters

mi MemberInfo
Instance object
Value object

Returns

bool

SingleGlobalConsumer(IAppJobWorkerBuilder)

When enabled, only ONE service instance in the entire Quantum-Space will consume jobs.

public static IAppJobWorkerBuilder SingleGlobalConsumer(this IAppJobWorkerBuilder builder)

Parameters

builder IAppJobWorkerBuilder

Returns

IAppJobWorkerBuilder

SingleGlobalConsumer(IAppJobWorkerBuilder, bool)

When enabled, only ONE service instance in the entire Quantum-Space will consume jobs.

public static IAppJobWorkerBuilder SingleGlobalConsumer(this IAppJobWorkerBuilder builder, bool isSingleton)

Parameters

builder IAppJobWorkerBuilder
isSingleton bool

Enable Global Quantum-Space singleton

Returns

IAppJobWorkerBuilder

SingleGlobalConsumer(IAppStateMachineWorkerBuilder)

When enabled, only ONE service instance in the entire Quantum-Space will consume state-machine jobs.

public static IAppStateMachineWorkerBuilder SingleGlobalConsumer(this IAppStateMachineWorkerBuilder builder)

Parameters

builder IAppStateMachineWorkerBuilder

Returns

IAppStateMachineWorkerBuilder

SingleGlobalConsumer(IAppStateMachineWorkerBuilder, bool)

When enabled, only ONE service instance in the entire Quantum-Space will consume state-machine jobs.

public static IAppStateMachineWorkerBuilder SingleGlobalConsumer(this IAppStateMachineWorkerBuilder builder, bool isSingleton)

Parameters

builder IAppStateMachineWorkerBuilder
isSingleton bool

Enable Global Quantum-Space singleton

Returns

IAppStateMachineWorkerBuilder

Unauthorized(IActionContext)

public static void Unauthorized(this IActionContext ctx)

Parameters

ctx IActionContext

Unauthorized(IActionContext, ProblemDetails)

public static void Unauthorized(this IActionContext ctx, ProblemDetails problem)

Parameters

ctx IActionContext
problem ProblemDetails

Unauthorized<T>(IActionContext, T)

public static T Unauthorized<T>(this IActionContext ctx, T response)

Parameters

ctx IActionContext
response T

Returns

T

Type Parameters

T

When(IAppJobWorkerBuilder, WorkerRunAsyncPredicateDelegate)

User-defined condition to control whether worker is allowed to request and run a new Job

public static IAppJobWorkerBuilder When(this IAppJobWorkerBuilder builder, WorkerRunAsyncPredicateDelegate predicate)

Parameters

builder IAppJobWorkerBuilder
predicate WorkerRunAsyncPredicateDelegate

Check whether worker is allowed to process a new job

Returns

IAppJobWorkerBuilder

When(IAppJobWorkerBuilder, WorkerRunPredicateDelegate)

User-defined condition to control whether worker is allowed to request and run a new Job

public static IAppJobWorkerBuilder When(this IAppJobWorkerBuilder builder, WorkerRunPredicateDelegate predicate)

Parameters

builder IAppJobWorkerBuilder
predicate WorkerRunPredicateDelegate

Check whether worker is allowed to process a new job

Returns

IAppJobWorkerBuilder

WithController(IAppJobWorkerBuilder, IAppJobWorkerController)

Control worker behavior from user code

public static IAppJobWorkerBuilder WithController(this IAppJobWorkerBuilder builder, IAppJobWorkerController controller)

Parameters

builder IAppJobWorkerBuilder
controller IAppJobWorkerController

The controller

Returns

IAppJobWorkerBuilder

WithController(IAppStateMachineWorkerBuilder, IAppStateMachineWorkerController)

Control worker behavior from user code

public static IAppStateMachineWorkerBuilder WithController(this IAppStateMachineWorkerBuilder builder, IAppStateMachineWorkerController controller)

Parameters

builder IAppStateMachineWorkerBuilder
controller IAppStateMachineWorkerController

The controller

Returns

IAppStateMachineWorkerBuilder

WithParallelism(IAppJobWorkerBuilder, int)

Set Parallelism for job processing. Default is Environment.ProcessorCount * 5 This configures local parallelism for each service instance.

public static IAppJobWorkerBuilder WithParallelism(this IAppJobWorkerBuilder builder, int parallelism)

Parameters

builder IAppJobWorkerBuilder
parallelism int

The number of worker to run in parallel

Returns

IAppJobWorkerBuilder

WithParallelism(IAppStateMachineWorkerBuilder, int)

Set Parallelism for state-machine processing. Default is Environment.ProcessorCount * 5 This configures local parallelism for each service instance.

public static IAppStateMachineWorkerBuilder WithParallelism(this IAppStateMachineWorkerBuilder builder, int parallelism)

Parameters

builder IAppStateMachineWorkerBuilder
parallelism int

The number of worker to run in parallel

Returns

IAppStateMachineWorkerBuilder

WithProblem(IActionContext, HttpStatusCode, ProblemDetails)

public static void WithProblem(this IActionContext ctx, HttpStatusCode code, ProblemDetails problem)

Parameters

ctx IActionContext
code HttpStatusCode
problem ProblemDetails

WithRateLimitter(IAppJobWorkerBuilder, RateLimiter)

Rate-limit job processing.

public static IAppJobWorkerBuilder WithRateLimitter(this IAppJobWorkerBuilder builder, RateLimiter rateLimiter)

Parameters

builder IAppJobWorkerBuilder
rateLimiter RateLimiter

The rate-limiter

Returns

IAppJobWorkerBuilder

WithRateLimitter(IAppStateMachineWorkerBuilder, RateLimiter)

Rate-limit state-machine processing.

public static IAppStateMachineWorkerBuilder WithRateLimitter(this IAppStateMachineWorkerBuilder builder, RateLimiter rateLimiter)

Parameters

builder IAppStateMachineWorkerBuilder
rateLimiter RateLimiter

The rate-limiter

Returns

IAppStateMachineWorkerBuilder

WithScope(IAppJobWorkerBuilder, GlowAppScope)

Set scope.

public static IAppJobWorkerBuilder WithScope(this IAppJobWorkerBuilder builder, GlowAppScope scope)

Parameters

builder IAppJobWorkerBuilder
scope GlowAppScope

The scope of the queue.

  • QuantumSpace scope means the queue is shared with other services in the same QuantumSpace.
  • Service scope means this queue is only visible to other instances of the same service.

Returns

IAppJobWorkerBuilder

WithScope(IAppStateMachineWorkerBuilder, GlowAppScope)

Set scope.

public static IAppStateMachineWorkerBuilder WithScope(this IAppStateMachineWorkerBuilder builder, GlowAppScope scope)

Parameters

builder IAppStateMachineWorkerBuilder
scope GlowAppScope

The scope of the queue.

  • QuantumSpace scope means the queue is shared with other services in the same QuantumSpace.
  • Service scope means this queue is only visible to other instances of the same service.

Returns

IAppStateMachineWorkerBuilder

WithStatusCode(IActionContext, HttpStatusCode)

public static void WithStatusCode(this IActionContext ctx, HttpStatusCode code)

Parameters

ctx IActionContext
code HttpStatusCode

WithStatusCode<T>(IActionContext, HttpStatusCode, T)

public static T WithStatusCode<T>(this IActionContext ctx, HttpStatusCode code, T response)

Parameters

ctx IActionContext
code HttpStatusCode
response T

Returns

T

Type Parameters

T