triple

package
v3.3.1 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2025 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TRIPLE protocol name
	TRIPLE = "tri"
)

Variables

This section is empty.

Functions

func GetProtocol

func GetProtocol() base.Protocol

Types

type DubboInvoker

type DubboInvoker struct {
	base.BaseInvoker
	// contains filtered or unexported fields
}

DubboInvoker is implement of protocol.Invoker, a dubboInvoker refer to one service and ip.

func NewDubbo3Invoker

func NewDubbo3Invoker(url *common.URL) (*DubboInvoker, error)

NewDubbo3Invoker constructor

func (*DubboInvoker) Destroy

func (di *DubboInvoker) Destroy()

Destroy destroy dubbo3 client invoker.

func (*DubboInvoker) Invoke

func (di *DubboInvoker) Invoke(ctx context.Context, invocation base.Invocation) result.Result

Invoke call remoting.

func (*DubboInvoker) IsAvailable

func (di *DubboInvoker) IsAvailable() bool

IsAvailable check if invoker is available, now it is useless

type MethodInfo

type MethodInfo struct {
	Name           string
	Type           string
	ReqInitFunc    func() any
	StreamInitFunc func(baseStream any) any
	MethodFunc     func(ctx context.Context, args []any, handler any) (any, error)
	Meta           map[string]any
}

type Option added in v3.3.1

type Option func(*Options)

func Http3Enable added in v3.3.1

func Http3Enable() Option

Http3Enable enables HTTP/3 support for the Triple protocol. This option configures the server to start both HTTP/2 and HTTP/3 servers simultaneously, providing modern HTTP/3 capabilities alongside traditional HTTP/2.

When enabled, the server will:

  • Start an HTTP/3 server using QUIC protocol
  • Continue running the existing HTTP/2 server
  • Enable protocol negotiation between HTTP/2 and HTTP/3
  • Provide improved performance and security benefits of HTTP/3

Usage Examples:

// Basic HTTP/3 enablement
server := triple.NewServer(
    triple.Http3Enable(),
)

Requirements:

  • TLS configuration is required for HTTP/3
  • Server must have valid TLS certificates
  • Clients must support HTTP/3 for full benefits
  • Fallback to HTTP/2 is automatic for unsupported clients

Default Behavior:

  • HTTP/3 is disabled by default for backward compatibility
  • When enabled, negotiation defaults to true
  • Both HTTP/2 and HTTP/3 servers run on the same port

Experimental

NOTICE: This API is EXPERIMENTAL and may be changed or removed in a later release.

func Http3Negotiation added in v3.3.1

func Http3Negotiation(negotiation bool) Option

Http3Negotiation configures HTTP/3 negotiation behavior for the Triple protocol. This option controls whether HTTP/2 Alternative Services (Alt-Svc) negotiation is enabled when both HTTP/2 and HTTP/3 servers are running simultaneously.

Usage Examples:

// Enable HTTP/3 negotiation (default behavior)
server := triple.NewServer(
    triple.Http3Enable(),
    triple.Http3Negotiation(true),
)

// Disable HTTP/3 negotiation for explicit protocol control
server := triple.NewServer(
    triple.Http3Enable(),
    triple.Http3Negotiation(false),
)

Default Behavior:

  • When HTTP/3 is enabled, negotiation defaults to true
  • This ensures backward compatibility and optimal client experience

Experimental

NOTICE: This API is EXPERIMENTAL and may be changed or removed in a later release.

func WithKeepAlive added in v3.3.1

func WithKeepAlive(interval, timeout time.Duration) Option

WithKeepAlive sets the keep-alive interval and timeout for the Triple protocol. interval: The duration between keep-alive pings. timeout: The duration to wait for a keep-alive response before considering the connection dead. If not set, default interval is 10s, default timeout is 20s.

func WithKeepAliveInterval added in v3.3.1

func WithKeepAliveInterval(interval time.Duration) Option

WithKeepAliveInterval sets the keep-alive interval for the Triple protocol. interval: The duration between keep-alive pings. If not set, default interval is 10s.

func WithKeepAliveTimeout added in v3.3.1

func WithKeepAliveTimeout(timeout time.Duration) Option

WithKeepAliveTimeout sets the keep-alive timeout for the Triple protocol. timeout: The duration to wait for a keep-alive response before considering the connection dead. If not set, default timeout is 20s.

func WithMaxServerRecvMsgSize added in v3.3.1

func WithMaxServerRecvMsgSize(size string) Option

WithMaxServerRecvMsgSize sets the maximum size of messages that the server can receive. size: The maximum message size in bytes, specified as a string (e.g., "4MB"). If not set, default value is 4MB (4194304 bytes).

func WithMaxServerSendMsgSize added in v3.3.1

func WithMaxServerSendMsgSize(size string) Option

WithMaxServerSendMsgSize sets the maximum size of messages that the server can send. size: The maximum message size in bytes, specified as a string (e.g., "4MB"). If not set, default value is 2147MB (math.MaxInt32).

type Options added in v3.3.1

type Options struct {
	Triple *global.TripleConfig
}

TODO: The triple options for the server and client are mixed together now. We need to find a way to separate them later.

func NewOptions added in v3.3.1

func NewOptions(opts ...Option) *Options

type Server

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

Server is TRIPLE adaptation layer representation. It makes use of tri.Server to provide functionality.

func NewServer

func NewServer(cfg *global.TripleConfig) *Server

NewServer creates a new TRIPLE server.

func (*Server) GetServiceInfo

func (s *Server) GetServiceInfo() map[string]grpc.ServiceInfo

func (*Server) GracefulStop

func (s *Server) GracefulStop()

GracefulStop TRIPLE server

func (*Server) RefreshService

func (s *Server) RefreshService(invoker base.Invoker, info *common.ServiceInfo)

todo(DMwangnima): extract a common function RefreshService refreshes Triple Service

func (*Server) Start

func (s *Server) Start(invoker base.Invoker, info *common.ServiceInfo)

Start TRIPLE server

func (*Server) Stop

func (s *Server) Stop()

Stop TRIPLE server

type ServiceInfo

type ServiceInfo struct {
	InterfaceName string
	ServiceType   any
	Methods       []MethodInfo
	Meta          map[string]any
}

type TripleExporter

type TripleExporter struct {
	*base.BaseExporter
}

TripleExporter wraps BaseExporter

func NewTripleExporter

func NewTripleExporter(key string, invoker base.Invoker, exporterMap *sync.Map) *TripleExporter

func (*TripleExporter) UnExport

func (te *TripleExporter) UnExport()

UnExport and unregister Triple service from registry and memory.

type TripleInvoker

type TripleInvoker struct {
	base.BaseInvoker
	// contains filtered or unexported fields
}

func NewTripleInvoker

func NewTripleInvoker(url *common.URL) (*TripleInvoker, error)

func (*TripleInvoker) Destroy

func (ti *TripleInvoker) Destroy()

Destroy will destroy Triple's invoker and client, so it is only called once

func (*TripleInvoker) Invoke

func (ti *TripleInvoker) Invoke(ctx context.Context, invocation base.Invocation) result.Result

Invoke is used to call client-side method.

func (*TripleInvoker) IsAvailable

func (ti *TripleInvoker) IsAvailable() bool

IsAvailable get available status

func (*TripleInvoker) IsDestroyed

func (ti *TripleInvoker) IsDestroyed() bool

IsDestroyed get destroyed status

type TripleProtocol

type TripleProtocol struct {
	base.BaseProtocol
	// contains filtered or unexported fields
}

func NewTripleProtocol

func NewTripleProtocol() *TripleProtocol

func (*TripleProtocol) Destroy

func (tp *TripleProtocol) Destroy()

func (*TripleProtocol) Export

func (tp *TripleProtocol) Export(invoker base.Invoker) base.Exporter

Export TRIPLE service for remote invocation

func (*TripleProtocol) Refer

func (tp *TripleProtocol) Refer(url *common.URL) base.Invoker

Refer a remote triple service

Directories

Path Synopsis
triple_health
Code generated by protoc-gen-triple.
Code generated by protoc-gen-triple.
triple_reflection
Code generated by protoc-gen-triple.
Code generated by protoc-gen-triple.
Package triple is a slim RPC framework built on Protocol Buffers and net/http.
Package triple is a slim RPC framework built on Protocol Buffers and net/http.
internal/assert
Package assert is a minimal assert package using reflection.
Package assert is a minimal assert package using reflection.
internal/gen/proto/connect/ping/v1/pingv1connect
The connect.ping.v1 package contains an echo service designed to test the connect-go implementation.
The connect.ping.v1 package contains an echo service designed to test the connect-go implementation.

Jump to

Keyboard shortcuts

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