...

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

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

     1  package solace
     2  
     3  import (
     4  	"solace.dev/go/messaging/pkg/solace/config"
     5  )
     6  
     7  // EndpointProvisioner aids the type-safe collection of queue properties,
     8  // and can provision multiple queues with different names (but identical properties) on the broker.
     9  // Warning: This is a mutable object. The fluent builder style setters modify and return the original object. Make copies explicitly.
    10  type EndpointProvisioner interface {
    11  	// Provision a queue with the specified name on the broker bearing
    12  	// all the properties configured on the Provisioner.
    13  	// Properties left unconfigured will be set to broker defaults.
    14  	// Accepts a boolean parameter to ignore a specific error response from the broker which indicates
    15  	// that a queue with the same name and properties already exists.
    16  	// Blocks until the operation is finished on the broker, returns the provision outcome.
    17  	Provision(queueName string, ignoreExists bool) ProvisionOutcome
    18  
    19  	// ProvisionAsync will asynchronously provision a queue with the specified name on
    20  	// the broker bearing all the properties configured on the Provisioner.
    21  	// Accepts a boolean parameter to ignore a specific error response from the broker which indicates
    22  	// that a queue with the same name and properties already exists.
    23  	// Properties left unconfigured will be set to broker defaults.
    24  	// This function is idempotent. The only way to resume configuration operation
    25  	// after this function is called is to create a new instance.
    26  	// Any attempt to call this function will provision the queue
    27  	// on the broker, even if this function completes.
    28  	// The maximum number of outstanding requests for provision is set to 32.
    29  	// This function will return an error when this limit is reached or exceeded.
    30  	// Returns a channel immediately that receives the endpoint provision outcome when completed.
    31  	ProvisionAsync(queueName string, ignoreExists bool) <-chan ProvisionOutcome
    32  
    33  	// ProvisionAsyncWithCallback will asynchronously provision a queue with the specified name on
    34  	// the broker bearing all the properties configured on the Provisioner.
    35  	// Accepts a boolean parameter to ignore a specific error response from the broker which indicates
    36  	// that a queue with the same name and properties already exists.
    37  	// Properties left unconfigured will be set to broker defaults.
    38  	// This function is idempotent. The only way to resume configuration operation
    39  	// after this function is called is to create a new instance.
    40  	// Any attempt to call this function will provision the queue
    41  	// on the broker, even if this function completes.
    42  	// Returns immediately and registers a callback that will receive an
    43  	// outcome for the endpoint provision.
    44  	// Please note that the callback may not be executed in network order from the broker
    45  	ProvisionAsyncWithCallback(queueName string, ignoreExists bool, callback func(ProvisionOutcome))
    46  
    47  	// Deprovision (deletes) the queue with the given name from the broker.
    48  	// Ignores all queue properties accumulated in the EndpointProvisioner.
    49  	// Accepts the ignoreMissing boolean property, which, if set to true,
    50  	// turns the "no such queue" error into nil.
    51  	// Blocks until the operation is finished on the broker, returns the nil or an error
    52  	Deprovision(queueName string, ignoreMissing bool) error
    53  
    54  	// DeprovisionAsync will asynchronously deprovision (deletes) the queue with the given
    55  	// name from the broker. Returns immediately.
    56  	// Ignores all queue properties accumulated in the EndpointProvisioner.
    57  	// Accepts the ignoreMissing boolean property, which, if set to true,
    58  	// turns the "no such queue" error into nil.
    59  	// Any error (or nil if successful) is reported through the returned channel.
    60  	// Returns a channel immediately that receives nil or an error.
    61  	DeprovisionAsync(queueName string, ignoreMissing bool) <-chan error
    62  
    63  	// DeprovisionAsyncWithCallback will asynchronously deprovision (deletes) the queue with the
    64  	// given name on the broker.
    65  	// Ignores all queue properties accumulated in the EndpointProvisioner.
    66  	// Accepts the ignoreMissing boolean property, which, if set to true,
    67  	// turns the "no such queue" error into nil.
    68  	// Returns immediately and registers a callback that will receive an
    69  	// error if deprovision on the broker fails.
    70  	// Please note that the callback may not be executed in network order from the broker
    71  	DeprovisionAsyncWithCallback(queueName string, ignoreMissing bool, callback func(err error))
    72  
    73  	// FromConfigurationProvider sets the configuration based on the specified configuration provider.
    74  	// The following are built in configuration providers:
    75  	// - EndpointPropertyMap - This can be used to set an EndpointProperty to a value programatically.
    76  	//
    77  	// The EndpointPropertiesConfigurationProvider interface can also be implemented by a type
    78  	// to have it act as a configuration factory by implementing the following:
    79  	//
    80  	//   func (type MyType) GetConfiguration() EndpointPropertyMap {...}
    81  	//
    82  	// Any properties provided by the configuration provider are layered over top of any
    83  	// previously set properties, including those set by specifying various strategies.
    84  	// Can be used to clone a EndpointProvisioner object.
    85  	FromConfigurationProvider(properties config.EndpointPropertiesConfigurationProvider) EndpointProvisioner
    86  
    87  	// Returns a copy of the current configuration held.
    88  	GetConfiguration() config.EndpointPropertyMap
    89  
    90  	// WithProperty will set an individual queue property by name. Does not perform type checking.
    91  	WithProperty(propertyName config.EndpointProperty, propertyValue interface{}) EndpointProvisioner
    92  
    93  	// WithDurability will set the durability property for the endpoint.
    94  	// True for durable, false for non-durable.
    95  	WithDurability(durable bool) EndpointProvisioner
    96  
    97  	// WithExclusiveAccess will set the endpoint access type.
    98  	// True for exclusive, false for non-exclusive.
    99  	WithExclusiveAccess(exclusive bool) EndpointProvisioner
   100  
   101  	// WithDiscardNotification will set the notification behaviour on message discards.
   102  	// True to notify senders about discards, false not to.
   103  	WithDiscardNotification(notifySender bool) EndpointProvisioner
   104  
   105  	// WithMaxMessageRedelivery will sets the number of times messages from the
   106  	// queue will be redelivered before being diverted to the DMQ.
   107  	WithMaxMessageRedelivery(count uint) EndpointProvisioner
   108  
   109  	// WithMaxMessageSize will set the maximum message size in bytes the queue will accept.
   110  	WithMaxMessageSize(count uint) EndpointProvisioner
   111  
   112  	// WithPermission will set the queue's permission level for others.
   113  	// The levels are supersets of each other, can not be combined and the last one set will take effect.
   114  	WithPermission(permission config.EndpointPermission) EndpointProvisioner
   115  
   116  	// WithQuotaMB will set the overall size limit of the queue in MegaBytes.
   117  	WithQuotaMB(quota uint) EndpointProvisioner
   118  
   119  	// WithTTLPolicy will set how the queue will handle the TTL value in messages.
   120  	// True to respect it, false to ignore it.
   121  	WithTTLPolicy(respect bool) EndpointProvisioner
   122  }
   123  
   124  // ProvisionOutcome - the EndpointProvisioner.Provision operation
   125  // return this structure to indicate the success and the underlying error code.
   126  // It is possible for the outcome to be successful and yet contain a non-nil error when the queue already exists on the broker,
   127  // and the Provision function was invoked with the ignoreExists flag set.
   128  type ProvisionOutcome interface {
   129  	// GetError returns the low level error object if any.
   130  	GetError() error
   131  
   132  	// GetStatus retrives the actual outcome: true means success, false means failure.
   133  	GetStatus() bool
   134  }
   135