package closure import ( "context" "fmt" "github.com/tgckpg/resolver-go/internal/compilecache" ) type Compiler struct { client *Client } func NewCompiler() *Compiler { return &Compiler{client: NewClientFromEnv()} } func (c *Compiler) Compile(ctx context.Context, job compilecache.Job) ([]byte, error) { payload, ok := job.Payload.(CompilePayload) if !ok { return nil, fmt.Errorf("closure compiler got invalid payload type %T", job.Payload) } req := CompileRequest{ ExternSources: payload.ExternSources, JSSources: payload.JSSources, Defines: payload.Defines, } return c.client.Compile(ctx, req) }