Git Product home page Git Product logo

Comments (4)

tigrannajaryan avatar tigrannajaryan commented on June 15, 2024 1

FYI, we protect the connection with a mutex in our example. So it seems reasonable to just move this mutex inside the connection struct and have proper encapsulation.

One argument against having the mutex in the connection is that in the server implementation one may have a mutex per agent anyway (e.g. to protect agent's data fields) and that same mutex can be used to protect the connection. However, we don't do it in our example (we have a separate mutex for data fields) so perhaps the combined mutex is not such a good option (otherwise why don't we use it?).

from opamp-go.

andykellr avatar andykellr commented on June 15, 2024

This is working as intended per the Connection interface:

// Send a message. Should not be called concurrently for the same Connection instance.
// Can be called only for WebSocket connections. Will return an error for plain HTTP
// connections.
// Blocks until the message is sent.
// Should return as soon as possible if the ctx is cancelled.
Send(ctx context.Context, message *protobufs.ServerToAgent) error

I will do some benchmarking with a large number of connections to determine the overhead of adding a mutex per connection.

from opamp-go.

evan-bradley avatar evan-bradley commented on June 15, 2024

I missed this issue while working on #200. In my opinion having separate mutexes for the WS connection and the agent data fields makes sense because the cost of the mutexes is low and it would cause contention between updating the agent and sending it messages if we had a shared mutex.

@andykellr @tigrannajaryan Are we satisfied that this is resolved?

from opamp-go.

tigrannajaryan avatar tigrannajaryan commented on June 15, 2024

Yes, I think we can close this.

from opamp-go.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.