question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Open up parts of the API

See original GitHub issue

Feature Request

I’m working on a Scala wrapper of your library that brings two key features: 1.) easier Scala interoperability 2.) thread-safety across transactions

In order to achieve the latter, whenever someone calls multi, I’m essentially doing something like 1.) return a new object that from the outside looks like it’s a redis client, but is actually a wrapper around the current client 2.) all methods (other than exec) that get called, create a Command and push it to a queue 3.) once exec is called: take out a shared lock, send the server a multi, followed by all the commands in the queue, followed by exec, and release the lock 4.) this wrapper may not be used again

I implemented it and it all works just fine, but I had to do something ugly: for a few classes, I had to declare them inside of a package io.lettuce.core so that I could access some internals. This included: a.) CommandArgs.singularArguments, in order to access all the keys in a command. Used to find the slot/underlying connection to use if running in cluster mode. b.) BaseRedisAsyncCommands.dispatch, in order to dispatch the queued commands c.) RedisCommandBuilder, to create Commands to dispatch

Is my goal to create a thread-safe transactional API reasonable? Would you go about it different? Would you consider opening up the visibility of some of these APIs, or do you have any suggestions about how I could implement it differently?

Is your feature request related to a problem? Please describe

My project runs in a highly parallel environment, and the lack of thread safety in the multi API is very cumbersome.

Describe the solution you’d like

Opening up parts of the API to make extending it easier.

Describe alternatives you’ve considered

Haven’t been able to think of much.

Teachability, Documentation, Adoption, Migration Strategy

This change wouldn’t really have much impact on existing users.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mp911decommented, Jul 22, 2020

Would it be easier to add an overload that just uses the old behavior?

Then we re-introduce the error-prone behavior without helping users to understand why they potentially run into issues.

https://github.com/lettuce-io/lettuce-core/issues/1311#issuecomment-660942403 isn’t really saying that I’m avoiding complexity, it’s more outlining what we can/should do.

0reactions
dontgititcommented, Feb 3, 2021

fair enough! FWIW we’ve been using the version with the ReadWriteLock and it’s been working well enough

Read more comments on GitHub >

github_iconTop Results From Across the Web

What Is Open API (Public API)? Definition from ... - TechTarget
Open APIs are published on the internet and shared freely, allowing the owner of a network-accessible service to give a universal access to...
Read more >
How to Use an API: Just the Basics 2022 - TechnologyAdvice
The easiest way to start using an API is by finding an HTTP client online, like REST-Client, Postman, or Paw. These ready-to-use tools...
Read more >
The Ultimate Guide to Accessing & Using APIs - HubSpot Blog
An API, short for Application Programming Interface, is a software-to-software interface. APIs provide a secure and standardized way for ...
Read more >
What Are API Functions? (Types, Components and 3 Examples)
APIs operate through requests and responses with endpoints. When an API requests data from an app or server, an endpoint sends back a...
Read more >
Chapter 6: API Design - An Introduction to APIs - Zapier
Read or Download Chapter 6: API Design from our An Introduction to APIs e-book for FREE and start learning today!
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found