Swift - Background worker

时间:2019-01-15 18:10:23

标签: swift server-side

I have a server-side application written in Swift and Vapor 3. I have implemented a couple of metrics for my application and I want to send them to statsD. I was thinking about the background worker that keeps persistent socket connection to statsD server. The application passes metrics to background worker and worker is responsible for gathering and sending data to server.

It would be nice if worker could gather metrics and send them only every couple of seconds.

Is it a good idea? How can I spawn a new thread on application startup and how do I communicate between main process and a worker process?

0 个答案:

没有答案