func (b *Base) GetReadersData() map[string]interface{} {
	return b.ReadersData
}
GetReadersData returns ReadersData field.
package writers
import (
	"bytes"
	"encoding/json"
	"errors"
	"reflect"
	"github.com/Sirupsen/logrus"
	"github.com/go-fsnotify/fsnotify"
	resourced_config "github.com/resourced/resourced/config"
	"github.com/resourced/resourced/libprocess"
	"github.com/resourced/resourced/libstring"
)
var writerConstructors = make(map[string]func() IWriter)
func Register(name string, constructor func() IWriter) {
	if constructor == nil {
		panic("writer: Register writer constructor is nil")
	}
	if _, dup := writerConstructors[name]; dup {
		panic("writer: Register called twice for writer constructor " + name)
	}
	writerConstructors[name] = constructor
}
func NewGoStruct(name string) (IWriter, error) {
	constructor, ok := writerConstructors[name]
	if !ok {
		return nil, errors.New("GoStruct is undefined.")
	}
	return constructor(), nil
}
func NewGoStructByConfig(config resourced_config.Config) (IWriter, error) {
	writer, err := NewGoStruct(config.GoStruct)
	if err != nil {
		return nil, err
	}
	if len(config.GoStructFields) > 0 {
		for structFieldInString, value := range config.GoStructFields {
			goStructField := reflect.ValueOf(writer).Elem().FieldByName(structFieldInString)
			if goStructField.IsValid() && goStructField.CanSet() {
				valueOfValue := reflect.ValueOf(value)
				goStructField.Set(valueOfValue)
			}
		}
	}
	return writer, err
}
type IWriter interface {
	WatchDir(string, func() error) error
	Run() error
	SetConfigs(*resourced_config.Configs)
	SetReadersDataInBytes(map[string][]byte)
	SetReadersData(map[string]interface{})
	GetReadersData() map[string]interface{}
	SetData(interface{})
	GetData() interface{}
	GetJsonProcessor() string
	GenerateData() error
	ToJson() ([]byte, error)
}
type Base struct {
	Configs       *resourced_config.Configs
	ReadersData   map[string]interface{}
	Data          interface{}
	JsonProcessor string
}
func (b *Base) WatchDir(path string, callback func() error) error {
	watcher, err := fsnotify.NewWatcher()
	if err != nil {
		return err
	}
	defer watcher.Close()
	err = watcher.Add(path)
	if err != nil {
		return err
	}
	for {
		select {
		case event := <-watcher.Events:
			if (event.Op&fsnotify.Create == fsnotify.Create) || (event.Op&fsnotify.Remove == fsnotify.Remove) || (event.Op&fsnotify.Write == fsnotify.Write) || (event.Op&fsnotify.Rename == fsnotify.Rename) {
				logrus.WithFields(logrus.Fields{
					"Path":  path,
					"Event": event.String(),
				}).Info("Changes happened, executing callback")
				callback()
			}
		case err := <-watcher.Errors:
			if err != nil {
				logrus.WithFields(logrus.Fields{
					"Error": err.Error(),
					"Path":  path,
				}).Error("Error while watching path")
			}
		}
	}
	return nil
}
func (b *Base) Run() error {
	return nil
}
func (b *Base) SetConfigs(configs *resourced_config.Configs) {
	b.Configs = configs
}
func (b *Base) SetReadersDataInBytes(readersJsonBytes map[string][]byte) {
	if b.ReadersData == nil {
		b.ReadersData = make(map[string]interface{})
	}
	for key, jsonBytes := range readersJsonBytes {
		var data interface{}
		err := json.Unmarshal(jsonBytes, &data)
		if err == nil {
			b.ReadersData[key] = data
		}
	}
}
func (b *Base) SetReadersData(readersData map[string]interface{}) {
	b.ReadersData = readersData
}