Ssrc Wisp™ Event-based distributed service framework

Software icon

Ssrc Wisp™ (pronounced source wisp) allows you to rapidly build event-based distributed services in C++. Events are delivered as native C++ data structures, avoiding the complexity and performance cost of manipulating intermediate serialization formats. Services may send/receive point-to-point messages or send/receive events to/from groups of services using the same communication API. Ssrc Wisp™ is suitable for constructing custom enterprise services and back-end services for Web applications, such as Web Wispers™.

For more information, read the overview.

Download
VersionSourceLicenseChangesDocumentationReports
1.3.1wisp-1.3.1.tar.xzLICENSECHANGES1.3.1 API Test Code Coverage
1.3.0wisp-1.3.0.tar.xzLICENSE
1.2.5wisp-1.2.5.tar.xzLICENSE

A Simple Example

Wisp services communicate via events, implemented as messages. A set of related messages forms a protocol, implemented as a C++ struct containing message types and meta-data describing the relationships between messages. For example, messages may be organized to implement remote method invocations (a two-way call) or isolated event deliveries (a one-way call).

The following code listing defines the messages required to communicate with an echo service, which sends back to the client the text received in an echo request.

#ifndef __WISP_EXAMPLE_ECHO_PROTOCOL_H #define __WISP_EXAMPLE_ECHO_PROTOCOL_H #include <ssrc/wisp/protocol.h> using std::string; enum ProtocolNumber { Echo = 2038 }; WISP_DEFINE_PROTOCOL(Echo); struct EchoProtocol : public ssrc::wisp::protocol::ServiceProtocol<Echo> { enum MessageType { Stop, EchoRequest, EchoReply }; typedef MessageEcho MessageStop; WISP_PROTOCOL_MESSAGE(EchoRequest, MessageEcho, ((string, payload))); WISP_PROTOCOL_MESSAGE(EchoReply, MessageEcho, ((string, payload))); WISP_ONE_WAY_CALL(caller_type, Stop); WISP_TWO_WAY_CALL(caller_type, EchoRequest, EchoReply); WISP_ONE_WAY_CALL(caller_type, EchoReply); }; #endif

Wisp services implement event-processing functions named process_request and process_response to receive asynchronous events. Also, they can use I/O-based continuations to process replies to asynchronous two-way calls.

The following code listing defines the echo service, which recognizes two EchoProtocol messages: EchoRequest and Stop.

#ifndef __WISP_EXAMPLE_ECHO_SERVICE_H #define __WISP_EXAMPLE_ECHO_SERVICE_H #include "echo_protocol.h" #include <ssrc/wisp/service.h> using ssrc::spread::Message; using ssrc::wisp::protocol::MessageInfo; using ssrc::wisp::service::ServiceProtocolProcessor; class EchoService : public ServiceProtocolProcessor<EchoProtocol::packing_traits> { friend class ServiceProtocolProcessor<EchoProtocol::packing_traits>; typedef ServiceProtocolProcessor<EchoProtocol::packing_traits> super; WISP_IMPORT(EchoProtocol, MessageStop); WISP_IMPORT(EchoProtocol, MessageEchoRequest); WISP_IMPORT(EchoProtocol, CallEchoReply); virtual void transition(State state) { if(state == Stopping) state = Stopped; else if(state == Starting) state = Started; super::transition(state); } public: EchoService(super::caller_type & caller) : super(caller) { WISP_SERVICE_REQUEST(MessageStop); WISP_SERVICE_REQUEST(MessageEchoRequest); } virtual ~EchoService() { } void process_request(const MessageStop & msg, const MessageInfo &) { stop(); } void process_request(const MessageEchoRequest & msg, const MessageInfo & msginfo) { _caller. replyp<CallEchoReply>(msginfo.sender(), msg.payload, msginfo.token(), Message::FIFO); } }; #endif

Wisp services run as independent processes, subject to operating system process scheduling and memory protection. This approach results in more robust and easier to manage services than services hosted in application servers executing threads inside a shared memory space.

The following code listing creates an executable program from EchoService.

#include "echo_service.h" #include <ssrc/wisp/utility/service_main.h> WISP_SERVICE_MAIN(EchoService)

This product uses software developed by Spread Concepts LLC for use in the Spread toolkit. For more information about Spread, see http://www.spread.org/.