Scaffold modules and queue layer

This commit is contained in:
Mariano Belinky 2026-01-04 18:26:33 +01:00
parent a7b0d1440d
commit 2850843294
7 changed files with 97 additions and 0 deletions

View File

@ -0,0 +1,6 @@
package plugin
type Metadata struct {
Name string
Description string
}

View File

@ -0,0 +1,58 @@
package queue
import (
"context"
"sync"
)
type Task func(context.Context) error
type Queue struct {
mu sync.Mutex
closed bool
ch chan Task
}
func New(size int) *Queue {
if size < 1 {
size = 1
}
return &Queue{ch: make(chan Task, size)}
}
func (q *Queue) Start(ctx context.Context) {
for {
select {
case <-ctx.Done():
return
case task, ok := <-q.ch:
if !ok {
return
}
if task != nil {
_ = task(ctx)
}
}
}
}
func (q *Queue) Enqueue(task Task) bool {
q.mu.Lock()
defer q.mu.Unlock()
if q.closed {
return false
}
q.ch <- task
return true
}
func (q *Queue) Close() {
q.mu.Lock()
if q.closed {
q.mu.Unlock()
return
}
q.closed = true
close(q.ch)
q.mu.Unlock()
}

View File

@ -0,0 +1,8 @@
package session
type ID string
type Context struct {
SessionKey string
RunID string
}

6
modules/audio/audio.go Normal file
View File

@ -0,0 +1,6 @@
package audio
type Device struct {
Name string
ID string
}

6
modules/stt/stt.go Normal file
View File

@ -0,0 +1,6 @@
package stt
type Transcript struct {
Text string
Source string
}

8
modules/tts/tts.go Normal file
View File

@ -0,0 +1,8 @@
package tts
type Request struct {
Text string
Voice string
Rate int
Engine string
}

View File

@ -0,0 +1,5 @@
package wakeword
type Event struct {
Keyword string
}