Skip to content

Commit

Permalink
remove scalar values and Extension struct for local extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
charithabandi committed Oct 26, 2023
1 parent 48fb093 commit 2dddabf
Show file tree
Hide file tree
Showing 10 changed files with 220 additions and 401 deletions.
8 changes: 4 additions & 4 deletions cmd/kwild/server/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ import (

// getExtensions returns both the local and remote extensions. Remote extensions are identified by
// connecting to the specified extension URLs.
func getExtensions(ctx context.Context, urls []string) (map[string]extensions.ExtensionDriver, error) {
exts := make(map[string]extensions.ExtensionDriver)
func getExtensions(ctx context.Context, urls []string) (map[string]extActions.Extension, error) {
exts := make(map[string]extActions.Extension)

for name, ext := range extActions.GetRegisteredExtensions() {
for name, ext := range extActions.RegisteredExtensions() {
_, ok := exts[name]
if ok {
return nil, fmt.Errorf("duplicate extension name: %s", name)
Expand All @@ -59,7 +59,7 @@ func getExtensions(ctx context.Context, urls []string) (map[string]extensions.Ex
return exts, nil
}

func adaptExtensions(exts map[string]extensions.ExtensionDriver) map[string]engine.ExtensionInitializer {
func adaptExtensions(exts map[string]extActions.Extension) map[string]engine.ExtensionInitializer {
adapted := make(map[string]engine.ExtensionInitializer, len(exts))

for name, ext := range exts {
Expand Down
56 changes: 0 additions & 56 deletions extensions/actions/extension.go

This file was deleted.

17 changes: 13 additions & 4 deletions extensions/actions/extension_registry.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
package extensions

import "strings"
import (
"context"
"strings"
)

var registeredExtensions = make(map[string]*Extension)
type Extension interface {
Name() string
Initialize(ctx context.Context, metadata map[string]string) (map[string]string, error)
Execute(ctx context.Context, metadata map[string]string, method string, args ...any) ([]any, error)
}

var registeredExtensions = make(map[string]Extension)

func RegisterExtension(name string, ext *Extension) error {
func RegisterExtension(name string, ext Extension) error {
name = strings.ToLower(name)
if _, ok := registeredExtensions[name]; ok {
panic("extension of same name already registered: " + name)
Expand All @@ -14,6 +23,6 @@ func RegisterExtension(name string, ext *Extension) error {
return nil
}

func GetRegisteredExtensions() map[string]*Extension {
func RegisteredExtensions() map[string]Extension {
return registeredExtensions
}
188 changes: 0 additions & 188 deletions extensions/actions/math.go

This file was deleted.

Loading

0 comments on commit 2dddabf

Please sign in to comment.