Introduce DataCollection and DataStream (#125)

This commit does the following:

- Renames DataStream to DataCollection since that describes better the interface
- Introduces DataStream as a streamable item within this collection
This commit is contained in:
Vaibhav Kamra 2022-06-03 14:44:23 -07:00 committed by GitHub
parent c33ef8631b
commit b29cedfb34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 8 deletions

View File

@ -1,12 +1,36 @@
package connector
// A DataStream provides an iterator to consume a
// collection of graph data of the same type (e.g. mail)
type DataStream interface{}
import "io"
// A DataCollection represents a collection of data of the
// same type (e.g. mail)
type DataCollection interface {
// Returns either the next item in the collection or an error if one occurred.
// If not more items are available in the collection, returns (nil, nil).
NextItem() (DataStream, error)
}
// DataStream represents a single item within a DataCollection
// that can be consumed as a stream
type DataStream interface {
// ToReader returns a reader for the data stream
ToReader() io.Reader
// Provides a unique identifier for this data
UUID() string
}
// ExchangeDataCollection represents exchange mailbox
// data for a single user. It implements the DataStream
// interface which allows reading data in the collection
// data for a single user.
//
// It implements the DataCollection interface
type ExchangeDataCollection struct {
user string
}
// NextItem returns either the next item in the collection or an error if one occurred.
// If not more items are available in the collection, returns (nil, nil).
func (*ExchangeDataCollection) NextItem() (DataStream, error) {
// TODO: Return the next "to be read" item in the collection as a
// DataStream
return nil, nil
}

View File

@ -120,8 +120,8 @@ func (gc *GraphConnector) GetUsersIds() []string {
return values
}
// ExchangeDataStream returns a DataStream that the caller can
// use to stream mailbox data out for the specified user
func (gc *GraphConnector) ExchangeDataStream(user string) DataStream {
// ExchangeDataStream returns a DataCollection that the caller can
// use to read mailbox data out for the specified user
func (gc *GraphConnector) ExchangeDataCollection(user string) DataCollection {
return &ExchangeDataCollection{user: user}
}