---
# System prepended metadata

title: Engineering Topics 1

---

# Engineering Topics 1

# sda-core, sda-db

sda-core Jobs:
* when a Job fails, next invocation should happen after a configured interval, now it is invoked right away which spams the logs
* when Jobs module is being stopped, Jobs with long intervals prevent it from shutting down for up to the longest interval. 
  This makes long (> 1 min) Job intervals unfeasible.
* each Job invocation should start a new logging/tracing context
  
sda-db #find_by_and_lock!():
* what is the expected functionality?


```ruby
wallet = wallets_repo.find_by_and_lock!(
  id: id,
  state: "ACTIVE"
)

wallet # => ?
```

# Shared RSpec examples

```ruby
# spec_helper.rb

require "sda-messaging/rspec"
require "sda-core/rspec"

```

# Error handling 

```ruby
      def call
        # something happens here and raises an error
      rescue StandardError => e
        raise Core::Error(e).with(
          "#{self} failed",
          params.to_h
        )
        # => Core::Error
        # "Actions::Wallets::Create failed: String is expected as ID (ArgumentError)"
        # params: { id: "asd", ...},
        # backtrace: ...
        #
      end

```


```ruby
  while 
    job.run
  rescue => e
    logger.error e
  end
```

