8000 Kafka trigger by Mandukhai-Alimaa · Pull Request #302 · open-lambda/open-lambda · GitHub
[go: up one dir, main page]

Skip to content

Kafka trigger #302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 25, 2025
Merged

Conversation

Mandukhai-Alimaa
Copy link
Contributor

No description provided.

@Mandukhai-Alimaa Mandukhai-Alimaa marked this pull request as ready for review June 17, 2025 20:28
Copy link
Member
@tylerharter tylerharter left a comment

Choose a reason for hiding this comment

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

Great work!


err = s.eventManager.Register(funcName, cfg.Triggers)
if err != nil {
return err
}

entry.Lock.Unlock()
Copy link
Member

Choose a reason for hiding this comment

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

If it covers to the end, why not use defer? If you return err above, the lock is never released.

@@ -33,7 +33,12 @@ type CronTrigger struct {
Schedule string `yaml:"schedule"` // Cron schedule (e.g., "*/5 * * * *")
}

// TODO: add KafkaTrigger struct
type KafkaTrigger struct {
Bootstrap_servers []string `yaml:"bootstrap_servers" json:"bootstrap_servers"` // e.g., ["localhost:9092"]
Copy link
Member

Choose a reason for hiding this comment

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

We normally use camel case, like BootstrapServers


type KafkaManager struct {
workerPool *cloudvm.WorkerPool // to forward the req to worker
mapLock sync.Mutex
Copy link
Member

Choose a reason for hiding this comment

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

should we just call it lock? It doesn't seem like we're just using it to protect changes to the map, but to the entries as well given we hold it for the entire time the functions run.


data, err := json.Marshal(trigger)
if err != nil {
log.Printf("[KafkaManager] Failed to marshal Kafka trigger for %s: %v", functionName, err)
Copy link
Member

Choose a reason for hiding this comment

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

Let's use %w

continue
}

req := httptest.NewRequest(http.MethodPost, "/kafka-init/"+functionName, bytes.NewBuffer(data))
Copy link
Member

Choose a reason for hiding this comment

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

I don't know what httptest does, but is what we're doing related to testing? Why not a regular HTTP request, like here: https://github.com/open-lambda/open-lambda/blob/main/src/worker/lambda/lambdaInstance.go#L145?


data, err := json.Marshal(trigger)
if err != nil {
log.Printf("[KafkaManager] Failed to marshal Kafka trigger for %s: %v", functionName, err)
Copy link
Member

Choose a reason for hiding this comment

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

Is it right that we have errors here but the function returns no error?

@Mandukhai-Alimaa Mandukhai-Alimaa merged commit 1a4afb2 into open-lambda:main Jun 25, 2025
1 check passed
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.

2 participants
0