rsocket_transport_quic

package module
v0.0.0-...-6a50e11 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

README

rsocket-transport-quic

QUIC transport for rsocket-go.

Install

$ go get -u github.com/jjeffcaii/rsocket-transport-quic

Quick Start

Start Echo Server

package main

import (
	"context"
	"log"

	rtq "github.com/jjeffcaii/rsocket-transport-quic"
	"github.com/rsocket/rsocket-go"
	"github.com/rsocket/rsocket-go/payload"
	"github.com/rsocket/rsocket-go/rx/mono"
)

func main() {
	err := rsocket.Receive().
		Acceptor(func(setup payload.SetupPayload, sendingSocket rsocket.CloseableRSocket) (responder rsocket.RSocket, err error) {
			responder = rsocket.NewAbstractSocket(
				rsocket.RequestResponse(func(request payload.Payload) mono.Mono {
					return mono.Just(request)
				}),
			)
			return
		}).
		Transport(rtq.Server().SetAddr(":443").Build()).
		Serve(context.Background())
	log.Fatalln(err)
}

Client

package main

import (
	"context"
	"log"

	rtq "github.com/jjeffcaii/rsocket-transport-quic"
	"github.com/rsocket/rsocket-go"
	"github.com/rsocket/rsocket-go/payload"
)

func main() {
	client, err := rsocket.Connect().
		Transport(rtq.Client().SetAddr("127.0.0.1:443").Build()).
		Start(context.Background())

	if err != nil {
		panic(err)
	}
	defer client.Close()

	res, err := client.RequestResponse(payload.NewString("hello world", "rsocket")).Block(context.Background())
	if err != nil {
		panic(err)
	}
	log.Println("response:", res.DataUTF8())
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientBuilder

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

func Client

func Client() *ClientBuilder

func (*ClientBuilder) Build

func (*ClientBuilder) SetAddr

func (q *ClientBuilder) SetAddr(addr string) *ClientBuilder

func (*ClientBuilder) SetHostAndPort

func (q *ClientBuilder) SetHostAndPort(host string, port int) *ClientBuilder

func (*ClientBuilder) SetTLSConfig

func (q *ClientBuilder) SetTLSConfig(c *tls.Config) *ClientBuilder

type ServerBuilder

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

func Server

func Server() *ServerBuilder

func (*ServerBuilder) Build

func (*ServerBuilder) SetAddr

func (q *ServerBuilder) SetAddr(addr string) *ServerBuilder

func (*ServerBuilder) SetHostAndPort

func (q *ServerBuilder) SetHostAndPort(host string, port int) *ServerBuilder

func (*ServerBuilder) SetTLSConfig

func (q *ServerBuilder) SetTLSConfig(c *tls.Config) *ServerBuilder

Jump to

Keyboard shortcuts

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