added updated code for core wiring

1. Removed tracing
2. Skipped Registration
This commit is contained in:
MohitKatare-protean
2025-03-25 21:06:34 +05:30
parent 519cca19af
commit ec558558c5
87 changed files with 9279 additions and 711 deletions

View 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)
}

View 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)
}

View 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)
}

View 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)
}

View 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)
}

View 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)
}