HAProxy community

HAProxy management socket to modify HAProxy map in runtime



I find a reference in documentation to modify the HAProxy map in runtime but it doesn’t clarify the functionality.

My objective is to modify HAProxy map from LUA in runtime and also flush the updates to disk periodically.

  1. Could the HAProxy team please add more details with example?

  2. Does it mean usa - 12 could be changed to usa - 13 or new entry uk -14 could be added to map in runtime, and same changes will get flushed to disk as well in geo.map periodically?

  3. Will core.set_map(filename, key, value) help?

The declared maps can be modified during the runtime throught the HAProxy management socket.

Reference: http://www.arpalert.org/src/haproxy-lua-api/1.7dev/#map-class

PS : I am aware of dynamic-update but don’t wanna use HAPEE.


usa 12

-- Create and load map
geo = Map.new("geo.map", Map.ip);

-- Create new fetch that returns the user country
core.register_fetches("country", function(txn)

  local loc;

  -- Perform lookup
  loc = geo:lookup("usa"); 
 -- loc is 12 here

  if (loc == nil) then
    return default;

  return loc;