[Documentation] [TitleIndex] [WordIndex

Calling a service

$ (wait-for-service "my_service" 10)
$ (setq response (call-service "my_service" 'ServiceType :arg1 42 :arg2 24))
$ (with-fields (field1 field2) response
    (* field1 field2))

Note that you don't have to explicitly create a request object for call-service.

Providing a service

$ (def-service-callback AddTwoInts (a b)
    (make-response :data (+ a b))
$ (register-service "add_two_ints" 'AddTwoInts')

Note that def-service-callback takes care of getting the arguments out of the request, and creating the response when you're done. If you want to use a lambda function instead of one with a name,

$ (register-service-fn "add_two_ints" 
    #'(lambda (req) (with-fields (a b) req 
      (make-msg "my_package/AddTwoIntsResponse" :data (+ a b)))))

would do the same thing.


2024-12-21 18:31