Any tips on how one might be able to schedule a nakama function call from the server, like a cron job or something like that? The application would be for sending scheduled notifications to some or all clients.
For the specific use case you mention (scheduled notifications) it’s usually managed via a separate mobile engagement service which you talk to over a REST API (something like Leanplum, One Signal, and others are good for this use case).
There’s a way to kick off background tasks in the Go server runtime with just the standard library timer package. In Lua we don’t have a special API for it right now because we recommend for performance reasons to process data for users on their interaction with the server rather than as a background job which would have to scan the entire player base out of the database to perform some processing logic.
Maybe this is just a basic question, but just for making sure…
Is it ok to pass these parameters to a goroutine
func ScheduledJob(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule)
At the “InitModule” time? Otherwise How do I perform access to the database?
Yes, it’s safe to pass those parameters to a separate goroutine when