On Sep29, 2011, at 14:45 , Dickson S. Guedes wrote:
> I'm working on a google_contacts_fdw to google contacts api  but
> stopped in the authentication design. As you can see in , for
> google api, you should get an authorization token and store the "Auth"
> value to use latter on the same "session". I'm wondering how the best
> way to "cache" this value as long as possible, because actually, when
> you need authentication for a FDW, you use the
> fdw_routine->BeginForeignScan call function but, in this situation,
> each SELECT to foreign table will do the handshake and some APIs could
> block this. Many client libraries work fine, caching the Auth value.
> How WWW_FDW could play with behaviors like that, since other Web APIs
> has the a authorization system like this ?
You could use a hash table, allocated in the top-level memory context,
to store one authentication token per combination of server and local user.
I suggest you look at the MySQL FDW (https://github.com/dpage/mysql_fdw)
- they presumably re-use the same connection over multiple foreign scans,
which seems to be a problem similar to yours.
In response to
pgsql-hackers by date
|Next:||From: Robert Haas||Date: 2011-09-29 13:59:26|
|Subject: Re: Does RelCache/SysCache shrink except when relations are deleted?|
|Previous:||From: Alvaro Herrera||Date: 2011-09-29 13:44:29|
|Subject: Re: pg_upgrade - add config directory setting|