← Back to team overview

mysql-proxy-discuss team mailing list archive

Re: Implementing the creation of master.info files

 

Diego Medina wrote:
> Hi Everyone,
> 
> I added a new blueprint
> https://blueprints.launchpad.net/mysql-proxy/+spec/master-info
> 
> And I am looking for ideas as to how you think this should work. So
> far we can read a master.info file and parse the different values, but
> how should the other way around work?
> 
> I thought if having a
> 
> to_masterinfo_string() function that you can access from Lua, but I am
> not sure about how to pass the parameters.
> 
> 1- pass two parameters, one for the path to the file, and the other
> one a string with \n to mark the new lines
> 2- pass a array to it, something like
> 
> to_masterinfo_string(
> 
> {
>       "path" = var0,
>       "master_host" = var1,
>       "master_user" = var2,
>        ...
> }

Yep, go with 2). You can perhaps use the LUA_IMPORT_* macros and fill
the master_info struct which would then be passed to the C-layer to turn
into a nice string.

That string is then returned as the result of the function.

Usually you can treat the to_* functions as a reverse of the from_*
functions and should end up with the same result:

  local f = io.open("master.info")
  local content = f:read("a")
  local master_info = proto.from_master_info(content)
  assert(proto.to_master_info(master_info) == content)


cheers,
  Jan
-- 
 jan: "Gee, Brain^WEric, what'd you wanna do tonight?"
eric: Same thing we do everynight: Take over the HelloWorld!



References