<commit_before>package eventmanager

import "time"

// Event manager structure
type EventManager struct {
	Storage    Storage
	Dispatcher DispatcherContract
	Recorder   Recorder
}

// Attaches a subscriber to an event
func (e *EventManager) Attach(eventName string, sub Subscriber) {
	e.Storage.Attach(eventName, sub)
}

// Dispatches the event across all the subscribers
func (e *EventManager) Dispatch(eventName string, eventState interface{}) {
	subscribers := e.Storage.Subscribers(eventName)
	e.Dispatcher.Dispatch(eventName, eventState, subscribers)
	record(e.Recorder, eventName, eventState)
}

// Dispatches the event across all the subscribers
func (e *EventManager) GoDispatch(eventName string, eventState interface{}) {
	subscribers := e.Storage.Subscribers(eventName)
	e.Dispatcher.GoDispatch(eventName, eventState, subscribers)
	record(e.Recorder, eventName, eventState)
}

// De attaches a subscriber from an event
func (e *EventManager) DeAttach(eventName string, subscriber Subscriber) {
	e.Storage.DeAttach(eventName, subscriber)
}

// Record the current event
func record(r Recorder, eventName string, eventState interface{}) {
	if nil != r {
		r.SnapShot(eventName, eventState, time.Now())
	}
}

// Factory method for the event manager
func NewEventManager(storage Storage, dispatcher DispatcherContract, recorder Recorder) *EventManager {
	return &EventManager{
		storage,
		dispatcher,
		recorder,
	}
}<commit_msg>Added nil recorder else of check statement<commit_after>package eventmanager

import "time"

// Event manager structure
type EventManager struct {
	Storage    Storage
	Dispatcher DispatcherContract
	Recorder   Recorder
}

// Attaches a subscriber to an event
func (e *EventManager) Attach(eventName string, sub Subscriber) {
	e.Storage.Attach(eventName, sub)
}

// Dispatches the event across all the subscribers
func (e *EventManager) Dispatch(eventName string, eventState interface{}) {
	subscribers := e.Storage.Subscribers(eventName)
	e.Dispatcher.Dispatch(eventName, eventState, subscribers)
	record(e.Recorder, eventName, eventState)
}

// Dispatches the event across all the subscribers
func (e *EventManager) GoDispatch(eventName string, eventState interface{}) {
	subscribers := e.Storage.Subscribers(eventName)
	e.Dispatcher.GoDispatch(eventName, eventState, subscribers)
	record(e.Recorder, eventName, eventState)
}

// De attaches a subscriber from an event
func (e *EventManager) DeAttach(eventName string, subscriber Subscriber) {
	e.Storage.DeAttach(eventName, subscriber)
}

// Record the current event
func record(r Recorder, eventName string, eventState interface{}) {
	r.SnapShot(eventName, eventState, time.Now())
}

type NilRecorder bool

func (n *NilRecorder) SnapShot(string, interface{}, time.Time) {

}

// Factory method for the event manager
func NewEventManager(storage Storage, dispatcher DispatcherContract, recorder Recorder) *EventManager {
	if nil == recorder {
		recorder = new(NilRecorder)
	}
	return &EventManager{
		storage,
		dispatcher,
		recorder,
	}
}
{'fraction_non_alphanumeric': 0.09349190617773373, 'fraction_numerical': 0.0, 'mean_word_length': 5.525862068965517, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7508303', 'n_tokens_mistral': 943, 'n_tokens_neox': 893, 'n_words': 271}