goridge

module
v4.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT

README

High-performance PHP-to-Golang IPC bridge

GoDoc Linux macOS Windows Go Report Card Codecov

PHPClasses Innovation Award

Goridge is high performance PHP-to-Golang codec library which works over native PHP sockets and Golang net/rpc package. The library allows you to call Go service methods from PHP with a minimal footprint, structures and []byte support.
PHP source code can be found in this repository: goridge-php


See https://github.com/roadrunner-server/roadrunner - High-performance PHP application server, load-balancer and process manager written in Golang

Features

  • no external dependencies or services, drop-in (64bit PHP version required)
  • low message footprint (12 bytes over any binary payload), binary error detection
  • CRC32 header verification
  • sockets over TCP or Unix (ext-sockets is required), standard pipes
  • very fast (300k calls per second on Ryzen 1700X over 20 threads)
  • native net/rpc integration, ability to connect to existed application(s)
  • standalone protocol usage
  • structured data transfer using json
  • []byte transfer, including big payloads
  • service, message and transport level error handling
  • hackable
  • works on Windows
  • unix sockets powered (also on Windows)

Installation

GO111MODULE=on go get github.com/roadrunner-server/goridge/v4
Sample of usage
package main

import (
	"fmt"
	"net"
	"net/rpc"

	goridgeRpc "github.com/roadrunner-server/goridge/v4/pkg/rpc"
)

type App struct{}

func (s *App) Hi(name string, r *string) error {
	*r = fmt.Sprintf("Hello, %s!", name)
	return nil
}

func main() {
	ln, err := net.Listen("tcp", ":6001")
	if err != nil {
		panic(err)
	}

	_ = rpc.Register(new(App))

	for {
		conn, err := ln.Accept()
		if err != nil {
			continue
		}
		_ = conn
		go rpc.ServeCodec(goridgeRpc.NewCodec(conn))
	}
}

License

The MIT License (MIT). Please see LICENSE for more information.

Directories

Path Synopsis
Package internal contains the frame routines shared by the relay implementations, SendFrame and ReceiveFrame.
Package internal contains the frame routines shared by the relay implementations, SendFrame and ReceiveFrame.
pkg
frame
Package frame implements a binary frame protocol for inter-process communication.
Package frame implements a binary frame protocol for inter-process communication.
pipe
Package pipe provides a pipe-based [relay.Relay] implementation that communicates with a child process over standard streams (STDIN/STDOUT).
Package pipe provides a pipe-based [relay.Relay] implementation that communicates with a child process over standard streams (STDIN/STDOUT).
relay
Package relay defines the Relay interface for frame-based inter-process communication.
Package relay defines the Relay interface for frame-based inter-process communication.
rpc
Package rpc provides net/rpc codec implementations that use the goridge frame protocol as a transport.
Package rpc provides net/rpc codec implementations that use the goridge frame protocol as a transport.
socket
Package socket provides a socket-based [relay.Relay] implementation for frame transport over TCP and Unix domain connections.
Package socket provides a socket-based [relay.Relay] implementation for frame transport over TCP and Unix domain connections.

Jump to

Keyboard shortcuts

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