brayan_lopez ~ zsh — -zsh
Hi all. I am

Brayan López

> Full-Stack Engineer
// complete a command to explore.
// try help, whois or projects in the terminal below
// account.go
func InitAccount(ctx context.Context, id string) (*Account, error) {
  acc := &Account{ID: id, Balance: 0}
  if err := store.Insert(ctx, acc); err != nil {
    return nil, fmt.Errorf("init: %w", err)
  }
  return acc, nil
}
// payment.go
func ProcessPayment(ctx context.Context, tx *Transaction) error {
  if tx.Amount <= 0 {
    return ErrInvalidAmount
  }
  acc, err := store.Lock(ctx, tx.AccountID)
  if err != nil {
    return fmt.Errorf("lock: %w", err)
  }
  acc.Balance -= tx.Amount
  return store.Commit(ctx, acc)
}
// worker.go
func RunWorkflow(ctx workflow.Context) error {
  opts := workflow.ActivityOptions{Timeout: 30 * time.Second}
  return workflow.ExecuteActivity(ctx, Settle).Get(ctx, nil)
}
brayan@portfolio:$
find me in: github linkedin x
Guatemala · UTC-6