Skip to content

Commit 1bf3fbd

Browse files
fix: pre-hotreload cartridge support
`crud` module is cartridge-independent in nature, but provides cartridge roles which are the most popular way to setup the module. The roles also not use any modern cartridge features and should work with any cartridge version. But since crud.cfg was introduced [1], it was required to add some code for roles reload [2] proper support. Now cartridge.hotreload module is unconditionally required, so roles cannot be used with cartridge older than 2.4.0. This patch fixes the behavior. 1. 6da4f56 2. tarantool/cartridge@941952e Follows #244
1 parent bd39ec8 commit 1bf3fbd

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased]
9+
10+
### Fixed
11+
* Pre-hotreload `cartridge` support (older than 2.4.0) (PR #341).
12+
813
## [1.0.0] - 02-02-23
914

1015
### Added

crud/common/stash.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
-- @module crud.common.stash
33
--
44
local dev_checks = require('crud.common.dev_checks')
5+
local utils = require('crud.common.utils')
56

67
local stash = {}
78

@@ -37,7 +38,11 @@ stash.name = {
3738
-- @return Returns
3839
--
3940
function stash.setup_cartridge_reload()
40-
local hotreload = require('cartridge.hotreload')
41+
local hotreload_supported, hotreload = utils.is_cartridge_hotreload_supported()
42+
if not hotreload_supported then
43+
return
44+
end
45+
4146
for _, name in pairs(stash.name) do
4247
hotreload.whitelist_globals({ name })
4348
end

crud/common/utils.lua

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ local bit = require('bit')
66
local log = require('log')
77

88
local is_cartridge, cartridge = pcall(require, 'cartridge')
9+
local is_cartridge_hotreload, cartridge_hotreload = pcall(require, 'cartridge.hotreload')
910

1011
local const = require('crud.common.const')
1112
local schema = require('crud.common.schema')
@@ -963,4 +964,19 @@ function utils.get_vshard_router_instance(router)
963964
return router_instance
964965
end
965966

967+
--- Check if Tarantool Cartridge hotreload supported
968+
-- and get its implementaion.
969+
--
970+
-- @function is_cartridge_hotreload_supported
971+
--
972+
-- @return[1] true or false
973+
-- @return[1] module table, if supported
974+
function utils.is_cartridge_hotreload_supported()
975+
if not is_cartridge_hotreload then
976+
return false
977+
end
978+
979+
return true, cartridge_hotreload
980+
end
981+
966982
return utils

0 commit comments

Comments
 (0)