Comments (3)
This problem will last even after merging #82
from fluent-logger-golang.
@tagomoris Are you already working on this? 🙂
About the implementation details, I have the following solution in mind that would be lock-free:
- Start an
ackRecv()
goroutine innewWithDialer
whenAck == true
- Use a dedicated channel (eg. named
acksCh
) to communicate betweenwrite()
andackRecv()
- Create an ack channel for each message in
write()
to communicate back fromackRecv()
towrite()
- Send a struct containing the ack ID, the ack channel and bool (with true value) from
write()
toackRecv()
(before actually writing to the connection, to avoid race conditions) - Block the
write()
until either the ack channel or a timeout channel got triggered
i. If the the timeout channel got triggered, resend the same struct as 4. but with the bool turned false. - Concurrently read from the
acksCh
and the socket
i. When an "ack request" is received fromacksCh
put it in a local map[string]struct{} if the bool is true or remove it if the bool is false.
ii. When an ack response is received from the socket, check if there's a matching ID in the local map and send astruct{}
to the appropriate channel and remove it from the local map. - When
Close()
is called,acksCh
got closed
i. Set a localshouldClose
bool to true inacksRecv()
ii. When the last ackMessage is received or removed from the local map (cf. 6.) andshouldClose
is true, exit fromacksRecv()
My only concern with this solution is regarding #104.
from fluent-logger-golang.
I've not worked on this yet - no plans for now.
@akerouanton Your idea was an alternative. I don't have enough knowledge about the creation cost of dedicated channels, so I can't evaluate which is better - but the idea of using channels seems a golang-ish solution.
from fluent-logger-golang.
Related Issues (20)
- tagomoris will step down from the maintainer HOT 4
- Calls to Write() after calling Close() in sync mode reopen the connection HOT 5
- Migrate testing to Go's testing package HOT 1
- Release v1.8.0 HOT 5
- Feature: periodically reconnect to fluentd-address HOT 1
- Add a new option TLSCertPath
- Option to skip loggertag and timestamp
- Support for fluentd `shared_key` and `user_auth`
- Panic if TLS fluentd server cannot be connected
- Support to take TLS certificate in case of tls enabled
- Fluent-bit Supported
- RequestAck usage
- What should be the source configuration to use fluent-logger-golang? HOT 1
- Add WithContext methods to Fluent struct
- Change in semantics of config.BufferLimit with addition of RequestAck in 1.4 HOT 5
- Unknown writing error: MaxRetry shows zero HOT 3
- Update README to describe Config parameters clearly HOT 1
- How to forward output plugin records HOT 3
- Passing struct pointers to `Post` method HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fluent-logger-golang.