skilld-labs / go-odoo

Golang wrapper for Odoo API
Apache License 2.0
86 stars 62 forks source link

There is no way to close off the connection #22

Closed AnJ-Github closed 4 years ago

AnJ-Github commented 4 years ago

I couldn't find any way to close off the connection and corresponding goroutine. If I need to send request with different credentials than the last time it leaves previous connection hanging and it leads to goroutine leak and in consequence memory leak.

I’m not sure if this could be solved in this package or it is problem with dependency kolo/xmlrpc (or I'm simply missing something).

ahuret commented 4 years ago

Hi @Gumaa thank you for your report !

Do you think adding a (c *Client) Close() func would be good ?

I can see kolo/xmlrpc doesn't implement Close() func but rpc does https://golang.org/src/net/rpc/client.go#L284.

If it is ok, please open an MR with fix :)

AnJ-Github commented 4 years ago

Do you think adding a (c *Client) Close() func would be good ?

I was looking up to this actually.

I could try fixing this but I'm not sure if I will be able to.

ahuret commented 4 years ago

imo just closing rpc Client would be enough. So it is :

func (c *Client) Close() error {
    return c.client.Close()
}
ahuret commented 4 years ago

btw we should probably changed client field (from Client struct) to xmlrpc so that it wouldn't be confusing

ahuret commented 4 years ago

@Gumaa Closing it since it's now implemented (see https://github.com/skilld-labs/go-odoo/blob/master/odoo.go#L58).