mpc

package
v0.0.0-...-c71cb10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PROVIDER Flag.
	PROVIDER = "PROVIDER"
	// CONSUMER Flag.
	CONSUMER = "CONSUMER"
)

Variables

View Source
var (
	TimeoutKey     = &prsim.Key{Name: "mesh.mpc.timeout", Dft: func() interface{} { return time.Second * 10 }}
	AddressKey     = &prsim.Key{Name: "mesh.mpc.address", Dft: func() interface{} { return "" }}
	InsecureKey    = &prsim.Key{Name: "mesh.mpc.insecure", Dft: func() interface{} { return true }}
	CertificateKey = &prsim.Key{Name: "mesh.mpc.certificate", Dft: func() interface{} { return &tls.Config{} }}
	RemoteUname    = &prsim.Key{Name: "mesh.mpc.uname", Dft: func() interface{} { return "" }}
	RemoteName     = &prsim.Key{Name: "mesh.mpc.name", Dft: func() interface{} { return "" }}
	HeaderKey      = &prsim.Key{Name: "mesh.mpc.headers", Dft: func() interface{} { return map[string]string{} }}
)
View Source
var ConsumerKey = &prsim.Key{Name: "mesh.mpc.Consumer", Dft: func() interface{} { return nil }}
View Source
var IConsumer = (*Consumer)(nil)
View Source
var IEden = (*Eden)(nil)
View Source
var IFilter = (*Filter)(nil)
View Source
var IInvoker = (*Invoker)(nil)
View Source
var IProvider = (*Provider)(nil)
View Source
var MeshFlag = struct {
	HTTP     codename
	GRPC     codename
	MQTT     codename
	TCP      codename
	JSON     codename
	PROTOBUF codename
	XML      codename
	THRIFT   codename
	YAML     codename
	OfProto  func(code string) codename
	OfCodec  func(code string) codename
	OfName   func(name string) codename
}{
	HTTP:     &meshFlag{code: "00", name: "http"},
	GRPC:     &meshFlag{code: "01", name: "grpc"},
	MQTT:     &meshFlag{code: "02", name: "mqtt"},
	TCP:      &meshFlag{code: "03", name: "tcp"},
	JSON:     &meshFlag{code: "00", name: "json"},
	PROTOBUF: &meshFlag{code: "01", name: "protobuf"},
	XML:      &meshFlag{code: "02", name: "xml"},
	THRIFT:   &meshFlag{code: "03", name: "thrift"},
	YAML:     &meshFlag{code: "04", name: "yaml"},
}
View Source
var ServiceProxy = new(serviceProxy)

Functions

func CloneContext

func CloneContext(ctx context.Context) prsim.Context

func Context

func Context() prsim.Context

func ContextWith

func ContextWith(ctx context.Context) prsim.Context

func CopyContext

func CopyContext(ctx context.Context, source map[string]string) prsim.Context

func Dump

func Dump(ctx context.Context) map[string]string

func HTTPTracerContext

func HTTPTracerContext(r *http.Request) prsim.Context

func Locale

func Locale(ctx context.Context) *types.Location

func NoService

func NoService(ctx context.Context, urn *types.URN) error

func TracerContext

func TracerContext(traceId string, spanId string) prsim.Context

func WithContext

func WithContext(ctx context.Context, mtx prsim.Context) context.Context

Types

type Consumer

type Consumer interface {

	// Start the mesh broker.
	Start() error

	// Consume the input payload.
	// urn       Actual uniform resource Domain Name.
	// execution Service reference.
	// inbound   Input arguments.
	// Output    payload
	Consume(ctx context.Context, urn string, execution Execution, inbound *bytes.Buffer) (*bytes.Buffer, error)

	// Closer is release hook
	io.Closer
}

type Digest

type Digest struct {
	TraceId string
	SpanId  string
	Mode    string
	CNI     string
	CII     string
	CIP     string
	CHost   string
	PNI     string
	PII     string
	PIP     string
	PHost   string
	URN     string
	Now     int64
}

func NewDigest

func NewDigest(ctx prsim.Context) *Digest

func (*Digest) Print

func (that *Digest) Print(ctx prsim.Context, pattern string, code string)

type Eden

type Eden interface {

	// Define the reference object.
	Define(ctx context.Context, mpi macro.MPI, reference interface{}) error

	// Refer the service reference by method.
	Refer(ctx context.Context, mpi macro.MPI, reference interface{}, method macro.Inspector) (Execution, error)

	// Store the service object.
	Store(ctx context.Context, kind interface{}, service interface{}) error

	// Infer the reference service by Domain.
	Infer(ctx context.Context, urn string) (Execution, error)

	// ReferTypes Get all reference types.
	ReferTypes(ctx context.Context) ([]macro.MPI, error)

	// InferTypes Get all service types.
	InferTypes(ctx context.Context) ([]macro.MPS, error)
}

Eden @SPI("mesh")

type Execution

type Execution interface {

	// Schema is the execution schema.
	Schema() Generic

	// Inspect execution.
	Inspect() macro.Inspector

	Invoker
}

type Filter

type Filter interface {

	// Invoke the next filter.
	// invoker    Service invoker.
	// invocation Service invocation
	Invoke(ctx context.Context, invoker Invoker, invocation Invocation) (interface{}, error)

	macro.SPI
}

type Generic

type Generic interface {
	GetURN() string
	GetProto() string
	GetCodec() string
	GetTimeout() int64
	GetRetries() int
}

type GenericExecution

type GenericExecution struct {
	// contains filtered or unexported fields
}

func (*GenericExecution) Init

func (that *GenericExecution) Init(urn *types.URN, arguments map[string]interface{})

func (*GenericExecution) Inspect

func (that *GenericExecution) Inspect() macro.Inspector

func (*GenericExecution) Invoke

func (that *GenericExecution) Invoke(ctx context.Context, invocation Invocation) (interface{}, error)

func (*GenericExecution) Schema

func (that *GenericExecution) Schema() Generic

type GenericHandler

type GenericHandler struct {
	ReferenceHandler
}

func (*GenericHandler) Invoke00

func (that *GenericHandler) Invoke00(ctx context.Context, urn string, arguments map[string]interface{}) ([]interface{}, error)

func (*GenericHandler) ReferExecution

func (that *GenericHandler) ReferExecution(ctx context.Context, inspector macro.Inspector) (Execution, error)

type GenericInspector

type GenericInspector struct {
	Name string
	Args map[string]interface{}
}

func (*GenericInspector) Call

func (that *GenericInspector) Call(ctx context.Context, proxy interface{}, method macro.Inspector, args ...interface{}) (interface{}, error)

func (*GenericInspector) GetBinding

func (that *GenericInspector) GetBinding() []macro.Binding

func (*GenericInspector) GetDeclaredKind

func (that *GenericInspector) GetDeclaredKind() interface{}

func (*GenericInspector) GetIntype

func (that *GenericInspector) GetIntype() macro.Parameters

func (*GenericInspector) GetMPI

func (that *GenericInspector) GetMPI() macro.MPI

func (*GenericInspector) GetMPS

func (that *GenericInspector) GetMPS() macro.MPS

func (*GenericInspector) GetName

func (that *GenericInspector) GetName() string

func (*GenericInspector) GetRetype

func (that *GenericInspector) GetRetype() macro.Returns

func (*GenericInspector) GetSPI

func (that *GenericInspector) GetSPI() macro.SPI

func (*GenericInspector) GetTName

func (that *GenericInspector) GetTName() string

func (*GenericInspector) NewInbound

func (that *GenericInspector) NewInbound() macro.Parameters

func (*GenericInspector) NewOutbound

func (that *GenericInspector) NewOutbound() macro.Returns

func (*GenericInspector) Signature

func (that *GenericInspector) Signature() string

func (*GenericInspector) String

func (that *GenericInspector) String() string

type GenericParameters

type GenericParameters map[string]interface{}

func (GenericParameters) Get

func (that GenericParameters) Get(key string) interface{}

func (GenericParameters) GetArguments

func (that GenericParameters) GetArguments(ctx context.Context) []interface{}

func (GenericParameters) GetAttachments

func (that GenericParameters) GetAttachments(ctx context.Context) map[string]string

func (GenericParameters) GetKind

func (that GenericParameters) GetKind() interface{}

func (GenericParameters) PutAll

func (that GenericParameters) PutAll(dict map[string]interface{})

func (GenericParameters) SetArguments

func (that GenericParameters) SetArguments(ctx context.Context, arguments ...interface{})

func (GenericParameters) SetAttachments

func (that GenericParameters) SetAttachments(ctx context.Context, attachments map[string]string)

type GenericReturns

type GenericReturns map[string]interface{}

func (GenericReturns) GetCause

func (that GenericReturns) GetCause(ctx context.Context) *macro.Cause

func (GenericReturns) GetCode

func (that GenericReturns) GetCode() string

func (GenericReturns) GetContent

func (that GenericReturns) GetContent(ctx context.Context) []interface{}

func (GenericReturns) GetMessage

func (that GenericReturns) GetMessage() string

func (GenericReturns) SetCause

func (that GenericReturns) SetCause(ctx context.Context, cause *macro.Cause)

func (GenericReturns) SetCode

func (that GenericReturns) SetCode(code string)

func (GenericReturns) SetContent

func (that GenericReturns) SetContent(ctx context.Context, arguments ...interface{})

func (GenericReturns) SetMessage

func (that GenericReturns) SetMessage(message string)

type InspectExecution

type InspectExecution struct {
	URN *types.URN
}

func (*InspectExecution) Call

func (that *InspectExecution) Call(ctx context.Context, proxy interface{}, method macro.Inspector, args ...interface{}) (interface{}, error)

func (*InspectExecution) GetBinding

func (that *InspectExecution) GetBinding() []macro.Binding

func (*InspectExecution) GetDeclaredKind

func (that *InspectExecution) GetDeclaredKind() interface{}

func (*InspectExecution) GetIntype

func (that *InspectExecution) GetIntype() macro.Parameters

func (*InspectExecution) GetMPI

func (that *InspectExecution) GetMPI() macro.MPI

func (*InspectExecution) GetMPS

func (that *InspectExecution) GetMPS() macro.MPS

func (*InspectExecution) GetName

func (that *InspectExecution) GetName() string

func (*InspectExecution) GetRetype

func (that *InspectExecution) GetRetype() macro.Returns

func (*InspectExecution) GetSPI

func (that *InspectExecution) GetSPI() macro.SPI

func (*InspectExecution) GetTName

func (that *InspectExecution) GetTName() string

func (*InspectExecution) Inspect

func (that *InspectExecution) Inspect() macro.Inspector

func (*InspectExecution) Invoke

func (that *InspectExecution) Invoke(ctx context.Context, invocation Invocation) (interface{}, error)

func (*InspectExecution) NewInbound

func (that *InspectExecution) NewInbound() macro.Parameters

func (*InspectExecution) NewOutbound

func (that *InspectExecution) NewOutbound() macro.Returns

func (*InspectExecution) Schema

func (that *InspectExecution) Schema() Generic

func (*InspectExecution) Signature

func (that *InspectExecution) Signature() string

func (*InspectExecution) String

func (that *InspectExecution) String() string

type Invocation

type Invocation interface {

	// GetProxy the delegate target object.
	GetProxy() Invoker

	// GetInspector interface.
	GetInspector() macro.Inspector

	// GetParameters parameters.
	GetParameters() macro.Parameters

	// GetArguments parameters.
	GetArguments(ctx context.Context) []interface{}

	// GetAttachments the attachments. The attributes will be serialized.
	GetAttachments(ctx context.Context) map[string]string

	// GetBuffer get the input buffer.
	GetBuffer() *bytes.Buffer

	// GetExecution get the invocation execution.
	GetExecution() Execution

	// GetURN get the invoked urn.
	GetURN() *types.URN
}

type InvocationRuntime

type InvocationRuntime struct {
	// contains filtered or unexported fields
}

func (*InvocationRuntime) Dispatch

func (that *InvocationRuntime) Dispatch(ctx context.Context, name string, args ...interface{}) (interface{}, error)

func (*InvocationRuntime) Parse

func (that *InvocationRuntime) Parse(ctx context.Context, ptr interface{}) error

func (*InvocationRuntime) ParseHeader

func (that *InvocationRuntime) ParseHeader(ctx context.Context, headers map[string]string) error

type Invoker

type Invoker interface {

	// Invoke the next invoker.
	Invoke(ctx context.Context, invocation Invocation) (interface{}, error)
}

type InvokerDecorator

type InvokerDecorator struct {
	Name    string
	Invoker Invoker
}

func (*InvokerDecorator) Att

func (that *InvokerDecorator) Att() *macro.Att

func (*InvokerDecorator) Invoke

func (that *InvokerDecorator) Invoke(ctx context.Context, invocation Invocation) (interface{}, error)

type InvokerFn

type InvokerFn func(ctx context.Context, invocation Invocation) (interface{}, error)

func (InvokerFn) Invoke

func (that InvokerFn) Invoke(ctx context.Context, invocation Invocation) (interface{}, error)

type MeshContext

type MeshContext struct {
	Context   context.Context
	TraceId   string
	SpanId    string
	Timestamp int64
	RunMode   int
	URN       string
	Consumer  *types.Location

	Attachments map[string]string
	Attributes  map[string]interface{}
	Principals  *prsim.Deque[*types.Principal]
	// contains filtered or unexported fields
}

func (*MeshContext) Deadline

func (that *MeshContext) Deadline() (deadline time.Time, ok bool)

func (*MeshContext) Done

func (that *MeshContext) Done() <-chan struct{}

func (*MeshContext) Err

func (that *MeshContext) Err() error

func (*MeshContext) GetAttachment

func (that *MeshContext) GetAttachment(name string) string

func (*MeshContext) GetAttachments

func (that *MeshContext) GetAttachments() map[string]string

func (*MeshContext) GetAttribute

func (that *MeshContext) GetAttribute(key *prsim.Key) interface{}

func (*MeshContext) GetAttributes

func (that *MeshContext) GetAttributes() map[string]interface{}

func (*MeshContext) GetConsumer

func (that *MeshContext) GetConsumer(ctx context.Context) *types.Location

func (*MeshContext) GetPrincipals

func (that *MeshContext) GetPrincipals() *prsim.Deque[*types.Principal]

func (*MeshContext) GetProvider

func (that *MeshContext) GetProvider(ctx context.Context) *types.Location

func (*MeshContext) GetRunMode

func (that *MeshContext) GetRunMode() int

func (*MeshContext) GetSpanId

func (that *MeshContext) GetSpanId() string

func (*MeshContext) GetTimestamp

func (that *MeshContext) GetTimestamp() int64

func (*MeshContext) GetTraceId

func (that *MeshContext) GetTraceId() string

func (*MeshContext) GetUrn

func (that *MeshContext) GetUrn() string

func (*MeshContext) Resume

func (that *MeshContext) Resume(ctx context.Context) prsim.Context

func (*MeshContext) RewriteContext

func (that *MeshContext) RewriteContext(context prsim.Context)

func (*MeshContext) RewriteURN

func (that *MeshContext) RewriteURN(urn string)

func (*MeshContext) SetAttribute

func (that *MeshContext) SetAttribute(key *prsim.Key, value interface{})

func (*MeshContext) Value

func (that *MeshContext) Value(key interface{}) interface{}

func (*MeshContext) WithTimeout

func (that *MeshContext) WithTimeout(timeout time.Duration) context.CancelFunc

type MeshEden

type MeshEden struct {
	// contains filtered or unexported fields
}

func (*MeshEden) Att

func (that *MeshEden) Att() *macro.Att

func (*MeshEden) Btt

func (that *MeshEden) Btt() []*macro.Btt

func (*MeshEden) Define

func (that *MeshEden) Define(ctx context.Context, mpi macro.MPI, reference any) error

func (*MeshEden) Infer

func (that *MeshEden) Infer(ctx context.Context, urn string) (Execution, error)

func (*MeshEden) InferTypes

func (that *MeshEden) InferTypes(ctx context.Context) ([]macro.MPS, error)

func (*MeshEden) Listen

func (that *MeshEden) Listen(ctx context.Context, event *types.Event) error

func (*MeshEden) Refer

func (that *MeshEden) Refer(ctx context.Context, mpi macro.MPI, reference any, method macro.Inspector) (Execution, error)

func (*MeshEden) ReferTypes

func (that *MeshEden) ReferTypes(ctx context.Context) ([]macro.MPI, error)

func (*MeshEden) Refresh

func (that *MeshEden) Refresh(ctx context.Context, runtime prsim.Runtime) error

func (*MeshEden) Start

func (that *MeshEden) Start(ctx context.Context, runtime prsim.Runtime) error

func (*MeshEden) Stop

func (that *MeshEden) Stop(ctx context.Context, runtime prsim.Runtime) error

func (*MeshEden) Store

func (that *MeshEden) Store(ctx context.Context, kind any, service any) error

type Provider

type Provider interface {

	// Start the mesh broker.
	Start(ctx context.Context, address string, tc *tls.Config) error

	io.Closer
}

type Referencable

type Referencable interface {
	ReferExecution(ctx context.Context, inspector macro.Inspector) (Execution, error)
}

type ReferenceHandler

type ReferenceHandler struct {
	MPI macro.MPI
	// contains filtered or unexported fields
}

func (*ReferenceHandler) Call

func (that *ReferenceHandler) Call(ctx context.Context, proxy interface{}, method macro.Inspector, args ...interface{}) (interface{}, error)

func (*ReferenceHandler) Invoke

func (that *ReferenceHandler) Invoke(ctx context.Context, invocation Invocation) (interface{}, error)

func (*ReferenceHandler) ReferExecution

func (that *ReferenceHandler) ReferExecution(ctx context.Context, inspector macro.Inspector) (Execution, error)

type ServiceHandler

type ServiceHandler struct {
	// contains filtered or unexported fields
}

func (*ServiceHandler) Invoke

func (that *ServiceHandler) Invoke(ctx context.Context, invocation Invocation) (interface{}, error)

type ServiceInvocation

type ServiceInvocation struct {
	Proxy      Invoker
	Inspector  macro.Inspector
	Parameters macro.Parameters
	Buffer     *bytes.Buffer
	Execution  Execution
	URN        *types.URN
}

func (*ServiceInvocation) GetArguments

func (that *ServiceInvocation) GetArguments(ctx context.Context) []interface{}

func (*ServiceInvocation) GetAttachments

func (that *ServiceInvocation) GetAttachments(ctx context.Context) map[string]string

func (*ServiceInvocation) GetBuffer

func (that *ServiceInvocation) GetBuffer() *bytes.Buffer

func (*ServiceInvocation) GetExecution

func (that *ServiceInvocation) GetExecution() Execution

func (*ServiceInvocation) GetInspector

func (that *ServiceInvocation) GetInspector() macro.Inspector

func (*ServiceInvocation) GetParameters

func (that *ServiceInvocation) GetParameters() macro.Parameters

func (*ServiceInvocation) GetProxy

func (that *ServiceInvocation) GetProxy() Invoker

func (*ServiceInvocation) GetURN

func (that *ServiceInvocation) GetURN() *types.URN

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL