// ReadAll will read all events from the event store by internally creating a
// a subscription and depleting it until io.EOF is encountered
// WARNING: Use with caution as this method will read the entire event store
// in a blocking fashion (porbably best used in combination with offset option)
ReadAll will read all events from the event store by internally creating a
a subscription and depleting it until io.EOF is encountered
WARNING: Use with caution as this method will read the entire event store
in a blocking fashion (porbably best used in combination with offset option)
// ReadAll will read all events from the event store by internally creating a // a subscription and depleting it until io . EOF is encountered // WARNING : Use with caution as this method will read the entire event store // in a blocking fashion ( porbably best used in combination with offset option )
func (es *EventStore) ReadAll(ctx context.Context, opts ...SubAllOpt) ([]EventData, error) {
	sub, err := es.SubscribeAll(ctx, opts...)
	if err != nil {
		return nil, err
	}
	defer sub.Close()
	var evts []EventData
	for {
		select {
		case data := <-sub.EventData:
			evts = append(evts, data)
		case err := <-sub.Err:
			if errors.Is(err, io.EOF) {
				return evts, nil
			}
			return nil, err
		}
	}
}
func ( es * EventStore ) ReadAll ( ctx context . Context , opts ... SubAllOpt ) ( [ ] EventData , error ) { sub , err := es . SubscribeAll ( ctx , opts ... ) if err != nil { return nil , err } defer sub . Close ( ) var evts [ ] EventData for { select { case data := <- sub . EventData : evts = append ( evts , data ) case err := <- sub . Err : if errors . Is ( err , io . EOF ) { return evts , nil } return nil , err } } }
ReadAll will read all events from the event store by internally creating a
a subscription and depleting it until io.EOF is encountered
WARNING: Use with caution as this method will read the entire event store
in a blocking fashion (porbably best used in combination with offset option)
ReadAll will read all events from the event store by internally creating a a subscription and depleting it until io . EOF is encountered WARNING : Use with caution as this method will read the entire event store in a blocking fashion ( porbably best used in combination with offset option )