### Quick Start with Express Source: https://github.com/arcenox-co/tickerq/blob/main/hub/sdks/node/README.md Initialize the SDK, register a function, and mount the Express handlers to start the service. ```ts import express from 'express'; import { TickerQSdk, TickerTaskPriority } from '@tickerq/sdk'; const app = express(); app.use(express.raw({ type: 'application/json' })); // 1. Initialize SDK const sdk = new TickerQSdk((opts) => opts .setApiKey('your-api-key') .setApiSecret('your-api-secret') .setCallbackUri('https://your-app.com') .setNodeName('my-node'), ); // 2. Register functions sdk.function('SendEmail', { priority: TickerTaskPriority.High }) .withRequest({ to: '', subject: '', body: '' }) .handle(async (ctx, signal) => { console.log(`Sending email to ${ctx.request.to}`); }); // 3. Mount endpoints & start sdk.expressHandlers().mount(app); await sdk.start(); app.listen(3000); ``` -------------------------------- ### Install TickerQ SDK Source: https://github.com/arcenox-co/tickerq/blob/main/hub/sdks/node/README.md Use npm to install the package in your Node.js project. ```bash npm install @tickerq/sdk ``` -------------------------------- ### Install project dependencies Source: https://github.com/arcenox-co/tickerq/blob/main/src/TickerQ.Dashboard/wwwroot/README.md Run this command to install all required project dependencies defined in package.json. ```sh npm install ``` -------------------------------- ### Start development server Source: https://github.com/arcenox-co/tickerq/blob/main/src/TickerQ.Dashboard/wwwroot/README.md Launches the Vite development server with hot-reload capabilities. ```sh npm run dev ``` -------------------------------- ### Add TickerQ.Utilities Package Source: https://github.com/arcenox-co/tickerq/blob/main/src/TickerQ.Utilities/README.md Install the TickerQ.Utilities package using the .NET CLI. ```bash dotnet add package TickerQ.Utilities ``` -------------------------------- ### Build TickerQ Project Source: https://github.com/arcenox-co/tickerq/blob/main/CONTRIBUTING.md Use this command to build the TickerQ solution. Ensure you have the .NET SDK installed. ```bash dotnet build src/src.sln ``` -------------------------------- ### Configure Logging Frameworks Source: https://github.com/arcenox-co/tickerq/blob/main/src/TickerQ.Instrumentation.OpenTelemetry/README.md Integration examples for Serilog and NLog using the standard .NET host builder. ```csharp builder.Host.UseSerilog((context, config) => { config.WriteTo.Console() .WriteTo.File("logs/tickerq-.txt", rollingInterval: RollingInterval.Day) .Enrich.FromLogContext(); }); ``` ```csharp builder.Logging.ClearProviders(); builder.Logging.AddNLog(); ``` -------------------------------- ### Add TickerQ.EntityFrameworkCore Package Source: https://github.com/arcenox-co/tickerq/blob/main/src/TickerQ.EntityFrameworkCore/README.md Install the TickerQ.EntityFrameworkCore NuGet package using the .NET CLI. ```bash dotnet add package TickerQ.EntityFrameworkCore ``` -------------------------------- ### Install TickerQ Package Source: https://github.com/arcenox-co/tickerq/blob/main/README.md Add the TickerQ NuGet package to your project using the .NET CLI. ```bash dotnet add package TickerQ ``` -------------------------------- ### Build Dashboard Project Source: https://github.com/arcenox-co/tickerq/blob/main/samples/TickerQ.Sample.WebApi/README.md Commands to install dependencies and build the dashboard project when encountering 404 errors. ```bash npm install ``` ```bash npm run build ``` -------------------------------- ### Manage SDK Lifecycle Source: https://github.com/arcenox-co/tickerq/blob/main/hub/sdks/node/README.md Control the SDK state with start, status checks, and graceful shutdown methods. ```ts // Start — freezes function registry, syncs with Hub await sdk.start(); // Check status console.log(sdk.isStarted); // Graceful shutdown — waits for running tasks to complete await sdk.stop(); // default 30s timeout await sdk.stop(60_000); // custom timeout ``` -------------------------------- ### Install TickerQ OpenTelemetry Package Source: https://github.com/arcenox-co/tickerq/blob/main/src/TickerQ.Instrumentation.OpenTelemetry/README.md Command to add the TickerQ OpenTelemetry instrumentation package to your .NET project using the dotnet CLI. ```bash dotnet add package TickerQ.Instrumentation.OpenTelemetry ``` -------------------------------- ### Custom Development Credentials Source: https://github.com/arcenox-co/tickerq/blob/main/src/TickerQ.Dashboard/wwwroot/src/config/README.md Example of how to change the default username and password in `auth.config.ts` for development. ```typescript credentials: { username: 'your-username', password: 'your-password' } ``` -------------------------------- ### View TickerQ Log Output Source: https://github.com/arcenox-co/tickerq/blob/main/src/TickerQ.Instrumentation.OpenTelemetry/README.md Example of structured log entries generated by TickerQ for job lifecycle events. ```text [INF] TickerQ Job enqueued: TimeTicker - ProcessEmails (123e4567-e89b-12d3-a456-426614174000) from ExecutionTaskHandler [INF] TickerQ Job completed: ProcessEmails (123e4567-e89b-12d3-a456-426614174000) in 1250ms - Success: True [ERR] TickerQ Job failed: ProcessEmails (123e4567-e89b-12d3-a456-426614174000) - Retry 1 - Connection timeout [INF] TickerQ Job completed: ProcessEmails (123e4567-e89b-12d3-a456-426614174000) in 2500ms - Success: False [WRN] TickerQ Job cancelled: ProcessEmails (123e4567-e89b-12d3-a456-426614174000) - Task was cancelled [INF] TickerQ Job skipped: ProcessEmails (123e4567-e89b-12d3-a456-426614174000) - Another CronOccurrence is already running! [INF] TickerQ start seeding data: TimeTicker (production-node-01) [INF] TickerQ completed seeding data: TimeTicker (production-node-01) ``` -------------------------------- ### Add TickerQ OpenTelemetry Instrumentation to Web App Source: https://github.com/arcenox-co/tickerq/blob/main/src/TickerQ.Instrumentation.OpenTelemetry/README.md Configure OpenTelemetry with the TickerQ ActivitySource and enable TickerQ's OpenTelemetry instrumentation. This setup is suitable for basic web application integration. ```csharp using TickerQ.Instrumentation.OpenTelemetry; using OpenTelemetry.Trace; var builder = WebApplication.CreateBuilder(args); // Configure OpenTelemetry with TickerQ ActivitySource builder.Services.AddOpenTelemetry() .WithTracing(tracing => { tracing.AddSource("TickerQ") // Add TickerQ ActivitySource .AddConsoleExporter() .AddJaegerExporter(); }); // Add TickerQ with OpenTelemetry instrumentation builder.Services.AddTickerQ(options => { }) .AddOperationalStore(ef => { }) .AddOpenTelemetryInstrumentation(); // 👈 Enable tracing var app = builder.Build(); app.Run(); ``` -------------------------------- ### Custom Validation Rules Source: https://github.com/arcenox-co/tickerq/blob/main/src/TickerQ.Dashboard/wwwroot/src/config/README.md Example of modifying the minimum length requirements for usernames and passwords. ```typescript validation: { minUsernameLength: 4, // Require 4+ characters minPasswordLength: 6 // Require 6+ characters } ``` -------------------------------- ### Custom Error Messages Source: https://github.com/arcenox-co/tickerq/blob/main/src/TickerQ.Dashboard/wwwroot/src/config/README.md Example of customizing specific error messages for authentication feedback. ```typescript messages: { invalidCredentials: 'Access denied. Please check your credentials.', // ... other messages } ``` -------------------------------- ### Production Authentication API Call Source: https://github.com/arcenox-co/tickerq/blob/main/src/TickerQ.Dashboard/wwwroot/src/config/README.md An example of a production-ready `validateCredentials` function that uses `fetch` to communicate with a backend API for authentication. It handles success and error responses, returning a token or an error message. ```typescript // Replace the validateCredentials function with: export async function validateCredentials(username: string, password: string) { try { const response = await fetch('/api/auth/login', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ username, password }) }) if (response.ok) { const data = await response.json() return { isValid: true, token: data.token } } else { return { isValid: false, error: 'Invalid credentials' } } } catch (error) { return { isValid: false, error: 'Authentication service unavailable' } } } ``` -------------------------------- ### Configure SDK Options Source: https://github.com/arcenox-co/tickerq/blob/main/hub/sdks/node/README.md Set required API credentials and optional settings like timeouts or TLS verification. ```ts const sdk = new TickerQSdk((opts) => opts .setApiKey('your-api-key') // Required — Hub API key .setApiSecret('your-api-secret') // Required — Hub API secret .setCallbackUri('https://...') // Required — URL where Hub sends execution callbacks .setNodeName('my-node') // Required — Unique node identifier .setTimeoutMs(30000) // Optional — HTTP timeout (default: 30s) .setAllowSelfSignedCerts(true), // Optional — Skip TLS verification (dev only) ); ``` -------------------------------- ### Build for production Source: https://github.com/arcenox-co/tickerq/blob/main/src/TickerQ.Dashboard/wwwroot/README.md Performs type-checking, compilation, and minification of the project assets for production deployment. ```sh npm run build ``` -------------------------------- ### Run TickerQ Tests Source: https://github.com/arcenox-co/tickerq/blob/main/CONTRIBUTING.md Execute this command to run all tests for the TickerQ project. This helps ensure code quality and functionality. ```bash dotnet test src/src.sln ``` -------------------------------- ### Register TickerQ Services Source: https://github.com/arcenox-co/tickerq/blob/main/README.md Configure TickerQ in your WebApplication builder and enable the middleware. ```csharp var builder = WebApplication.CreateBuilder(args); builder.Services.AddTickerQ(); var app = builder.Build(); app.UseTickerQ(); app.Run(); ``` -------------------------------- ### Use Host Authentication with Custom Policy Source: https://github.com/arcenox-co/tickerq/blob/main/src/TickerQ.Dashboard/README.md Integrate with your host application's authentication system and enforce a specific authorization policy. Replace 'AdminPolicy' with your actual policy name. ```csharp services.AddTickerQ(config => { config.AddDashboard(dashboard => { dashboard.WithHostAuthentication("AdminPolicy"); }); }); ``` -------------------------------- ### Use Host Application's Authentication Source: https://github.com/arcenox-co/tickerq/blob/main/src/TickerQ.Dashboard/README.md Delegate authentication to your host application's existing authentication system. This allows for centralized authentication management. ```csharp services.AddTickerQ(config => { config.AddDashboard(dashboard => { dashboard.WithHostAuthentication(); }); }); ``` -------------------------------- ### Update Entity Framework Migrations Source: https://github.com/arcenox-co/tickerq/blob/main/samples/TickerQ.Sample.WebApi/README.md Commands to add and apply database migrations within the WebApi project directory. ```bash dotnet ef migrations add ``` ```bash dotnet ef database update ``` -------------------------------- ### Basic Authentication Source: https://github.com/arcenox-co/tickerq/blob/main/src/TickerQ.Dashboard/README.md Enable username and password authentication for the dashboard. Ensure you use strong, unique credentials for security. ```csharp services.AddTickerQ(config => { config.AddDashboard(dashboard => { dashboard.WithBasicAuth("admin", "secret123"); }); }); ``` -------------------------------- ### Lint project files Source: https://github.com/arcenox-co/tickerq/blob/main/src/TickerQ.Dashboard/wwwroot/README.md Executes ESLint to identify and fix code style issues. ```sh npm run lint ``` -------------------------------- ### Define a TickerQ Job Source: https://github.com/arcenox-co/tickerq/blob/main/README.md Create a job by decorating a method with the TickerFunction attribute. ```csharp using TickerQ.Utilities.Base; public class MyJobs { [TickerFunction("HelloWorld")] public async Task HelloWorld( TickerFunctionContext context, CancellationToken cancellationToken) { Console.WriteLine($"Hello from TickerQ! Job ID: {context.Id}"); } } ``` -------------------------------- ### Configure Jaeger Exporter for OpenTelemetry Source: https://github.com/arcenox-co/tickerq/blob/main/src/TickerQ.Instrumentation.OpenTelemetry/README.md Set up the OpenTelemetry tracing to use the Jaeger exporter, specifying the endpoint for trace collection. This is useful for sending traces to a Jaeger instance. ```csharp builder.Services.AddOpenTelemetry() .WithTracing(tracing => { tracing.AddTickerQInstrumentation() .AddJaegerExporter(options => { options.Endpoint = new Uri("http://localhost:14268/api/traces"); }); }); ``` -------------------------------- ### Implement Custom Logger with TickerQ SDK Source: https://github.com/arcenox-co/tickerq/blob/main/hub/sdks/node/README.md Provides a custom logger implementation for the TickerQ SDK. Ensure your logger conforms to the TickerQLogger interface. ```typescript import type { TickerQLogger } from '@tickerq/sdk'; const logger: TickerQLogger = { info: (msg, ...args) => console.log(msg, ...args), warn: (msg, ...args) => console.warn(msg, ...args), error: (msg, ...args) => console.error(msg, ...args), }; const sdk = new TickerQSdk((opts) => opts .setApiKey('...') .setApiSecret('...') .setCallbackUri('...') .setNodeName('...'), logger, ); ``` -------------------------------- ### No Authentication (Public Dashboard) Source: https://github.com/arcenox-co/tickerq/blob/main/src/TickerQ.Dashboard/README.md Configure the dashboard to be publicly accessible by not setting any authentication methods. This is the default behavior if no authentication is explicitly configured. ```csharp services.AddTickerQ(config => { config.AddDashboard(dashboard => { // No authentication setup = public dashboard }); }); ``` -------------------------------- ### TickerQ Job Execution Activity Structure Source: https://github.com/arcenox-co/tickerq/blob/main/src/TickerQ.Instrumentation.OpenTelemetry/README.md Illustrates the hierarchy and types of activities generated during TickerQ job execution. These activities represent different stages of a job's lifecycle. ```text tickerq.job.execute.timeticker (main job execution span) ├── tickerq.job.enqueued (when job starts execution) ├── tickerq.job.completed (on successful completion) ├── tickerq.job.failed (on failure) ├── tickerq.job.cancelled (on cancellation) ├── tickerq.job.skipped (when skipped) ├── tickerq.seeding.started (for data seeding) └── tickerq.seeding.completed (seeding completion) ``` -------------------------------- ### Schedule a Job Source: https://github.com/arcenox-co/tickerq/blob/main/README.md Use the ITimeTickerManager to schedule a job for future execution. ```csharp public class MyService(ITimeTickerManager manager) { public async Task Schedule() { await manager.AddAsync(new TimeTickerEntity { Function = "HelloWorld", ExecutionTime = DateTime.UtcNow.AddSeconds(10) }); } } ``` -------------------------------- ### POST /execute Source: https://github.com/arcenox-co/tickerq/blob/main/hub/sdks/node/README.md Endpoint used by the TickerQ Hub to trigger function executions on the registered node. ```APIDOC ## POST /execute ### Description Receives function execution requests from the TickerQ Hub. ### Method POST ### Endpoint /execute ``` -------------------------------- ### POST /resync Source: https://github.com/arcenox-co/tickerq/blob/main/hub/sdks/node/README.md Endpoint used by the TickerQ Hub to synchronize the function registry of the node. ```APIDOC ## POST /resync ### Description Re-syncs the local function registry with the TickerQ Hub. ### Method POST ### Endpoint /resync ``` -------------------------------- ### Default Development Credentials Source: https://github.com/arcenox-co/tickerq/blob/main/src/TickerQ.Dashboard/wwwroot/src/config/README.md Sets the default username and password for development and testing purposes. These should not be used in production. ```typescript credentials: { username: 'admin', password: 'admin' } ``` -------------------------------- ### API Key Authentication Source: https://github.com/arcenox-co/tickerq/blob/main/src/TickerQ.Dashboard/README.md Secure the dashboard using a single API key. This is useful for programmatic access or when a simple secret is preferred over username/password. ```csharp services.AddTickerQ(config => { config.AddDashboard(dashboard => { dashboard.WithApiKey("my-secret-api-key-12345"); }); }); ``` -------------------------------- ### Configure Azure Monitor Trace Exporter for OpenTelemetry Source: https://github.com/arcenox-co/tickerq/blob/main/src/TickerQ.Instrumentation.OpenTelemetry/README.md Configure OpenTelemetry tracing to use the Azure Monitor trace exporter. This is suitable for sending traces to Azure Application Insights. ```csharp builder.Services.AddOpenTelemetry() .WithTracing(tracing => { tracing.AddTickerQInstrumentation() .AddAzureMonitorTraceExporter(); }); ``` -------------------------------- ### Default Validation Rules Source: https://github.com/arcenox-co/tickerq/blob/main/src/TickerQ.Dashboard/wwwroot/src/config/README.md Defines the minimum length requirements for usernames and passwords during development. ```typescript validation: { minUsernameLength: 3, minPasswordLength: 1 } ``` -------------------------------- ### Register Functions with Different Request Types Source: https://github.com/arcenox-co/tickerq/blob/main/hub/sdks/node/README.md Functions can be registered with typed requests, no requests, or primitive request types. ```ts sdk.function('ProcessOrder', { priority: TickerTaskPriority.High, maxConcurrency: 3, requestType: 'OrderRequest', }) .withRequest({ orderId: 0, customerId: '', items: [''], total: 0 }) .handle(async (ctx, signal) => { ctx.request.orderId; // number ctx.request.customerId; // string ctx.request.items; // string[] }); ``` ```ts sdk.function('DatabaseCleanup', { cronExpression: '0 0 3 * * *', priority: TickerTaskPriority.LongRunning, }) .handle(async (ctx, signal) => { console.log(`Running cleanup for ${ctx.functionName}`); }); ``` ```ts sdk.function('ResizeImage') .withRequest('default-url') .handle(async (ctx, signal) => { console.log(ctx.request); // string }); ``` -------------------------------- ### Mount HTTP Endpoints Source: https://github.com/arcenox-co/tickerq/blob/main/hub/sdks/node/README.md Expose endpoints for the Hub to communicate with your application using Express or raw Node.js HTTP. ```ts sdk.expressHandlers().mount(app); // Or with a prefix sdk.expressHandlers('/tickerq').mount(app); ``` ```ts import { createServer } from 'node:http'; const handler = sdk.createHandler(); const server = createServer(handler); server.listen(3000); ``` -------------------------------- ### Access Handler Context Source: https://github.com/arcenox-co/tickerq/blob/main/hub/sdks/node/README.md Retrieve execution metadata and request data within a function handler. ```ts sdk.function('MyJob') .handle(async (ctx, signal) => { ctx.id; // string — unique execution ID ctx.functionName; // string — registered function name ctx.type; // TickerType — TimeTicker or CronTickerOccurrence ctx.retryCount; // number — current retry attempt ctx.scheduledFor; // Date — when this execution was scheduled ctx.isDue; // boolean // Use signal for cancellation if (signal.aborted) return; }); ``` ```ts sdk.function('SendEmail') .withRequest({ to: '', subject: '' }) .handle(async (ctx, signal) => { ctx.request.to; // string — fully typed ctx.request.subject; // string }); ``` -------------------------------- ### Default Error Messages Source: https://github.com/arcenox-co/tickerq/blob/main/src/TickerQ.Dashboard/wwwroot/src/config/README.md Provides default error messages for various authentication scenarios. ```typescript messages: { invalidCredentials: 'Invalid credentials. Please try again.', loginFailed: 'Login failed. Please try again.', usernameRequired: 'Username is required', passwordRequired: 'Password is required', usernameTooShort: 'Username must be at least 3 characters', passwordTooShort: 'Password must be at least 1 character' } ``` -------------------------------- ### Dedicated OpenAPI Group Source: https://github.com/arcenox-co/tickerq/blob/main/src/TickerQ.Dashboard/README.md Assign a specific group name for the dashboard's OpenAPI endpoints. This helps organize API documentation, especially in larger projects. ```csharp services.AddTickerQ(config => { config.AddDashboard(dashboard => { dashboard.SetGroupName("tickerq"); }); }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.