func (fp *FilePersistorAddOn) OnShutdown() {
	close(fp.publishedEvents)
	<-fp.shutdownDone
}
OnShutdown will signal the run goroutine to flush any remaining event data
to disk and wait for it to complete.
package golongpoll
import (
	"bufio"
	"encoding/json"
	"errors"
	"fmt"
	"log"
	"os"
	"time"
)
type FilePersistorAddOn struct {
	filename string
	writeBufferSize int
	writeFlushPeriodSeconds int
	publishedEvents chan *Event
	shutdownDone chan bool
}
func NewFilePersistor(filename string, writeBufferSize int, writeFlushPeriodSeconds int) (*FilePersistorAddOn, error) {
	if writeBufferSize < 1 {
		return nil, errors.New("writeBufferSize must be > 0")
	}
	if writeFlushPeriodSeconds < 1 {
		return nil, errors.New("writeFlushPeriodSeconds must be > 0")
	}
	if len(filename) < 1 {
		return nil, errors.New("filename cannot be empty")
	}
	f, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE, 0755)
	if err != nil {
		return nil, fmt.Errorf("Error opening file for filename. Error: %v", err)
	}
	f.Close()
	eventsIn := make(chan *Event, 100)
	fp := FilePersistorAddOn{
		filename:                filename,
		writeBufferSize:         writeBufferSize,
		writeFlushPeriodSeconds: writeFlushPeriodSeconds,
		publishedEvents:         eventsIn,
		shutdownDone:            make(chan bool, 1),
	}
	return &fp, nil
}
func (fp *FilePersistorAddOn) OnLongpollStart() <-chan *Event {
	ch := make(chan *Event, 100)
	go fp.getOnStartInputEvents(ch)
	go fp.run()
	return ch
}
func (fp *FilePersistorAddOn) OnPublish(event *Event) {
	fp.publishedEvents <- event
}