(Migrated) Channel autocreation on service deployment

(This message has been automatically imported from the retired mailing list)

Hi,

I’ve been thinking for a while about the following feature: have a
service create its own input channels during “after_add_to_store” phase.

Is it possible to do this or something similar in the current versions
(1.1 and GH)?
And if it isn’t, do you think it would be interesting or even possible
to implement?

I had a look at the code and thought about different possibilities, with
and without coding involved:

  • Send an Http request to the corresponding service.
    o Doable without coding in zato, but really “ugly”: cluster,
    names, server or load-balancer host/port, pubapi password, etc.
    need to be hard coded.
    o Might have problems during server startup.
  • Invoke the corresponding service internally
    o At the moment it is not possible because there is no “self” in
    after_add_to_store. Also, looking at the code I see no easy way
    of making the invoke method accessible from there.
    o Also, I don’t know if in this case the deployment order would be
    an issue during server startup.
  • Develop a special syntax (like the Spring annotations) to
    "autoconnect" a service to a channel.
    o Maybe this would be the cleanest solution, but I don’t know if
    it is possible or even if it would go against any principle in
    Zato philosophy.

What do you think about it?

Regards,
Carles

On 05/20/2014 02:25 PM, Coeuz wrote:

  • Develop a special syntax (like the Spring annotations) to
    "autoconnect" a service to a channel.
    o Maybe this would be the cleanest solution, but I don’t know if
    it is possible or even if it would go against any principle in
    Zato philosophy.

That would seem the best way.

Consider this JSONAdapter:

https://github.com/zatosource/zato/blob/master/code/zato-server/src/zato/server/service/adapter.py

It lets one develop JSON-invoking services in a completely declarative
way. This is the sort of code I’ve been recently authoring:

“”"

Zato

from zato.server.service.adapter import JSONAdapter

class CreateCustomer(JSONAdapter):
outconn = 'CRM Customer’
method = 'POST’
params_to_qs = False
params = {‘status’:‘new’}
"""

This is the whole code of a service that will accept a dictionary
request, converting to JSON, possibly storing some parameters in query
strings, possibly using some pre-defined ones as well with an option to
specify whether query parameters take priority over JSON payload and a
couple of other niceties, like the echo and dry run mode (very useful in
testing).

So with your question, how about we do

“”"

Zato

from zato.server.service.channel import JSONChannel

class CreateCustomer(JSONChannel):
def handle(self):
# Proceed as usual
"""

And when a service is being deployed, Zato could check if it’s a channel
service and if so - would generate an appropriate channel itself?

On 05/20/2014 02:25 PM, Coeuz wrote:

  • Develop a special syntax (like the Spring annotations) to
    "autoconnect" a service to a channel.
    o Maybe this would be the cleanest solution, but I don’t know if
    it is possible or even if it would go against any principle in
    Zato philosophy.

That would seem the best way.

Consider this JSONAdapter:

https://github.com/zatosource/zato/blob/master/code/zato-server/src/zato/server/service/adapter.py

It lets one develop JSON-invoking services in a completely declarative
way. This is the sort of code I’ve been recently authoring:

“”"

Zato

from zato.server.service.adapter import JSONAdapter

class CreateCustomer(JSONAdapter):
outconn = 'CRM Customer’
method = 'POST’
params_to_qs = False
params = {‘status’:‘new’}
"""

This is the whole code of a service that will accept a dictionary
request, converting to JSON, possibly storing some parameters in query
strings, possibly using some pre-defined ones as well with an option to
specify whether query parameters take priority over JSON payload and a
couple of other niceties, like the echo and dry run mode (very useful in
testing).

So with your question, how about we do

“”"

Zato

from zato.server.service.channel import JSONChannel

class CreateCustomer(JSONChannel):
def handle(self):
# Proceed as usual
"""

And when a service is being deployed, Zato could check if it’s a channel
service and if so - would generate an appropriate channel itself?

On 05/20/2014 04:01 PM, Dariusz Suchojad wrote:

class MyService(JSONService):
path = ‘/my/service’ # Auto-generate if not provided

403 if not declared

security = ‘security definition name’

One needs to be explicit that no security checks are needed

security = ‘no security’

By the way - these would only be settings of an automatically generated
default HTTP channel. Nothing here should prevent one from exposing the
very service over additional channels later on.