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

Mailbox Refactor #13

Open
influx6 opened this issue Jan 31, 2019 · 0 comments
Open

Mailbox Refactor #13

influx6 opened this issue Jan 31, 2019 · 0 comments
Assignees

Comments

@influx6
Copy link
Owner

influx6 commented Jan 31, 2019

The current implementation of Mailbox interface and it's implementation and their Envelope type, are abit under-designed, the interface leaks some methods from implementation causing Interface Poisoning which is bad design after much thought, we need to at a suitable time, reconsider a refactor of both the interface and it's implementation (the default MailboxImpl).

I personal feel that the underline mechanism for giving mailbox should be pulled based initially, because a pull based system can easily be converted to a push based system based on some wrapping. I am also favorable to the the idea of reactive streams, so we should consider such in our refactoring.

// Mailbox is a one-subscription publisher of envelope messages.
type Mailbox interface {
  Subscribe (MailSubscriber) (MailSubscription, error)
}

type MailSubscription interface{
   Stop()
   Next(batch int) error
}

type MailSubscriber interface {
  Stopped()
  Error(error)
  Completed()
  Next(EnvelopeMessage) error
}

type EnvelopeMessage interface{
  Encode(encoder EnvelopeEncoder)  error

  Meta(string) (interface{}, error)
  Payload() interface{}
  Ref() string
  Epoch() int64
}

type EnvelopeEncoder interface{
  EncodeRef(string) error
  EncodeEpoch(int64) error
  EncodePayload(interface{}) error
  EncodeMeta(string, interface{}) error
}

Think more on this.

@influx6 influx6 self-assigned this Jan 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant