added updated code for core wiring
1. Removed tracing 2. Skipped Registration
This commit is contained in:
27
pkg/plugin/definition/cache.go
Normal file
27
pkg/plugin/definition/cache.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package definition
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Cache defines the general cache interface for caching plugins.
|
||||
type Cache interface {
|
||||
// Get retrieves a value from the cache based on the given key.
|
||||
Get(ctx context.Context, key string) (string, error)
|
||||
|
||||
// Set stores a value in the cache with the given key and TTL (time-to-live) in seconds.
|
||||
Set(ctx context.Context, key, value string, ttl time.Duration) error
|
||||
|
||||
// Delete removes a value from the cache based on the given key.
|
||||
Delete(ctx context.Context, key string) error
|
||||
|
||||
// Clear removes all values from the cache.
|
||||
Clear(ctx context.Context) error
|
||||
}
|
||||
|
||||
// CacheProvider interface defines the contract for managing cache instances.
|
||||
type CacheProvider interface {
|
||||
// New initializes a new cache instance with the given configuration.
|
||||
New(ctx context.Context, config map[string]string) (Cache, func() error, error)
|
||||
}
|
||||
35
pkg/plugin/definition/keymanager.go
Normal file
35
pkg/plugin/definition/keymanager.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package definition
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/beckn/beckn-onix/pkg/model"
|
||||
)
|
||||
|
||||
type Keyset struct {
|
||||
UniqueKeyID string
|
||||
SigningPrivate string
|
||||
SigningPublic string
|
||||
EncrPrivate string
|
||||
EncrPublic string
|
||||
}
|
||||
|
||||
// KeyManager defines the interface for key management operations/methods.
|
||||
type KeyManager interface {
|
||||
GenerateKeyPairs() (*Keyset, error)
|
||||
StorePrivateKeys(ctx context.Context, keyID string, keys *Keyset) error
|
||||
SigningPrivateKey(ctx context.Context, keyID string) (string, string, error)
|
||||
EncrPrivateKey(ctx context.Context, keyID string) (string, string, error)
|
||||
SigningPublicKey(ctx context.Context, subscriberID, uniqueKeyID string) (string, error)
|
||||
EncrPublicKey(ctx context.Context, subscriberID, uniqueKeyID string) (string, error)
|
||||
DeletePrivateKeys(ctx context.Context, keyID string) error
|
||||
}
|
||||
|
||||
// KeyManagerProvider initializes a new signer instance.
|
||||
type KeyManagerProvider interface {
|
||||
New(context.Context, Cache, RegistryLookup, map[string]string) (KeyManager, func() error, error)
|
||||
}
|
||||
|
||||
type RegistryLookup interface {
|
||||
Lookup(ctx context.Context, req *model.Subscription) ([]model.Subscription, error)
|
||||
}
|
||||
10
pkg/plugin/definition/middleware.go
Normal file
10
pkg/plugin/definition/middleware.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package definition
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type MiddlewareProvider interface {
|
||||
New(ctx context.Context, cfg map[string]string) (func(http.Handler) http.Handler, error)
|
||||
}
|
||||
16
pkg/plugin/definition/router.go
Normal file
16
pkg/plugin/definition/router.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package definition
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/url"
|
||||
|
||||
"github.com/beckn/beckn-onix/pkg/model"
|
||||
)
|
||||
|
||||
type Router interface {
|
||||
Route(ctx context.Context, url *url.URL, body []byte) (*model.Route, error)
|
||||
}
|
||||
|
||||
type RouterProvider interface {
|
||||
New(ctx context.Context, cfg map[string]string) (Router, error)
|
||||
}
|
||||
16
pkg/plugin/definition/schemaValidator.go
Normal file
16
pkg/plugin/definition/schemaValidator.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package definition
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
// SchemaValidator interface for schema validation.
|
||||
type SchemaValidator interface {
|
||||
Validate(ctx context.Context, url *url.URL, reqBody []byte) error
|
||||
}
|
||||
|
||||
// SchemaValidatorProvider interface for creating validators.
|
||||
type SchemaValidatorProvider interface {
|
||||
New(ctx context.Context, config map[string]string) (SchemaValidator, func() error, error)
|
||||
}
|
||||
15
pkg/plugin/definition/step.go
Normal file
15
pkg/plugin/definition/step.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package definition
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/beckn/beckn-onix/pkg/model"
|
||||
)
|
||||
|
||||
type Step interface {
|
||||
Run(ctx *model.StepContext) error
|
||||
}
|
||||
|
||||
type StepProvider interface {
|
||||
New(context.Context, map[string]string) (Step, func(), error)
|
||||
}
|
||||
Reference in New Issue
Block a user