1 // pubsubplus-go-client 2 // 3 // Copyright 2021-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 config 18 19 // EndpointProperty - when provisioning queues on the broker, these properties of the queue can be supplied. 20 type EndpointProperty string 21 22 // EndpointPropertyMap is a map of EndpointProperty keys to values of respective types. 23 // Best handled via the type-safe EndpointProvisioner builder methods. 24 type EndpointPropertyMap map[EndpointProperty]interface{} 25 26 // EndpointPropertiesConfigurationProvider describes the behavior of a configuration provider 27 // that provides the queue properties for queue provisioning. 28 type EndpointPropertiesConfigurationProvider interface { 29 GetConfiguration() EndpointPropertyMap 30 } 31 32 // GetConfiguration returns a copy of the EndpointPropertyMap 33 func (endpointPropertyMap EndpointPropertyMap) GetConfiguration() EndpointPropertyMap { 34 ret := make(EndpointPropertyMap) 35 for key, value := range endpointPropertyMap { 36 ret[key] = value 37 } 38 return ret 39 } 40 41 // MarshalJSON implements the json.Marshaler interface. 42 func (endpointPropertyMap EndpointPropertyMap) MarshalJSON() ([]byte, error) { 43 m := make(map[string]interface{}) 44 for k, v := range endpointPropertyMap { 45 m[string(k)] = v 46 } 47 return nestJSON(m) 48 } 49 50 // UnmarshalJSON implements the json.Unmarshaler interface. 51 func (endpointPropertyMap EndpointPropertyMap) UnmarshalJSON(b []byte) error { 52 m, err := flattenJSON(b) 53 if err != nil { 54 return err 55 } 56 for key, val := range m { 57 endpointPropertyMap[EndpointProperty(key)] = val 58 } 59 return nil 60 } 61 62 // These constants are used as keys in a EndpointPropertyMap to provision queues on the broker. 63 const ( 64 // EndpointPropertyDurable boolean property specifying durability of the queue being provisioned. 65 // True means durable, false means non-durable. 66 EndpointPropertyDurable EndpointProperty = "solace.messaging.endpoint-property.durable" 67 68 // EndpointPropertyExclusive boolean property specifying the access type of the queue being provisioned. 69 // True means exclusive, false means non-exclusive. 70 EndpointPropertyExclusive EndpointProperty = "solace.messaging.endpoint-property.exclusive" 71 72 // EndpointPropertyNotifySender boolean property specifying whether the queue will notify senders on discards. 73 // True means to notify senders, false means no notification. 74 EndpointPropertyNotifySender EndpointProperty = "solace.messaging.endpoint-property.notify-sender" 75 76 // EndpointPropertyMaxMessageRedelivery integer property specifying how many times the broker 77 // will try to re-deliver messages from the queue being provisioned. 78 EndpointPropertyMaxMessageRedelivery EndpointProperty = "solace.messaging.endpoint-property.max-message-redelivery" 79 80 // EndpointPropertyMaxMessageSize integer property specifying how big (in bytes) each message 81 // can be in the queue being provisioned. 82 EndpointPropertyMaxMessageSize EndpointProperty = "solace.messaging.endpoint-property.max-message-size" 83 84 // EndpointPropertyPermission EndpointPermission enum type property specifying the permission level granted to others 85 // (relative to the clientusername that established the messagingService session) on the queue being provisioned. 86 EndpointPropertyPermission EndpointProperty = "solace.messaging.endpoint-property.permission" 87 88 // EndpointPropertyQuotaMB integer property specifying (in MegaBytes) how much storage 89 // the queue being provisioned is allowed to take up on the broker. 90 EndpointPropertyQuotaMB EndpointProperty = "solace.messaging.endpoint-property.quota-mb" 91 92 // EndpointPropertyRespectsTTL boolean property specifying how the queue being provisioned 93 // treats the TTL value in messages. 94 // True means respect the TTL, false means ignore the TTL. 95 EndpointPropertyRespectsTTL EndpointProperty = "solace.messaging.endpoint-property.respects-ttl" 96 ) 97 98 // EndpointPermission - these permissions can be supplied when provisioning queues on the broker. 99 type EndpointPermission string 100 101 // The different permission levels that can be granted to other clients over the queue being provisioned. 102 // These are increasingly broad levels, each encompassing all lower permissions. 103 const ( 104 // EndpointPermissionNone specifies no access at all to others. 105 EndpointPermissionNone EndpointPermission = "solace.messaging.endpoint-permission.none" 106 107 // EndpointPermissionReadOnly specifies others may read (browse) the queue. 108 EndpointPermissionReadOnly EndpointPermission = "solace.messaging.endpoint-permission.read-only" 109 110 // EndpointPermissionConsume specifies others may browse and consume from the queue. 111 EndpointPermissionConsume EndpointPermission = "solace.messaging.endpoint-permission.consume" 112 113 // EndpointPermissionModifyTopic specifies others may browse and consume from the queue, and alter its subscription(s). 114 EndpointPermissionModifyTopic EndpointPermission = "solace.messaging.endpoint-permission.modify-topic" 115 116 // EndpointPermissionDelete specifies others may do anything to the queue without restriction. 117 EndpointPermissionDelete EndpointPermission = "solace.messaging.endpoint-permission.delete" 118 ) 119