38 Commits
Author SHA1 Message Date
RomainandGitHub bc580c56fe One side buffering 2026-01-26 10:38:03 +01:00
Fernandez Ludovic f97e824631 chore: update linter 2025-07-15 16:00:27 +02:00
Adam DukeandGitHub 18a66b7d02 buffer: handle bufferWriter error (#247) 2025-03-29 00:00:17 +01:00
Fernandez Ludovic caffa2a271 Revert "fix(buffer): follow the retry predicate (#234)"
This reverts commit 6598e6a3ce.
2023-04-27 15:22:21 +02:00
Ngọc LongandGitHub 4a744c3d60 Reduce gRPC status checking overhead (#237) 2023-04-25 15:32:49 +02:00
Ngọc LongandGitHub 74b5e48548 feat(buffer): Support gRPC and gRPC Web. (#236) 2023-04-17 10:28:32 +02:00
Ludovic FernandezandGitHub 6598e6a3ce fix(buffer): follow the retry predicate (#234) 2023-03-13 09:44:20 +01:00
Ludovic FernandezandGitHub bb7fce4ebe fix(buffer): handle context with multibuf (#232) 2023-02-27 14:54:49 +01:00
Fernandez Ludovic f9b24bada2 feat: rename Debug to Verbose 2022-11-21 16:14:23 +01:00
Fernandez Ludovic 6df7a99088 feat: follow slog interface 2022-11-19 13:26:41 +01:00
Fernandez Ludovic 736173ce4c feat: rewrite options and logger 2022-11-11 00:31:09 +01:00
Fernandez Ludovic 46587e0d00 feat: major version of the module 2022-11-07 11:37:22 +01:00
Fernandez Ludovic 2bd95e442a feat: cleaning the deprecated elements 2022-11-07 10:24:03 +01:00
Fernandez Ludovic d40451c79f chore: update linter 2022-11-07 09:50:18 +01:00
Kevin PolletandGitHub 94cfe4b463 buffer: fix typo in hijack algorithm (#228) 2022-11-04 15:22:35 +01:00
Fernandez Ludovic d43b3ad9b9 chore: linting 2022-05-07 13:17:39 +02:00
Fernandez Ludovic e5c657ef5f fix: apply linting 2022-05-05 00:28:29 +02:00
Iman SahebiandGitHub f3cca5810d fix typo (#212) 2021-02-08 20:11:44 +01:00
Wes TurnerandGitHub 43c3f1a380 doc: buffer.go: s/request/response/ (#172) 2020-11-06 04:05:20 +01:00
MichaelandEmile Vauge bf2c8a177a fix: body should never be nil (#162) 2018-10-10 16:42:06 +02:00
Ludovic FernandezandEmile Vauge 03d1469f5a fix: use internal logger. (#160) 2018-09-21 17:08:36 +02:00
Ludovic FernandezandEmile Vauge d254a6d78a fix: buffer error and go1.11. (#159)
* fix: buffer error and go1.11.

* chore: add go1.11 in Travis.

* review: comment.
2018-09-04 12:28:44 +02:00
Ludovic FernandezandEmile Vauge 510e0d1bfc refactor: migrate from go-check to Testify. (#146) 2018-07-09 16:30:28 +02:00
Ludovic FernandezandArchis f905dbdc10 Linting (#144)
* refactor: minor code changes.

* fix: checks-fmt.

* refactor: comments.
2018-07-07 06:23:06 -07:00
Andreas LinzandArchis 1bff799876 Implement context logger for remaining packages (#94)
* Fix doc comment for Stream option setter

This was left from long ago.

* Allow setting the logger the forwarder uses

* Document the Logger option

* Use logrus.StandardLogger() as the default

This means the behaviour will be the same as before, e.g. global
logrus settings will be set on the forward logger by default.

* Implement context-logger for buffer package

* Fix a typo

compete → complete

* Implement context-logger for circuit breaker package

There is one single place where the context-logger is not implemented
and this is cbreaker/predicates.go:53 because it had required to change
the API.

* Implement context-logger for connection limiter package

* Implement context-logger for rate limiter package

* Implement context-logger for round-robin package

* Implement context-logger for stream package

* Implement context-logger for trace package

* Rename opt-setter to fix redeclaration

* Use context logger's level

* Modify context-logger properties directly

This is required because the setter's are not part of the Logger
interface.

* Set standard logger for {Default,Error}Handler

* Use logger from CircuitBreaker

* Remove leftover import

* Fix some copy-paste errors

* Remove redundant logger setup

* Remove unused logger

* Implement context-logger for ProxyWriter

A pair of constructors was added so a default logger is set.
Instantiating the ProxyWriter struct without setting a logger would have
caused a nil pointer exception.

* Fix missing usages of context-logger

Ripgrep to the rescue:

$ rg --sort-files --regexp '\s+log\.'

* Fix build breaks with context logger

* Match log levels of newer commits
2018-07-07 01:31:53 -07:00
Justin HunterandEmile Vauge 66ca30d5f1 fix typo of completed (competed) (#128) 2018-05-24 10:01:36 +02:00
Larry.HeandArchis 622826f37f fix buffer chunked response (#113) (#123) 2018-03-13 07:50:15 -07:00
Ludovic FernandezandEmile Vauge 406c987b90 fix: conditional setter. (#119) 2018-02-15 15:09:24 +01:00
Ludovic FernandezandEmile Vauge 757ecaf2d2 Buffer: conditional setter (#118)
* refactor: rename parameter.

* feature: add conditional setter.
2018-02-12 15:12:49 +01:00
Ludovic FernandezandEmile Vauge 179a64f105 Logs level and Forwarder Logger (#117)
* refactor: change logs level.

* refactor: change logger type in forwarder.
2018-02-12 11:18:57 +01:00
Ludovic FernandezandEmile Vauge 1fe46d1aeb Enhance code quality analysis (#104)
* chore: add new Make targets.

* refactor: code review.

* chore(travis): go import path.
2017-12-18 10:25:18 +01:00
nvartolomeiandArchis d767e22291 Go 1.8 fixes (#89)
* Fix buffer tests for Go 1.6+

* Fix forward test under Go 1.6+

* Do not send chunked requests for empty body.

See https://beta.golang.org/doc/go1.8#net_http

* Add Go 1.6.x, 1.7.x, 1.8.x to Travis
2017-09-28 07:16:12 -07:00
arthur 09873248fd fix logrus path 2017-07-10 18:06:33 +08:00
ArchisandGitHub 017b1c168e Simplify fwd.go, and enable WSS (Websockets over TLS) (#73)
* Added Hijack and CloseNotifier interfaces

When testing an upgrade to WebSocket connections,
I noticed that the buffer.bufferWriter ResponseWriter proxy
does not implement the Hijack or CloseNotify methods.

The Hijack method is of prominence here - it allows the websockets code
to hijack the connection and run the WS proxy inline. Without that
any Frontends would have trouble upgrading the connection in the forwarder.

The CloseNotifier is more for house-keeping. It allows http.Serve to terminate
in-flight connections to backends, when the client-side connection breaks.

That means if a browser closes a tab, or you "CTRL+C" out of
a wget/curl, it'll rapidly clean up the dependent connections to vulcan's
backend.

This is useful for resource saving under either long-lived or high-latency
 connections.

* Don't write anything once connection has been  hijacked

* Added logs to Websocket proxying

* Only error when there is an error

* Web sockets use TLS

* Outgoing scheme must be wss to use tls.Dial

* Better WSS/WS dial

* Gofmt

* Consolidated all code against one forwarder with different Service methods

* Accidentally deleted DefaultTransport

* Re-introduce Header Rewriter in Websockets

Figured out why web sockets weren't working with the
rewriter.

Turns out, removing Hop-By-Hop headers was also removing
the Connection and Upgrade headers which are crucial
for the dial.

This change modifies the HeaderRewriter
to not remove Hop-By-Hop headers when it's a
WebSocket request.

This ensures all Websocket receipients still get
all the X-Forward* headers for better logging,
monitoring and decision-making.

* Missed a reference in the unit test to the renamed function.

* Added a RequestRewriteListener

In many situations where we consume Oxy,
it is useful to have informaiton on the routing
decisions made by RR and Rebalancer, on a per-request
level.

I made a similar change to the Forwarder where there's
a UrlForwardingStateListener to be able to figure
out when a connection is attempted and when it ends.

Logs are useful, but they're not easily parsable
in-proc. And sometimes it can be useful to know
which backends were selected to use, and which ones
are unused (for whatever reason.)

Initially I had an info-level log (which I still think
is beneficial), but now at a DebugLevel, and instead
delegate the introspection/logging through
this listener instead.

Also added Unit tests to ensure it works and is
wired in correctly. All tests are passing.
2017-05-31 14:30:23 -07:00
ArchisandGitHub 10e6c1ab57 Logging revamp (#64) (#67)
* Logging revamp (#64)

* Logging revamp

This change revamps logging in the following ways:
1. In the buffer (and any place really) where an error is returned,
   the log type is "Error" consistently, rather than info.

2. In ALL middlewares is a debug-level log that is emitted when a
   request is beginning to be served, and once when the ServeHTTP
   method exits (using defer). This allows, under debug conditions,
   a way to trace the flow of a request.

3. Finally, an important log entry which I feel was always missing,
   was an info-level entry that mentioned which specific backend
   server a particular request hit.

More logging improvements

More logging improvements

Http Streaming forwarder wasn't using ProxyWriter at all.

This was a fix made by Roy Sundahl. I'm merging it in here.

Attach standard logger as error logger for reverse proxy.

Revert "Attach standard logger as error logger for reverse proxy."

This reverts commit a39e0e7a1c9ecbd13af945a684a81fcaaa5a51f2.

Added an HTTP Request serializer for logging

Updated Serializer for http.Request objects

The challenge with logrus is it uses json.Marshall to serialize
object fields, but will log nothing if there's a marshalling error.

This prevented http.Request from getting serialized, and thus prevented
the entire entry from being logged.

By using httputil.DumpRequest, this change serializes
all http.Request objects (even if there's an error), and makes
sure a log entry is pushed.

Use JSON Serializer so the request is machine-parsable.

Revert "Use JSON Serializer so the request is machine-parsable."

This reverts commit a99a99299f2300dcaab1bb479c3f53cc1d76cc50.

Request serializer was a bad idea.

Attempting to serialize requests was a bad idea.

Serialize Http Request

Go fmt

* Fixed UT

Due to different golang versions, the fields in the struct
http.Request might be different across different runs of
the Unit Test. That means verifying that an http.Request correctly
serializes to a JSON String is not a fixed predictable operation
that is also portable across golang versions.

This change modifies the test to simply ensure length of the
generated string is more than zero.

Gated all expensive logs behind their log level.

This will ensure that if the log level is
what the log entry is, expensive processing
of serializing a full HTTP request isn't performed
per log entry.

* Added a benchmark test
2017-04-21 11:50:41 -05:00
ArchisandGitHub bac7799115 Revert "Logging revamp (#64)" (#66)
This reverts commit f3e1c9ca8e.
2017-04-20 19:58:53 -05:00
ArchisandGitHub f3e1c9ca8e Logging revamp (#64)
* Logging revamp

This change revamps logging in the following ways:
1. In the buffer (and any place really) where an error is returned,
   the log type is "Error" consistently, rather than info.

2. In ALL middlewares is a debug-level log that is emitted when a
   request is beginning to be served, and once when the ServeHTTP
   method exits (using defer). This allows, under debug conditions,
   a way to trace the flow of a request.

3. Finally, an important log entry which I feel was always missing,
   was an info-level entry that mentioned which specific backend
   server a particular request hit.

More logging improvements

More logging improvements

Http Streaming forwarder wasn't using ProxyWriter at all.

This was a fix made by Roy Sundahl. I'm merging it in here.

Attach standard logger as error logger for reverse proxy.

Revert "Attach standard logger as error logger for reverse proxy."

This reverts commit a39e0e7a1c9ecbd13af945a684a81fcaaa5a51f2.

Added an HTTP Request serializer for logging

Updated Serializer for http.Request objects

The challenge with logrus is it uses json.Marshall to serialize
object fields, but will log nothing if there's a marshalling error.

This prevented http.Request from getting serialized, and thus prevented
the entire entry from being logged.

By using httputil.DumpRequest, this change serializes
all http.Request objects (even if there's an error), and makes
sure a log entry is pushed.

Use JSON Serializer so the request is machine-parsable.

Revert "Use JSON Serializer so the request is machine-parsable."

This reverts commit a99a99299f2300dcaab1bb479c3f53cc1d76cc50.

Request serializer was a bad idea.

Attempting to serialize requests was a bad idea.

Serialize Http Request

Go fmt

* Fixed UT

Due to different golang versions, the fields in the struct
http.Request might be different across different runs of
the Unit Test. That means verifying that an http.Request correctly
serializes to a JSON String is not a fixed predictable operation
that is also portable across golang versions.

This change modifies the test to simply ensure length of the
generated string is more than zero.
2017-04-15 09:03:37 -07:00
ArchisandGitHub e7b38e42b9 Rename "Stream" to "Buffer", and make "Stream" a pass-through for now (#45)
* Renamed Stream to Buffer

This handles the issue: https://github.com/vulcand/oxy/issues/9

It is a better name and helps clarify what the intent and function of this
object is.

* Forked the original stream into Buffer.

* Fixed a build break

* Simplified stream to be pass-through for now.

* Most UTs for stream expect StatusOk as return code

* More updates towards allowing streaming

1. Initial run at the feedback received on the code review, namely,
   updated all comments/docs to say "buffer" in the buffer part of the
   code, and fixed the mistaken package "steam" to "stream"

2. In fwd.go, replaced RoundTripper with ReverseProxy when
   the stream flag is provided. Not sure yet ReverseProxy
   won't buffer and wait for EOF to flush bytes down to the client
   but having a httpStreamingForwarded as a playground, ensures
   the working version of the forwarded isn't affected by any bugs/mistakes
   I introduce.

* Finished up the httpStreamingForwarder.

* Externalize FlushInterval, with a default, and add a URL connect/disconnect listener.

* Make URL to listener, a pointer so listeners can track them correctly.

* Go fmt

* Updated documentation for stream

* Rename Stream test correctly.

* Rebased against master

* Merge artifact removed

* Added a chunked transfer encoding unit test.
2016-08-30 11:35:57 -07:00