1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-21 17:46:58 -05:00

refine capability deisgn

This commit is contained in:
Shelikhoo 2022-02-06 21:53:15 +00:00 committed by Xiaokang Wang (Shelikhoo)
parent 2a90a46ed5
commit 7888c10622
5 changed files with 17 additions and 23 deletions

View File

@ -1,20 +1,16 @@
package environment
import (
"github.com/v2fly/v2ray-core/v5/features/extension/storage"
)
type AppEnvironmentCapabilitySet interface {
BaseEnvironmentCapabilitySet
SystemNetworkCapabilitySet
InstanceNetworkCapabilitySet
FileSystemCapabilitySet
PersistentStorage() storage.ScopedPersistentStorage
TransientStorage() storage.ScopedTransientStorage
PersistentStorageCapabilitySet
TransientStorageCapabilitySet
}
type AppEnvironment interface {
AppEnvironmentCapabilitySet
NarrowScope(key []byte) (AppEnvironment, error)
NarrowScope(key string) (AppEnvironment, error)
doNotImpl()
}

View File

@ -3,6 +3,7 @@ package environment
import (
"github.com/v2fly/v2ray-core/v5/common/environment/filesystemcap"
"github.com/v2fly/v2ray-core/v5/common/log"
"github.com/v2fly/v2ray-core/v5/features/extension/storage"
"github.com/v2fly/v2ray-core/v5/transport/internet"
"github.com/v2fly/v2ray-core/v5/transport/internet/tagged"
)
@ -37,3 +38,10 @@ type LogCapabilitySet interface {
type FileSystemCapabilitySet interface {
filesystemcap.FileSystemCapabilitySet
}
type PersistentStorageCapabilitySet interface {
PersistentStorage() storage.ScopedPersistentStorage
}
type TransientStorageCapabilitySet interface {
TransientStorage() storage.ScopedTransientStorage
}

View File

@ -2,10 +2,8 @@ package envctx
import "context"
type environmentContextKey int
const (
environmentKey environmentContextKey = iota
environmentKey string = "v2.environment"
)
func ContextWithEnvironment(ctx context.Context, environment interface{}) context.Context {

View File

@ -1,18 +1,14 @@
package environment
import (
"github.com/v2fly/v2ray-core/v5/features/extension/storage"
)
type ProxyEnvironmentCapabilitySet interface {
BaseEnvironmentCapabilitySet
InstanceNetworkCapabilitySet
TransientStorage() storage.ScopedTransientStorage
TransientStorageCapabilitySet
}
type ProxyEnvironment interface {
ProxyEnvironmentCapabilitySet
NarrowScope(key []byte) (ProxyEnvironment, error)
NarrowScopeToTransport(key []byte) (TransportEnvironment, error)
NarrowScope(key string) (ProxyEnvironment, error)
NarrowScopeToTransport(key string) (TransportEnvironment, error)
doNotImpl()
}

View File

@ -1,18 +1,14 @@
package environment
import (
"github.com/v2fly/v2ray-core/v5/features/extension/storage"
)
type TransportEnvironmentCapacitySet interface {
BaseEnvironmentCapabilitySet
SystemNetworkCapabilitySet
InstanceNetworkCapabilitySet
TransientStorage() storage.ScopedTransientStorage
TransientStorageCapabilitySet
}
type TransportEnvironment interface {
TransportEnvironmentCapacitySet
NarrowScope(key []byte) (TransportEnvironment, error)
NarrowScope(key string) (TransportEnvironment, error)
doNotImpl()
}