I hereby claim:
- I am fjeldstad on github.
- I am hihaj (https://keybase.io/hihaj) on keybase.
- I have a public key ASBYXxk2CnVB20Dx1bfMa6nTXJhQG-OJbplVRb9zFm7zkQo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
#investering
I hereby claim:
To claim this, I am signing this object:
| const service, { sendCommand, query, publishEvent } = require('microservice'); | |
| const accountSuspensionService = service('account-suspension'); | |
| accountSuspensionService.onCommand('suspend-account', async function (command) { | |
| const { id, reason } = command.payload; | |
| const account = await query('get-account-by-id', { id }); | |
| if (account.status !== 'active') { | |
| throw new Error(`Suspending an account requires status 'active', was instead '${account.status}'.`); | |
| } |
| <!doctype html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>hello-choo</title> | |
| </head> | |
| <body> | |
| <script src="static/bundle.js"></script> | |
| </body> | |
| </html> |
| const trimmed = problematicString.replace(/[\x00-\x09\x0B-\x0C\x0E-\x1F\x7F-\x9F]/g, ''); |
| public abstract class Saga<TState> where TState : class | |
| { | |
| private const int MaxMessageHandlingRetryAttemptsPerMessage = 3; | |
| private const int MillisecondsBetweenMessageHandlingAttempts = 500; | |
| private readonly List<Func<IBus, string, Task>> _registrations = new List<Func<IBus, string, Task>>(); | |
| protected void When<TMessage>( | |
| Func<TMessage, Task<IMemory>> accessMemory, | |
| Func<TMessage, TState, Task<ITransformResult>> transform) where TMessage : class |
| public class CustomerRevenueSaga : Saga<CustomerRevenue> | |
| { | |
| public CustomerRevenueSaga(ICustomerRevenueStore store) | |
| { | |
| When<OrderPlaced>( | |
| accessMemory: async msg => new Memory(await store.GetByCustomerId(msg.CustomerId), store.Save), | |
| transform: (msg, state) => | |
| { | |
| var nextState = state?.Clone() ?? new CustomerRevenue { CustomerId = msg.CustomerId }; | |
| nextState.PendingOrderAmounts[msg.Id] = msg.Amount; |
| public class CustomerRevenueNode : | |
| Node<CustomerRevenueNode.State>, | |
| Node<CustomerRevenueNode.State>.IHandle<OrderPlaced>, | |
| Node<CustomerRevenueNode.State>.IHandle<OrderCancelled>, | |
| Node<CustomerRevenueNode.State>.IHandle<OrderDelivered> | |
| { | |
| public class State | |
| { | |
| public Guid CustomerId { get; set; } | |
| public decimal AggregatedRevenue { get; set; } |
| public interface INode | |
| { | |
| } | |
| public interface IMessageToPublish | |
| { | |
| object Message { get; } | |
| TimeSpan? Delay { get; } | |
| } |