<s> """<STR_LIT>""" <EOL> from Handler import Handler <EOL> import urllib2 <EOL> class HttpPostHandler ( Handler ) : <EOL> def __init__ ( self , config = None ) : <EOL> Handler . __init__ ( self , config ) <EOL> self . metrics = [ ] <EOL> self . batch_size = int ( self . config [ '<STR_LIT>' ] ) <EOL> self . url = self . config . get ( '<STR_LIT:url>' ) <EOL> def get_default_config_help ( self ) : <EOL> """<STR_LIT>""" <EOL> config = super ( HttpPostHandler , self ) . get_default_config_help ( ) <EOL> config . update ( { <EOL> '<STR_LIT:url>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } ) <EOL> return config <EOL> def get_default_config ( self ) : <EOL> """<STR_LIT>""" <EOL> config = super ( HttpPostHandler , self ) . get_default_config ( ) <EOL> config . update ( { <EOL> '<STR_LIT:url>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:100> , <EOL> } ) <EOL> return config <EOL> def process ( self , metric ) : <EOL> self . metrics . append ( str ( metric ) ) <EOL> if len ( self . metrics ) >= self . batch_size : <EOL> self . post ( ) <EOL> def flush ( self ) : <EOL> """<STR_LIT>""" <EOL> self . post ( ) <EOL> def post ( self ) : <EOL> req = urllib2 . Request ( self . url , "<STR_LIT:\n>" . join ( self . metrics ) ) <EOL> urllib2 . urlopen ( req ) <EOL> self . metrics = [ ] </s>
