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

Use type transactionID #218

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 4 additions & 4 deletions agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type Handler func(e Event)
// Event is passed to Handler describing the transaction event.
// Do not reuse outside Handler.
type Event struct {
TransactionID [TransactionIDSize]byte
TransactionID transactionID
Message *Message
Error error
}
Expand All @@ -77,7 +77,7 @@ var (

// StopWithError removes transaction from list and calls handler with
// provided error. Can return ErrTransactionNotExists and ErrAgentClosed.
func (a *Agent) StopWithError(id [TransactionIDSize]byte, err error) error {
func (a *Agent) StopWithError(id transactionID, err error) error {
a.mux.Lock()
if a.closed {
a.mux.Unlock()
Expand All @@ -101,7 +101,7 @@ func (a *Agent) StopWithError(id [TransactionIDSize]byte, err error) error {

// Stop stops transaction by id with ErrTransactionStopped, blocking
// until handler returns.
func (a *Agent) Stop(id [TransactionIDSize]byte) error {
func (a *Agent) Stop(id transactionID) error {
return a.StopWithError(id, ErrTransactionStopped)
}

Expand All @@ -113,7 +113,7 @@ var ErrAgentClosed = errors.New("agent is closed")
// Could return ErrAgentClosed, ErrTransactionExists.
//
// Agent handler is guaranteed to be eventually called.
func (a *Agent) Start(id [TransactionIDSize]byte, deadline time.Time) error {
func (a *Agent) Start(id transactionID, deadline time.Time) error {
a.mux.Lock()
defer a.mux.Unlock()
if a.closed {
Expand Down
Loading