Closed harisgen79 closed 5 years ago
ObjectBox Go currently only works in embedded mode, where there is no separate database server. Therefore, a program requires unique access to the database (files).
From what I understand about your situation, you have two options:
Your best bet would be for each program to have its own database. If you really need one, you can have a simple service with both databases, providing an API to the other programs.
In the future, you could use ObjectBox Sync to solve this situation (if you would be fine with asynchronous data propagation between the clients) but that's not readily available yet.
There might be a third option: merge program1 and program2 into one. If both programs should access both databases, what is the motivation to separate them? Asking to understand your use case better...
Program1 performs as an RFID card scanner which means it should respond quickly which is the motivation to separate them. Program2 also does POST and GET methods every interval (few hours or so, haven't defined it yet). When it does GET it receives data of 1500+ employees which takes a long time. If it was all in one program, RFID reader would not be responding while doing GET so I had to separate them, otherwise there might be a queue of employees getting angry because the device is not responding instantly.
@harisgen79 ObjectBox uses a multi version concurrency model, where a reader (read transactions; usually sufficient for a typical GET) never blocks a writer.
OK then, I'll figure something out then. Thank you for the answers. Cheers.
Also, you can run the employee update job "in the background" as another goroutine, see https://golang.org/pkg/time/#example_NewTicker - that means you can have it all in the single application while not blocking the RFID scanner functionality
I made exactly that, works fine, thanks for the advice.
Glad it worked. Closing the issue.
Hello,
I am making an embedded system on Raspberry Pi 3 where I'm keeping track of arrivals of employees to work. I have two databases, one to store data about arrivals (RFID, time of arrival, etc.) and other to store general data about employees. Additionally, I also want to send data to cloud. For that purpose I have made two Golang programs, let's call them program1 for managing database of arrivals and program2 for database of employees. Is it possible to make these programs access both databases and make changes. If yes, how and in which situations?