Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example Fluent-SQLite iOS #67

Closed
0xLeif opened this issue Jul 15, 2020 · 2 comments
Closed

Example Fluent-SQLite iOS #67

0xLeif opened this issue Jul 15, 2020 · 2 comments
Labels
question Further information is requested
Projects

Comments

@0xLeif
Copy link

0xLeif commented Jul 15, 2020

FLite is aim to be used with iOS to save data using SQLite.

Vapor 3 is supported and working in the master branch.

Vapor 4 has the iOS test passing, but fails on an actual iOS project.

FLite 0.2.0 is using Vapor 4

I am getting this error on an iOS project

Fatal error: Unexpected error while running SelectableEventLoop: kqueue(): Too many open files (errno: 24).: file /Users/cri/Library/Developer/Xcode/DerivedData/test-gsikgwqyfpktaldxljjiybotjrwo/SourcePackages/checkouts/swift-nio/Sources/NIO/EventLoop.swift, line 828
2020-07-08 16:59:03.742934-0500 test[94438:1326247] Fatal error: Unexpected error while running SelectableEventLoop: kqueue(): Too many open files (errno: 24).: file /Users/cri/Library/Developer/Xcode/DerivedData/test-gsikgwqyfpktaldxljjiybotjrwo/SourcePackages/checkouts/swift-nio/Sources/NIO/EventLoop.swift, line 828

Here is the example iOS project code

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        let semaphore = DispatchSemaphore(value: 0)
        var values = [Todo]()
        
        try? FLite.prepare(migration: Todo.self).wait()
        
        try! FLite.add(model: Todo(title: "Hello World", strings: ["hello", "world"])).wait()
        
        FLite.fetch(model: Todo.self)
            .whenSuccess { (todos) in
                values = todos
                semaphore.signal()
        }
        
        semaphore.wait()
        
        print("Values: \(values)")
    }
}
@tanner0101
Copy link
Member

tanner0101 commented Jul 15, 2020

Hi @0xLeif. My guess is the problem is here: https://github.com/0xLeif/FLite/blob/develop/Sources/FLite/FLite.swift#L30. For maximum concurrency, set the number of threads to System.coreCount. Since NIO is non-blocking, no more than that is needed.

@tanner0101 tanner0101 added the question Further information is requested label Jul 15, 2020
@tanner0101 tanner0101 added this to To Do in Vapor 4 via automation Jul 15, 2020
@0xLeif
Copy link
Author

0xLeif commented Jul 15, 2020

@tanner0101 Awesome that was it! Thanks!!

Values: [Todo id: Optional(1C8E9B2E-33CD-42CC-9FCB-9D557801AA3B)
    title: Hello World
    someList: ["hello", "world"]]

@0xLeif 0xLeif closed this as completed Jul 15, 2020
Vapor 4 automation moved this from To Do to Done Jul 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
Vapor 4
  
Done
Development

No branches or pull requests

2 participants