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:
parent
c33ef8631b
commit
b29cedfb34
@ -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
|
||||
}
|
||||
|
||||
@ -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}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user