diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..b05bff2 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/openmessaging-go + +go 1.12 diff --git a/openmessaging/messaging_access_point.go b/openmessaging/common/messaging_access_point.go similarity index 92% rename from openmessaging/messaging_access_point.go rename to openmessaging/common/messaging_access_point.go index f663269..51360cd 100644 --- a/openmessaging/messaging_access_point.go +++ b/openmessaging/common/messaging_access_point.go @@ -13,21 +13,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package openmessaging +package common import ( - . "github.com/openmessaging-go/openmessaging/producer" + "github.com/openmessaging-go/openmessaging" . "github.com/openmessaging-go/openmessaging/consumer" . "github.com/openmessaging-go/openmessaging/manager" + . "github.com/openmessaging-go/openmessaging/producer" ) type MessagingAccessPoint interface { /** - * Returns the target OMS specification version of the specified vendor implementation. - * - * @return the OMS version of implementation - * @see OMS#specVersion - */ + * Returns the target OMS specification version of the specified vendor implementation. + * + * @return the OMS version of implementation + * @see OMS#specVersion + */ Version() (string, error) /** @@ -44,7 +45,7 @@ type MessagingAccessPoint interface { * * @return the attributes */ - Attributes() (KeyValue, error) + Attributes() (openmessaging.KeyValue, error) /** * Creates a new {@code Producer} for the specified {@code MessagingAccessPoint}. diff --git a/openmessaging/common/messaging_access_point_test.go b/openmessaging/common/messaging_access_point_test.go new file mode 100644 index 0000000..2f50ac9 --- /dev/null +++ b/openmessaging/common/messaging_access_point_test.go @@ -0,0 +1,46 @@ +package common + +import ( + "testing" + + "github.com/openmessaging-go/openmessaging" + "github.com/openmessaging-go/openmessaging/consumer" + "github.com/openmessaging-go/openmessaging/manager" + "github.com/openmessaging-go/openmessaging/producer" +) + +func TestCycleImportIssue(t *testing.T) { + s := &sampleMessagingAccessPoint{} + v, err := s.Version() + if err != nil { + t.Fatal(err) + } + t.Log(v) +} + +type sampleMessagingAccessPoint struct { +} + +func (sampleMessagingAccessPoint) Version() (string, error) { + return "0.0.1", nil +} + +func (sampleMessagingAccessPoint) Attributes() (openmessaging.KeyValue, error) { + panic("implement me") +} + +func (sampleMessagingAccessPoint) CreateProducer() (producer.Producer, error) { + panic("implement me") +} + +func (sampleMessagingAccessPoint) CreateTransactionProducer(transactionStateCheckListener producer.TransactionStateCheckListener) (producer.Producer, error) { + panic("implement me") +} + +func (sampleMessagingAccessPoint) CreateConsumer() (consumer.Consumer, error) { + panic("implement me") +} + +func (sampleMessagingAccessPoint) ResourceManager() (manager.ResourceManager, error) { + panic("implement me") +} diff --git a/openmessaging/consumer/consumer.go b/openmessaging/consumer/consumer.go index 333632a..d659c95 100644 --- a/openmessaging/consumer/consumer.go +++ b/openmessaging/consumer/consumer.go @@ -18,20 +18,20 @@ package consumer import ( . "github.com/openmessaging-go/openmessaging" - . "github.com/openmessaging-go/openmessaging/interceptor" + interceptor "github.com/openmessaging-go/openmessaging/interceptor" ) type Consumer interface { ServiceLifecycle /** - * Resumes the {@code Consumer} in push model after a suspend. - *
- * This method resumes the {@code Consumer} instance after it was suspended. The instance will not receive new - * messages between the suspend and resume calls. - * - * @return error if the instance has not been suspended. - * @see Consumer#suspend() - */ + * Resumes the {@code Consumer} in push model after a suspend. + *
+ * This method resumes the {@code Consumer} instance after it was suspended. The instance will not receive new + * messages between the suspend and resume calls. + * + * @return error if the instance has not been suspended. + * @see Consumer#suspend() + */ Resume() error /** @@ -110,14 +110,14 @@ type Consumer interface { * * @param interceptor an interceptor instance. */ - AddInterceptor(interceptor ConsumerInterceptor) error + AddInterceptor(interceptor interceptor.ConsumerInterceptor) error /** * Removes an interceptor from this consumer. * * @param interceptor an interceptor to be removed. */ - RemoveInterceptor(interceptor ConsumerInterceptor) error + RemoveInterceptor(interceptor interceptor.ConsumerInterceptor) error /** * Receives the next message from the bind queues of this consumer in pull model. diff --git a/openmessaging/consumer/message_listener.go b/openmessaging/consumer/message_listener.go index 9e1b16e..65a6cc2 100644 --- a/openmessaging/consumer/message_listener.go +++ b/openmessaging/consumer/message_listener.go @@ -22,23 +22,23 @@ import ( type Context interface { /** - * Acknowledges the specified and consumed message, which is related to this {@code MessageContext}. - *
- * Messages that have been received but not acknowledged may be redelivered. - * - * @return error if the consumer fails to acknowledge the messages due to some internal error. - */ + * Acknowledges the specified and consumed message, which is related to this {@code MessageContext}. + *
+ * Messages that have been received but not acknowledged may be redelivered. + * + * @return error if the consumer fails to acknowledge the messages due to some internal error. + */ Ack() error } type MessageListener interface { /** - * Callback method to receive incoming messages. - *
- * A message listener should handle different types of {@code Message}. - * - * @param message the received message object. - * @param context the context delivered to the consume thread. - */ + * Callback method to receive incoming messages. + *
+ * A message listener should handle different types of {@code Message}. + * + * @param message the received message object. + * @param context the context delivered to the consume thread. + */ OnReceived(message Message, context Context) error } diff --git a/openmessaging/headers.go b/openmessaging/headers.go index 425a0b6..bbcae08 100644 --- a/openmessaging/headers.go +++ b/openmessaging/headers.go @@ -23,13 +23,13 @@ type Headers interface { * specified destination. *
* When a message is received, its destination is equivalent to the {@code Queue} where the message resides in. - */ + */ SetDestination(destination string) (Headers, error) /** - * The {@code MESSAGE_ID} header field contains a value that uniquely identifies each message sent by a {@code - * Producer}. - */ + * The {@code MESSAGE_ID} header field contains a value that uniquely identifies each message sent by a {@code + * Producer}. + */ SetMessageId(messageId string) (Headers, error) /** @@ -177,10 +177,10 @@ type Headers interface { SetCompression(compression int16) (Headers, error) /** - * See {@link Headers#setDestination(String)} - * - * @return destination - */ + * See {@link Headers#setDestination(String)} + * + * @return destination + */ GetDestination() (string, error) /** diff --git a/openmessaging/interceptor/consumer_interceptor.go b/openmessaging/interceptor/consumer_interceptor.go index 3cc81db..2bbe2fd 100644 --- a/openmessaging/interceptor/consumer_interceptor.go +++ b/openmessaging/interceptor/consumer_interceptor.go @@ -22,13 +22,13 @@ import ( type ConsumerInterceptor interface { /** - * Invoked before the message is actually sent to the network. - *
- * This allows for modification of the message if necessary. - * - * @param message a message will be sent. - * @param attributes the extensible attributes delivered to the intercept thread. - */ + * Invoked before the message is actually sent to the network. + *
+ * This allows for modification of the message if necessary. + * + * @param message a message will be sent. + * @param attributes the extensible attributes delivered to the intercept thread. + */ PreReceive(message Message, attributes Context) error /** diff --git a/openmessaging/interceptor/context.go b/openmessaging/interceptor/context.go index cb7a028..540f784 100644 --- a/openmessaging/interceptor/context.go +++ b/openmessaging/interceptor/context.go @@ -22,9 +22,9 @@ import ( type Context interface { /** - * Returns the attributes of this {@code Context} instance. - * - * @return the attributes. - */ + * Returns the attributes of this {@code Context} instance. + * + * @return the attributes. + */ Attributes() (KeyValue, error) } diff --git a/openmessaging/interceptor/producer_interceptor.go b/openmessaging/interceptor/producer_interceptor.go index 7f2cd9a..bf23f08 100644 --- a/openmessaging/interceptor/producer_interceptor.go +++ b/openmessaging/interceptor/producer_interceptor.go @@ -22,13 +22,13 @@ import ( type ProducerInterceptor interface { /** - * Invoked before the message is actually sent to the network. - *
- * This allows for modification of the message if necessary. - * - * @param message a message will be sent. - * @param attributes the extensible attributes delivered to the intercept thread. - */ + * Invoked before the message is actually sent to the network. + *
+ * This allows for modification of the message if necessary. + * + * @param message a message will be sent. + * @param attributes the extensible attributes delivered to the intercept thread. + */ PreSend(message Message, attributes Context) error /** diff --git a/openmessaging/key_value.go b/openmessaging/key_value.go index a327716..53c8563 100644 --- a/openmessaging/key_value.go +++ b/openmessaging/key_value.go @@ -18,11 +18,11 @@ package openmessaging type KeyValue interface { /** - * Inserts or replaces {@code short} value for the specified key. - * - * @param key the key to be placed into this {@code KeyValue} object - * @param value the value corresponding to key - */ + * Inserts or replaces {@code short} value for the specified key. + * + * @param key the key to be placed into this {@code KeyValue} object + * @param value the value corresponding to key + */ PutInt16(key string, value int16) (KeyValue, error) /** diff --git a/openmessaging/manager/resource_manager.go b/openmessaging/manager/resource_manager.go index e3a0f24..8eb6041 100644 --- a/openmessaging/manager/resource_manager.go +++ b/openmessaging/manager/resource_manager.go @@ -28,7 +28,7 @@ type ResourceManager interface { * @return error when the given timeout elapses before the create operation completes. * @return error when this given destination has been created in the server. * @return error when the {@code ResourceManager} fails to create namespace due to some internal error. - */ + */ CreateNamespace(nsName string) error /** @@ -62,7 +62,7 @@ type ResourceManager interface { * @return error when the given timeout elapses before the list operation completes. * @return error when the {@code ResourceManager} fails to list the namespace due to some internal error. */ - ListNamespaces() ([]string, error); + ListNamespaces() ([]string, error) /** * Creates a {@code Queue} resource in the configured namespace with some preset attributes. diff --git a/openmessaging/message.go b/openmessaging/message.go index c34c643..dc22c41 100644 --- a/openmessaging/message.go +++ b/openmessaging/message.go @@ -18,10 +18,10 @@ package openmessaging type Message interface { /** - * Returns all the system header fields of the {@code Message} object as a {@code KeyValue}. - * - * @return the system headers of a {@code Message} - */ + * Returns all the system header fields of the {@code Message} object as a {@code KeyValue}. + * + * @return the system headers of a {@code Message} + */ Headers() (Headers, error) /** diff --git a/openmessaging/message_factory.go b/openmessaging/message_factory.go index 2de5e08..1bfba2f 100644 --- a/openmessaging/message_factory.go +++ b/openmessaging/message_factory.go @@ -17,15 +17,15 @@ package openmessaging type MessageFactory interface { /** - * Creates a {@code Message} object. A {@code Message} object is used to send a message containing a stream of - * uninterpreted bytes. - *
- * The returned {@code Message} object only can be sent to the specified queue. - * - * @param queueName the target queue to send - * @param body the body data for a message - * @return the created {@code Message} object - * @return error when body exceed the maximum length or others. - */ + * Creates a {@code Message} object. A {@code Message} object is used to send a message containing a stream of + * uninterpreted bytes. + *
+ * The returned {@code Message} object only can be sent to the specified queue. + * + * @param queueName the target queue to send + * @param body the body data for a message + * @return the created {@code Message} object + * @return error when body exceed the maximum length or others. + */ CreateMessage(queueName string, body []byte) (Message, error) } diff --git a/openmessaging/oms_built_keys.go b/openmessaging/oms_built_keys.go index 00ee1a5..2370751 100644 --- a/openmessaging/oms_built_keys.go +++ b/openmessaging/oms_built_keys.go @@ -16,9 +16,9 @@ package openmessaging /** - * The {@code DRIVER_IMPL} key represents the vendor implementation - * entry of {@link MessagingAccessPoint}. - */ + * The {@code DRIVER_IMPL} key represents the vendor implementation + * entry of {@link MessagingAccessPoint}. + */ const DRIVER_IMPL = "DRIVER_IMPL" /** diff --git a/openmessaging/producer/producer.go b/openmessaging/producer/producer.go index a7c6155..9b9e437 100644 --- a/openmessaging/producer/producer.go +++ b/openmessaging/producer/producer.go @@ -25,17 +25,17 @@ type Producer interface { ServiceLifecycle MessageFactory /** - * Sends a message to the specified destination synchronously, the destination should be preset to {@link - * Message#headers()}, other header fields as well. - * - * @param message a message will be sent. - * @return the successful {@code SendResult}. - * @return error when have no authority to send messages to a given destination. - * @return error when an invalid message is specified. - * @return error when the given timeout elapses before the send operation completes. - * @return error when have no given destination in the server. - * @return error when the {@code Producer} fails to send the message due to some internal error. - */ + * Sends a message to the specified destination synchronously, the destination should be preset to {@link + * Message#headers()}, other header fields as well. + * + * @param message a message will be sent. + * @return the successful {@code SendResult}. + * @return error when have no authority to send messages to a given destination. + * @return error when an invalid message is specified. + * @return error when the given timeout elapses before the send operation completes. + * @return error when have no given destination in the server. + * @return error when the {@code Producer} fails to send the message due to some internal error. + */ Send(message Message) (SendResult, error) /** diff --git a/openmessaging/producer/transaction_result.go b/openmessaging/producer/transaction_result.go index 5ffa4e9..a7e2fd7 100644 --- a/openmessaging/producer/transaction_result.go +++ b/openmessaging/producer/transaction_result.go @@ -19,10 +19,10 @@ package producer type TransactionalResult interface { SendResult /** - * The unique transactionId id related to the {@code TransactionResult} instance. - * - * @return the transactional id - */ + * The unique transactionId id related to the {@code TransactionResult} instance. + * + * @return the transactional id + */ TransactionId() (string, error) /** diff --git a/openmessaging/producer/transaction_state_check_listener.go b/openmessaging/producer/transaction_state_check_listener.go index 4a777b5..c5fefb3 100644 --- a/openmessaging/producer/transaction_state_check_listener.go +++ b/openmessaging/producer/transaction_state_check_listener.go @@ -43,6 +43,6 @@ type TransactionStateCheckListener interface { * * @param message the associated message. * @param context the check context. - */ + */ Check(message Message, context TransactionalContext) error } diff --git a/openmessaging/service_lifecycle.go b/openmessaging/service_lifecycle.go index 9000f38..8789104 100644 --- a/openmessaging/service_lifecycle.go +++ b/openmessaging/service_lifecycle.go @@ -64,9 +64,9 @@ func (this ServiceLifeState) String() string { type ServiceLifecycle interface { /** - * Used for startup or initialization of a service endpoint. A service endpoint instance will be in a ready state - * after this method has been completed. - */ + * Used for startup or initialization of a service endpoint. A service endpoint instance will be in a ready state + * after this method has been completed. + */ Start() error /** @@ -80,5 +80,5 @@ type ServiceLifecycle interface { * * @return This service current state {@link ServiceLifeState} */ - CurrentState() (ServiceLifeState,error) + CurrentState() (ServiceLifeState, error) }