Skip to content

Commit daef0aa

Browse files
committed
require: Add support to force reload a library
1 parent 486aa90 commit daef0aa

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/require.q

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,31 @@
7373
/ @see .require.i.load
7474
/ @see .require.i.init
7575
.require.lib:{[lib]
76+
operations:`load`init;
77+
7678
if[lib in key .require.loadedLibs;
77-
$[.require.loadedLibs[lib]`inited;
79+
if[.require.loadedLibs[lib]`inited;
7880
:(::);
79-
:.require.i.init lib
8081
];
82+
83+
operations:operations except `load;
84+
];
85+
86+
.require.i[operations] @\: lib;
87+
};
88+
89+
/ Loads the sepcified library and initialises it regardless of the current loaded and initialised state
90+
/ This should be used for reloading a stateless library without having to restart the kdb process
91+
/ @see .require.i.load
92+
/ @see .require.i.init
93+
.require.libForce:{[lib]
94+
if[lib in key .require.loadedLibs;
95+
libInfo:.require.loadedLibs;
96+
97+
.log.if.info ("Force reloading library [ Library: {} ] [ Already Loaded: {} ] [ Already Initialised: {} ]"; lib; `no`yes libInfo`loaded; `no`yes libInfo`inited);
8198
];
8299

83-
(.require.i.load;.require.i.init)@\:lib;
100+
.require.i[`load`init] @\: lib;
84101
};
85102

86103
.require.rescanRoot:{

0 commit comments

Comments
 (0)