Structuring Programs in Go

Application programs in the Go language differ in several ways from programs in other languages. These steps outline the main structural components of most Go application programs that communicate using TIBCO FTL.

Summary of Differences

  • Go does not support FTL timer events.
  • Queue objects do not require explicit dispatch.
  • Subscribe calls are methods of event queue objects, and these methods automatically add the new subscriber objects to the queue.
  • When an inbound message arrives, the queue places the message on a subscriber channel, where your message processing methods can receive it.
  • FTL inline mode is not relevant to Go programs.

Procedure

Task A Initializing TIBCO FTL Objects

  1. Create a realm object by connecting to an FTL server.

Task B Processing Events

  1. Create channels for inbound messages, and define goroutines to process messages from those channels.
  2. Create channels for advisory messages, and define goroutines to process advisories, as needed.
  3. Create a channel for out-of-band notifications, and define a goroutine to process notifications.
  4. Launch the goroutines that poll message channels.

Task C Sending Messages

  1. Define structs for marshaling data to and from messages.
  2. Define methods to construct outbound messages.
  3. Instantiate endpoints as publisher objects.
  4. Arrange to call the send methods of publishers.

    Programs usually call send methods in the context of a data-generation loop, or during message processing, or both.

Task D Receiving Messages

  1. Create an event queue object.
  2. Create subscriber objects.
    Supply a channel as an argument. (The goroutines that process messages on the channel are already running.)
    With a durable, supply a name property.

Task E Recovery and Clean-Up

  1. Recover from administrative disable (see Recovery of a Disabled Process Restart versus Reopen the Realm).
  2. Exit cleanly (see Clean-Up).
Related tasks