Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/openmessaging-go

go 1.12
Original file line number Diff line number Diff line change
Expand Up @@ -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)

/**
Expand All @@ -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}.
Expand Down
46 changes: 46 additions & 0 deletions openmessaging/common/messaging_access_point_test.go
Original file line number Diff line number Diff line change
@@ -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")
}
22 changes: 11 additions & 11 deletions openmessaging/consumer/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* <p>
* 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.
* <p>
* 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

/**
Expand Down Expand Up @@ -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.
Expand Down
26 changes: 13 additions & 13 deletions openmessaging/consumer/message_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@ import (

type Context interface {
/**
* Acknowledges the specified and consumed message, which is related to this {@code MessageContext}.
* <p>
* 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}.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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
}
16 changes: 8 additions & 8 deletions openmessaging/headers.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ type Headers interface {
* specified destination.
* <p>
* 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)

/**
Expand Down Expand Up @@ -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)

/**
Expand Down
14 changes: 7 additions & 7 deletions openmessaging/interceptor/consumer_interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import (

type ConsumerInterceptor interface {
/**
* Invoked before the message is actually sent to the network.
* <p>
* 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.
* <p>
* 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

/**
Expand Down
8 changes: 4 additions & 4 deletions openmessaging/interceptor/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
14 changes: 7 additions & 7 deletions openmessaging/interceptor/producer_interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import (

type ProducerInterceptor interface {
/**
* Invoked before the message is actually sent to the network.
* <p>
* 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.
* <p>
* 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

/**
Expand Down
10 changes: 5 additions & 5 deletions openmessaging/key_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 <tt>key</tt>
*/
* 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 <tt>key</tt>
*/
PutInt16(key string, value int16) (KeyValue, error)

/**
Expand Down
4 changes: 2 additions & 2 deletions openmessaging/manager/resource_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions openmessaging/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

/**
Expand Down
20 changes: 10 additions & 10 deletions openmessaging/message_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* <p>
* 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.
* <p>
* 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)
}
6 changes: 3 additions & 3 deletions openmessaging/oms_built_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

/**
Expand Down
22 changes: 11 additions & 11 deletions openmessaging/producer/producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

/**
Expand Down
8 changes: 4 additions & 4 deletions openmessaging/producer/transaction_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

/**
Expand Down
Loading