<commit_before>// Copyright 2014 <NAME>. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

package ipe

import (
	"time"

	log "github.com/golang/glog"
)

// socket interface to write to the client
type socket interface {
	WriteJSON(interface{}) error
}

// mockSocket is a mock implementation of socket
// used in the test suite
type mockSocket struct{}

func (s mockSocket) WriteJSON(i interface{}) error {
	return nil
}

// An User Connection
type connection struct {
	SocketID  string
	Socket    socket
	CreatedAt time.Time
}

// Create a new Subscriber
func newConnection(socketID string, s socket) *connection {
	log.Infof("Creating a new Subscriber %+v", socketID)

	return &connection{SocketID: socketID, Socket: s, CreatedAt: time.Now()}
}

// Publish the message to websocket atached to this client
func (conn *connection) Publish(m interface{}) {
	go func() {
		if err := conn.Socket.WriteJSON(m); err != nil {
			log.Errorf("Error publishing message to connection %+v, %s", conn, err)
		}
	}()
}<commit_msg>Sending messages without a goroutine<commit_after>// Copyright 2014 <NAME>. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

package ipe

import (
	"time"

	log "github.com/golang/glog"
)

// socket interface to write to the client
type socket interface {
	WriteJSON(interface{}) error
}

// mockSocket is a mock implementation of socket
// used in the test suite
type mockSocket struct{}

func (s mockSocket) WriteJSON(i interface{}) error {
	return nil
}

// An User Connection
type connection struct {
	SocketID  string
	Socket    socket
	CreatedAt time.Time
}

// Create a new Subscriber
func newConnection(socketID string, s socket) *connection {
	log.Infof("Creating a new Subscriber %+v", socketID)

	return &connection{SocketID: socketID, Socket: s, CreatedAt: time.Now()}
}

// Publish the message to websocket atached to this client
func (conn *connection) Publish(m interface{}) {
	conn.Socket.WriteJSON(m)
}
{'fraction_non_alphanumeric': 0.10043041606886657, 'fraction_numerical': 0.003825920612147298, 'mean_word_length': 4.040963855421687, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5585382', 'n_tokens_mistral': 638, 'n_tokens_neox': 620, 'n_words': 253}