You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@trafficserver.apache.org by Dk Jack <dn...@gmail.com> on 2016/01/21 00:55:29 UTC

poll external server

Hi,
I am new to ATS and I am trying to write a plugin. My plugin needs to do
two things:

1) Periodically poll an external server and get some info and cache the
info locally.
2) Use this cached info while processing the traffic.

I couldn't find a straight forward example to do #1. Could someone more
knowledgable
point me in the correct direction. Any help is appreciated. Thanks.

Dnj

Re: poll external server

Posted by James Peach <jp...@apache.org>.
> On Jan 20, 2016, at 3:55 PM, Dk Jack <dn...@gmail.com> wrote:
> 
> Hi,
> I am new to ATS and I am trying to write a plugin. My plugin needs to do
> two things:
> 
> 1) Periodically poll an external server and get some info and cache the
> info locally.

TSFetchUrl is probably what you want

> 2) Use this cached info while processing the traffic.
> 
> I couldn't find a straight forward example to do #1. Could someone more
> knowledgable
> point me in the correct direction. Any help is appreciated. Thanks.
> 
> Dnj


Re: poll external server

Posted by Dnj <dn...@gmail.com>.
I did see ats_pagespeed. I was looking for a socket interface and not a file interface. 



> On Jan 21, 2016, at 9:36 AM, Leif Hedstrom <zw...@apache.org> wrote:
> 
> 
>> On Jan 21, 2016, at 8:03 AM, Alan Carroll <so...@yahoo-inc.com.INVALID> wrote:
>> 
>> The closest I could find is ats_pagespeed.This doesn't poll an external server but it does poll a configuration file. Basically you set up a thread using TSThreadCreate(), have it do the polling, and then communicate its results back via thread safe containers. I think the pagespeed one works by creating a duplicate structure on configuration change, then atomically swapping pointers. You still need to reference count so the old structure can be cleaned up. Thread safe queues would work as well.
> 
> 
> Fwiw, The health_check plugin does the same (has a thread checking to changes on the file system).
> 
> — Leif
> 

Re: poll external server

Posted by Leif Hedstrom <zw...@apache.org>.
> On Jan 21, 2016, at 8:03 AM, Alan Carroll <so...@yahoo-inc.com.INVALID> wrote:
> 
> The closest I could find is ats_pagespeed.This doesn't poll an external server but it does poll a configuration file. Basically you set up a thread using TSThreadCreate(), have it do the polling, and then communicate its results back via thread safe containers. I think the pagespeed one works by creating a duplicate structure on configuration change, then atomically swapping pointers. You still need to reference count so the old structure can be cleaned up. Thread safe queues would work as well.


Fwiw, The health_check plugin does the same (has a thread checking to changes on the file system).

— Leif


Re: poll external server

Posted by Alan Carroll <so...@yahoo-inc.com.INVALID>.
The closest I could find is ats_pagespeed.This doesn't poll an external server but it does poll a configuration file. Basically you set up a thread using TSThreadCreate(), have it do the polling, and then communicate its results back via thread safe containers. I think the pagespeed one works by creating a duplicate structure on configuration change, then atomically swapping pointers. You still need to reference count so the old structure can be cleaned up. Thread safe queues would work as well.
 

    On Wednesday, January 20, 2016 5:55 PM, Dk Jack <dn...@gmail.com> wrote:
 

 Hi,
I am new to ATS and I am trying to write a plugin. My plugin needs to do
two things:

1) Periodically poll an external server and get some info and cache the
info locally.
2) Use this cached info while processing the traffic.

I couldn't find a straight forward example to do #1. Could someone more
knowledgable
point me in the correct direction. Any help is appreciated. Thanks.

Dnj