Skip to content

Commit d757190

Browse files
committed
feat(driver_manager): implicitly call on_update
if on_load is not defined
1 parent 594f025 commit d757190

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

shard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: placeos-driver
2-
version: 7.2.18
2+
version: 7.3.0
33

44
dependencies:
55
action-controller:

src/placeos-driver/driver_manager.cr

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,21 +85,25 @@ class PlaceOS::Driver::DriverManager
8585
# we don't want to block driver init processing too long
8686
# a driver might be making a HTTP request in on_load for exampe which
8787
# could block for a long time, resulting in poor feedback
88-
if driver.responds_to?(:on_load)
88+
if driver.responds_to?(:on_load) || driver.responds_to?(:on_update)
8989
wait_on_load = Channel(Nil).new
9090
spawn(same_thread: true) do
9191
begin
92-
driver.on_load
92+
if driver.responds_to?(:on_load)
93+
driver.on_load
94+
elsif driver.responds_to?(:on_update)
95+
driver.on_update
96+
end
9397
rescue error
94-
logger.error(exception: error) { "in the on_load function of #{driver.class} (#{@module_id})" }
98+
logger.error(exception: error) { "initializing #{driver.class} (#{@module_id})" }
9599
end
96100
wait_on_load.send nil
97101
end
98102

99103
select
100104
when wait_on_load.receive
101105
when timeout(6.seconds)
102-
logger.error { "timeout waiting for the on_load function of #{driver.class} (#{@module_id})" }
106+
logger.error { "timeout initializing #{driver.class} (#{@module_id})" }
103107
end
104108

105109
wait_on_load.close

0 commit comments

Comments
 (0)