Skip to content

Simple kafka caching#431

Open
Yashwanth-Ranjan-Singaravel wants to merge 20 commits intoopen-lambda:mainfrom
Yashwanth-Ranjan-Singaravel:feat/dumb-kafka-caching
Open

Simple kafka caching#431
Yashwanth-Ranjan-Singaravel wants to merge 20 commits intoopen-lambda:mainfrom
Yashwanth-Ranjan-Singaravel:feat/dumb-kafka-caching

Conversation

@Yashwanth-Ranjan-Singaravel
Copy link
Contributor

Adds a very simple kafka seek + caching mechanism

lambdaName string // lambda function name
kafkaTrigger *common.KafkaTrigger
client KafkaClient // used for PollFetches/Close (may be a cachedKafkaClient)
cache *cachedKafkaClient // typed reference for Seek; same object as client when caching is enabled
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No cache entry in this struct. Just client. The client may be a cachedKafkaClient that wraps a regular client.

"size", len(record.Value))
lkc.processMessage(record)
})
if seek := lkc.processMessage(record); seek != nil && lkc.cache != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this level of abstraction, we shouldn't be thinking about caching (even though it is helping us). We should seek the client the same, regular it is a raw client, or a cache client that wraps a raw client.

// cachedKafkaClient wraps a KafkaClient and caches records in an LRU map keyed
// by {topic, partition, offset}. When a seek is active, PollFetches serves
// records from the cache. On cache miss, the seek ends and normal polling resumes.
type cachedKafkaClient struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move cachedKafkaClient to another file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants