1 // pubsubplus-go-client 2 // 3 // Copyright 2025 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 import ( 20 "solace.dev/go/messaging/pkg/solace/message" 21 "solace.dev/go/messaging/pkg/solace/resource" 22 ) 23 24 // ReceiverCacheRequests provides an interface through which the application can request cached messages from a cache. 25 // - cachedMessageSubscriptionRequest: Configuration for the submitted cache request. Refer to 26 // [solace.dev/go/messaging/pkg/solace/resource.CachedMessageSubscriptionRequest] for more details. 27 // - cacheRequestID: An identifier that can be used to correlate received cached messages with a cache 28 // request and response. This cache request ID MUST be unique for the duration of application execution, and 29 // it is the responsibility of the application to ensure this. This ID will be returned to the application through 30 // the [solace.dev/go/messaging/pkg/solace.CacheResponse] provided to the application after the cache request has completed. 31 // 32 // The provided function callback or returned channel will provide to the application only the cache responses 33 // resulting from outstanding cache requests. Data messages related to the cache response will be passed through the 34 // conventional [solace.dev/go/messaging/pkg/solace.DirectMessageReceiver] interfaces of Receive() and ReceiveAsync(). 35 // 36 // In cases where the application does not immediately process the cache response, it may appear that the application 37 // does not receive the expected cache response within the timeout configured through 38 // [solace.dev/go/messaging/pkg/solace/resource.NewCachedMessageSubscriptionRequest]. It is important to note that the configured timeout applies only to 39 // the network, so if the API receives the cache response before the timeout expires, but the application does not 40 // process the response until after the timeout expires, the cache response will still be marked as complete. 41 type ReceiverCacheRequests interface { 42 43 // RequestCachedAsync asynchronously requests cached data from a cache and defers processing of the resulting 44 // cache response to the application through the returned channel. 45 // Returns IllegalStateError if the service is not connected or the receiver is not running. 46 // Returns InvalidConfigurationError if an invalid CachedMessageSubscriptionRequest was passed. 47 RequestCachedAsync(cachedMessageSubscriptionRequest resource.CachedMessageSubscriptionRequest, cacheRequestID message.CacheRequestID) (<-chan CacheResponse, error) 48 49 // RequestCachedAsyncWithCallback asynchronously requests cached data from a cache and processes the resulting 50 // cache response through the provided function callback. 51 // Returns IllegalStateError if the service is not connected or the receiver is not running. 52 // Returns InvalidConfigurationError if an invalid CachedMessageSubscriptionRequest was passed. 53 RequestCachedAsyncWithCallback(cachedMessageSubscriptionRequest resource.CachedMessageSubscriptionRequest, cacheRequestID message.CacheRequestID, callback func(CacheResponse)) error 54 } 55