...

Source file src/solace.dev/go/messaging/pkg/solace/message_publisher.go

Documentation: solace.dev/go/messaging/pkg/solace

     1  // pubsubplus-go-client
     2  //
     3  // Copyright 2021-2024 Solace Corporation. All rights reserved.
     4  //
     5  // Licensed under the Apache License, Version 2.0 (the "License");
     6  // you may not use this file except in compliance with the License.
     7  // You may obtain a copy of the License at
     8  //
     9  // http://www.apache.org/licenses/LICENSE-2.0
    10  //
    11  // Unless required by applicable law or agreed to in writing, software
    12  // distributed under the License is distributed on an "AS IS" BASIS,
    13  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  // See the License for the specific language governing permissions and
    15  // limitations under the License.
    16  
    17  package solace
    18  
    19  // MessagePublisher represents the shared functionality between all publisher instances.
    20  type MessagePublisher interface {
    21  	// Extend LifecycleControl for various lifecycle management functionality.
    22  	LifecycleControl
    23  }
    24  
    25  // MessagePublisherHealthCheck allows applications to check and listen for events
    26  // that indicate when message publishers are ready to publish. This is often used
    27  // to handle various back pressure schemes, such as reject on full, and allows
    28  // publishing to stop until the publisher can begin accepting more messages.
    29  type MessagePublisherHealthCheck interface {
    30  	// IsReady checks if the publisher can publish messages. Returns true if the
    31  	// publisher can publish messages, otherwise false if the publisher is prevented from
    32  	// sending messages (e.g., a full buffer or I/O problems).
    33  	IsReady() bool
    34  
    35  	// SetPublisherReadinessListener registers a listener to be called when the
    36  	// publisher can send messages. Typically, the listener is notified after a
    37  	// Publisher instance raises an error indicating that the outbound message
    38  	// buffer is full.
    39  	SetPublisherReadinessListener(listener PublisherReadinessListener)
    40  
    41  	// NotifyWhenReady makes a request to notify the application when the
    42  	// publisher is ready. This function triggers a readiness notification if one
    43  	// needs to be sent, otherwise the next readiness notification is
    44  	// processed.
    45  	NotifyWhenReady()
    46  }
    47  
    48  // PublisherReadinessListener defines a function that can be registered to
    49  // receive notifications from a publisher instance for readiness.
    50  type PublisherReadinessListener func()
    51