Skip to content

trafficland/elblogparser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ELB Log Parser

Using the parser is pretty straight forward.

import com.trafficland.elblogparser._

def main(args: Array[String]): Unit = {
    val parser = ELBRecordParser()
    
    val unparsedRecord: String = ??? // A string from an ELB access log.   
    parser.parse(unparsedRecord) { result: RecordParsingResult =>
      ??? // Do something with the result.  
    }
}

Design Notes

For efficiency, the parser is built for reuse. Every time parser.parse(_) is called the internal buffers are cleared. This cuts down on allocations.

The reason parser.parse(_) takes a callback, as opposed to taking a Seq[String] and returning a Seq[RecordParsingResult], is because if the ELB producing billions of records it may not be reasonable to store the records in memory. By taking a callback the developer using this library is given a functional way of handling the results.