David Sparks wrote:
Background: I have several hundred lines of yaml config that map
user/host names at connect/mail/rcpt time to specific actions. The
action is immediate reject/tempfail or deferred by adding an entry to
notes(); queue plugins use the notes entries to write the message with
some metadata (ie envelope information to relay the msg).
Good, now we are getting somewhere. The connection object is only good
as long as the connection exists and the transaction object (wait for
it!) is good only as long as the individual transaction exists. Neither
of them is suitable for "read once" configurations. The plugin object
themselves, however, is persistent across connections/transactions.
So, this is what you do:
1) Create a closure in your plugin; the compile() action might do this
for you but it is safer to just surround all of your plugin code with an
additional layer of {}'s).
2) Create a lexically scoped (my) variable to store your YAML config
into, inside that closure; this is now effectively your own private
storage class.
3) Populate the above lexical in the init() sub, which is called once
when the plugin is loaded (which in forkserver happens very early, even
before the fork happens).
4) Reference the lexical in your sub's (it is invisible outside the
closure).
5) On a more theoretical basis, it should be possible to reload the
configuration on demand (register a $SIG{HUP} handler), but this is at
the edge of what I know how to do...
HTH
John