server

package module
v0.0.0-...-e0abb51 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package server provides the core functionality for the momo server.

Package server provides the core functionality for the momo server.

Package server provides the core functionality for the momo server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChangeReplicationModeServer

func ChangeReplicationModeServer(ctx context.Context, cfg momo_common.Configuration, serverId int, timestamp int64) error

ChangeReplicationModeServer listens for connections on a dedicated port and updates the replication mode of the server.

When a client connects, it sends a JSON object containing the new replication mode. This function updates the server's replication mode and, if the server is the primary (serverId 0), it propagates the change to the other servers in the cluster.

func Daemon

func Daemon(ctx context.Context, cfg momo_common.Configuration, serverId int) error

Daemon is the core of the momo server. It listens for incoming connections and handles file uploads and replication. The server's behavior is determined by the replicationMode, which is received from the client.

The server can operate in one of the following replication modes:

  • ReplicationNone: The server saves the file without replicating it to other nodes.
  • ReplicationSplay: The primary server replicates the file to all other servers in the cluster.
  • ReplicationChain: Servers are arranged in a chain. The primary server replicates to the next server in the chain, which then replicates to the next, and so on.
  • ReplicationPrimarySplay: This mode is currently handled as ReplicationNone, which means no replication is performed.

The replication mode is determined by the client, and for secondary servers, it's influenced by the timestamp of the operation.

func GetCurrentReplicationMode

func GetCurrentReplicationMode() int

GetCurrentReplicationMode safely returns the current currentReplicationMode

func GetReplicationState

func GetReplicationState() momo_common.ReplicationData

GetReplicationState safely returns the current replicationState

func SetReplicationState

func SetReplicationState(newMode int, timestamp int64) momo_common.ReplicationData

SetReplicationState safely updates currentReplicationMode and replicationState

Types

This section is empty.

Jump to

Keyboard shortcuts

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