You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+7-3Lines changed: 7 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -238,9 +238,7 @@ end
238
238
239
239
##### Service Timers
240
240
241
-
You can introduce custom behavior into the service lifecycle on a timer. For example, check whether a team's trial has expired, or periodically cleanup data.
242
-
243
-
Note that unlike callbacks, timers are global for the entire service.
241
+
You can introduce custom behavior into the service lifecycle on a timer. For example, check whether a team's trial has expired, or periodically clean-up data. Timers can run once on start (`once_and_every`) and start running after a certain period (`every`).
244
242
245
243
```ruby
246
244
instance =SlackRubyBotServer::Service.instance
@@ -254,6 +252,10 @@ instance.every :hour do
254
252
end
255
253
end
256
254
255
+
instance.once_and_every :minutedo
256
+
# called once on start, then every minute
257
+
end
258
+
257
259
instance.every :minutedo
258
260
# called every minute
259
261
end
@@ -267,6 +269,8 @@ instance.every 30 do
267
269
end
268
270
```
269
271
272
+
Note that, unlike callbacks, timers are global for the entire service. Timers are independent, and a failing timer will not terminate other timers.
273
+
270
274
##### Extensions
271
275
272
276
A number of extensions use service manager callbacks and service timers to implement useful functionality.
0 commit comments