Skip to content

Instantly share code, notes, and snippets.

# .configure_aws_template.sh
rand=$(xxd -l 4 -c 4 -p < /dev/random);
sed -i 's/XXXX/'${rand}'/g' template.yaml;
# ----------------------------------------------------- #
# template.yaml
CARBN_ENV_DBSchemaLambdaFunctionTriggerXXXX:
# .circleci/.configure_aws_template.sh
payment_processing_server_ip=$([ $1 = "prod" ] && echo "54.90.113.155" || echo "18.170.1.160");
sed -i 's/CARBN_PAYMENT_PROCESSING_SERVER_IP_ADDRESS/'${payment_processing_server_ip}'/g' template.yaml;
# ----------------------------------------------------- #
# template.yaml
CARBN_ENV_PaymentProcessingAPI:
import XCTest
import FaultOrderingTests
@MainActor
func testExample() throws {
let app = XCUIApplication()
let test = FaultOrderingTest { app in
app.launch()
}
test.testApp(testCase: self, app: app)
actor DependencyResolver {
private var completedSteps: [LaunchStep.Type] = []
private var pendingSteps: [LaunchStep] = []
init(steps: [LaunchStep]) {
self.pendingSteps = steps
}
func getAndClaimNextAvailableStep() -> LaunchStep? {
// Find all steps whose dependencies are satisfied
private func runWorker(id: Int, resolver: DependencyResolver) async {
while await !resolver.allStepsComplete() {
if let step = await resolver.getAndClaimNextAvailableStep() {
executeStep(step)
await resolver.markStepComplete(type(of: step))
} else {
try? await Task.sleep(for: .milliseconds(5))
}
}
}
private func executeMainThreadStepsInParallel() async {
let mainSteps: [LaunchStep] = [
AppConfigStep(),
LoggingConfigurationStep(),
NetworkMonitoringStep(),
SecureStorageStep(),
UserDefaultsStep(),
AudioSessionStep(),
CrashReportingStep(),
DatabaseSchemaStep(),
protocol LaunchStep {
var name: String { get }
var dependencies: [LaunchStep.Type] { get }
var priority: LaunchPriority { get }
func execute() // Synchronous, blocking execution
}
// ...
private func executeMainThreadStepsInParallel() async {
let mainSteps: [LaunchStep] = [
AppConfigStep(),
LoggingConfigurationStep(),
SecureStorageStep(),
UserDefaultsStep(),
CrashReportingStep(),
DatabaseSchemaStep(),
FeatureFlagsStep(),
PersistenceStep(),
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
let group = DispatchGroup()
group.enter()
Task.detached(priority: .high) {
await LaunchOrchestrator.shared.executeCriticalLaunchPath()
group.leave()
@main
final class AppDelegate: UIResponder, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
LaunchOrchestrator.shared.executeCriticalLaunchPath()
DispatchQueue.global(qos: .utility).async {