customerimporter

package
v0.0.0-...-62af069 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 14, 2023 License: Unlicense Imports: 13 Imported by: 0

Documentation

Overview

package customerimporter reads from the given customers.csv file and returns a sorted (data structure of your choice) of email domains along with the number of customers with e-mail addresses for each domain. Any errors should be logged (or handled). Performance matters (this is only ~3k lines, but *could* be 1m lines or run on a small machine).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(envFile string) error

Load loads the environment variables from the .env file.

func Run

func Run(log Logger, config *Config) error

Run opens CSV file, prepare a CSV file reader, process email domains and count the occurences and sort email domains by name.

Types

type Config

type Config struct {
	Concurrency              int
	InputCSVFilePathDefault  string
	InputCSVFilePath0Lines   string
	InputCSVFilePath10Lines  string
	InputCSVFilePath3kLines  string
	InputCSVFilePath10mLines string
	ReadBufferSizeInBytes    int
}

Config is a struct which encapsulates .env file variables.

func LoadConfig

func LoadConfig(log Logger, envFilePath string) (*Config, error)

LoadConfig loads the configuration from the .env file.

func LoadConfigTest

func LoadConfigTest(log Logger, envFilePath string) (*Config, error)

LoadConfigTest loads the configuration from the .env file for tests

type Customer

type Customer struct {
	FirstName string
	LastName  string
	Email     string
	Gender    string
	IPAddress string
}

Customer struct represents a customer record in the CSV file.

type DomainCounter

type DomainCounter struct {
	// contains filtered or unexported fields
}

DomainCounter is a struct made for convenience for the results channel.

type Logger

type Logger interface {
	Info(msg string, keyVals ...interface{})
	Warn(msg string, keyVals ...interface{})
	Error(msg string, keyVals ...interface{})
}

Logger is an interface representing the required logging methods.

type MockLogger

type MockLogger struct {
	Logs []string
}

MockLogger is a mock implementation of the Logger interface.

type Task

type Task struct {
	// contains filtered or unexported fields
}

Task is a struct of CSV file records (size of this slice depends of the reader's buffer).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL