node

package
v0.0.0-...-c58429a Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

* Copyright 2017- Yuji Ito <llamerada.jp@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Logger             *slog.Logger
	ObservationHandler *observation.Handler
	HttpClient         *http.Client
	SeedURL            string
	ICEServers         []*networkTypes.ICEServer
	CoordinateSystem   geometry.CoordinateSystem

	// PacketHopLimit is the maximum number of hops that a packet can be relayed.
	// If you set 0, the default value of 64 will be set.
	PacketHopLimit uint

	// CacheLifetime is the lifetime of the cache. The spread algorithm is
	// so simple that the same packet may be received multiple times;
	// if the same packet is received within the cache lifetime, it can be suppressed
	// for reprocessing. This costs more memory.
	SpreadCacheLifetime time.Duration

	// Before sending a large payload, you can check whether a cache exists
	// at the other node using knock packet. For small packets, it is more efficient
	// to send the packet without knocking.
	// If you set 0, disable the use of knock packets.
	SpreadSizeToUseKnock uint
}

type ConfigSetter

type ConfigSetter func(*Config)

func WithHttpClient

func WithHttpClient(client *http.Client) ConfigSetter

func WithICEServers

func WithICEServers(servers []*networkTypes.ICEServer) ConfigSetter

IceServers is a list of ICE servers. In Colonio, multiple ICE servers can be used to establish a WebRTC connection. Each entry contains the URLs of the ICE server, the username, and the credential.

func WithLogger

func WithLogger(logger *slog.Logger) ConfigSetter

func WithObservation

func WithObservation(handler *observation.Handler) ConfigSetter

func WithPlaneGeometry

func WithPlaneGeometry(xMin, xMax, yMin, yMax float64) ConfigSetter

Plane is a configuration for the plane geometry. If this configuration is set, the 2D position based network will be setup as a plane space.

func WithSeedURL

func WithSeedURL(url string) ConfigSetter

func WithSphereGeometry

func WithSphereGeometry(radius float64) ConfigSetter

Sphere is a configuration for the sphere geometry. If this configuration is set, the 2D position based network will be setup as a sphere space.

type MessagingOptionSetter

type MessagingOptionSetter func(*MessagingOptions)

func MessagingWithAcceptNearby

func MessagingWithAcceptNearby() MessagingOptionSetter

func MessagingWithIgnoreResponse

func MessagingWithIgnoreResponse() MessagingOptionSetter

type MessagingOptions

type MessagingOptions messaging.Options

type MessagingRequest

type MessagingRequest struct {
	SourceNodeID string
	Message      []byte
	Options      *MessagingOptions
}

type MessagingResponseWriter

type MessagingResponseWriter messaging.ResponseWriter

type Node

type Node interface {
	Start(ctx context.Context) error
	Stop()
	IsOnline() bool
	IsStable() bool
	GetLocalNodeID() string
	UpdateLocalPosition(x, y float64) error
	// messaging
	MessagingPost(dst, name string, val []byte, setters ...MessagingOptionSetter) ([]byte, error)
	MessagingSetHandler(name string, handler func(*MessagingRequest, MessagingResponseWriter))
	MessagingUnsetHandler(name string)
	// spread
	SpreadPost(x, y, r float64, name string, val []byte, setters ...SpreadOptionSetter) error
	SpreadSetHandler(name string, handler func(*SpreadRequest))
	SpreadUnsetHandler(name string)
}

func NewNode

func NewNode(setters ...ConfigSetter) (Node, error)

type SpreadOptionSetter

type SpreadOptionSetter func(*SpreadOptions)

func SpreadWithSomeoneMustExists

func SpreadWithSomeoneMustExists() SpreadOptionSetter

type SpreadOptions

type SpreadOptions spread.Options

type SpreadRequest

type SpreadRequest struct {
	SourceNodeID string
	Message      []byte
	Options      *SpreadOptions
}

Directories

Path Synopsis
internal
constants
* Copyright 2017- Yuji Ito <llamerada.jp@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* Copyright 2017- Yuji Ito <llamerada.jp@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
geometry
* Copyright 2017- Yuji Ito <llamerada.jp@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* Copyright 2017- Yuji Ito <llamerada.jp@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
messaging
* Copyright 2017- Yuji Ito <llamerada.jp@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* Copyright 2017- Yuji Ito <llamerada.jp@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
network
* Copyright 2017- Yuji Ito <llamerada.jp@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* Copyright 2017- Yuji Ito <llamerada.jp@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
network/node_accessor
* Copyright 2017- Yuji Ito <llamerada.jp@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* Copyright 2017- Yuji Ito <llamerada.jp@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
network/routing
* Copyright 2017- Yuji Ito <llamerada.jp@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* Copyright 2017- Yuji Ito <llamerada.jp@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
network/seed_accessor
* Copyright 2017- Yuji Ito <llamerada.jp@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* Copyright 2017- Yuji Ito <llamerada.jp@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
network/signal
* Copyright 2017- Yuji Ito <llamerada.jp@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* Copyright 2017- Yuji Ito <llamerada.jp@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
network/transferer
* Copyright 2017- Yuji Ito <llamerada.jp@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* Copyright 2017- Yuji Ito <llamerada.jp@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
spread
* Copyright 2017- Yuji Ito <llamerada.jp@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* Copyright 2017- Yuji Ito <llamerada.jp@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
wait_any
* Copyright 2017- Yuji Ito <llamerada.jp@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* Copyright 2017- Yuji Ito <llamerada.jp@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* Copyright 2017- Yuji Ito <llamerada.jp@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* Copyright 2017- Yuji Ito <llamerada.jp@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.

Jump to

Keyboard shortcuts

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