Documentation ¶
Overview ¶
Package parse of the Dataflow kit is used by parse.d service which parses html content from web pages following the rules described in Payload JSON file.
Index ¶
- func DecodeParseRequest(ctx context.Context, r *http.Request) (interface{}, error)
- func EncodeParseResponse(_ context.Context, w http.ResponseWriter, response interface{}) error
- func HealthCheckHandler(w http.ResponseWriter, r *http.Request)
- func MakeParseEndpoint(svc Service) endpoint.Endpoint
- func NewHttpHandler(ctx context.Context, endpoint Endpoints) http.Handler
- type Config
- type Endpoints
- type HTMLServer
- type ParseService
- type Service
- type ServiceMiddleware
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeParseRequest ¶
DecodeParseRequest decodes request sent to Parser if error occures, server returns 400 Bad Request
func EncodeParseResponse ¶
func EncodeParseResponse(_ context.Context, w http.ResponseWriter, response interface{}) error
EncodeParseResponse encodes response returned by Parser
func HealthCheckHandler ¶
func HealthCheckHandler(w http.ResponseWriter, r *http.Request)
HealthCheckHandler is used to check if Parse service is alive
func MakeParseEndpoint ¶
MakeParseEndpoint creates Parse Endpoint
Types ¶
type HTMLServer ¶
type HTMLServer struct {
// contains filtered or unexported fields
}
HTMLServer represents the web service that serves up HTML
type ParseService ¶
type ParseService struct { }
ParseService implements service with empty struct
func (ParseService) Parse ¶
func (ps ParseService) Parse(p scrape.Payload) (io.ReadCloser, error)
Parse service processes fetched page following the rules from Payload.
type Service ¶
type Service interface {
Parse(scrape.Payload) (io.ReadCloser, error)
}
Service defines Parse service interface
func NewHTTPClient ¶
NewHTTPClient returns an Parse Service backed by an HTTP server living at the remote instance. We expect instance to come from a service discovery system, so likely of the form "host:port". We bake-in certain middlewares, implementing the client library pattern.
type ServiceMiddleware ¶
ServiceMiddleware defines a middleware for a Parse service
func LoggingMiddleware ¶
func LoggingMiddleware(logger *zap.Logger) ServiceMiddleware
LoggingMiddleware logs Parse Service endpoints