func register()

in Sources/DistributedActors/Cluster/Reception/OperationLogDistributedReceptionist.swift [300:350]


    func register<Guest>(
        _ guest: Guest,
        with key: DistributedReception.Key<Guest>
    ) async where Guest: DistributedActor & __DistributedClusterActor {
        log.warning("distributed receptionist: register(\(guest), with: \(key)")
        let key = key.asAnyKey
        guard let address = guest.id._unwrapActorAddress else {
            log.error("Cannot register actor with unknown identity type \(guest.id.underlying) with receptionist")
            return
        }

        let ref = system._resolveUntyped(identity: guest.id)

        guard address._isLocal || (address.uniqueNode == system.cluster.uniqueNode) else {
            log.warning("""
            Actor [\(guest.id.underlying)] attempted to register under key [\(key)], with NOT-local receptionist! \
            Actors MUST register with their local receptionist in today's Receptionist implementation.
            """)
            return // TODO: This restriction could be lifted; perhaps we can direct the register to the right node?
        }

        let sequenced: OpLog<ReceptionistOp>.SequencedOp =
            self.addOperation(.register(key: key, identity: guest.id))

        if self.storage.addRegistration(sequenced: sequenced, key: key, guest: guest) {
            // self.instrumentation.actorRegistered(key: key, address: address) // TODO(distributed): make the instrumentation calls compatible with distributed actor based types

            watchTermination(of: guest) { onActorTerminated(identity: $0) }

            log.debug(
                "Registered [\(address)] for key [\(key)]",
                metadata: [
                    "receptionist/key": "\(key)",
                    "receptionist/guest": "\(address)",
                    "receptionist/opLog/maxSeqNr": "\(self.ops.maxSeqNr)",
                    "receptionist/opLog": "\(self.ops.ops)",
                ]
            )

            self.ensureDelayedListingFlush(of: key)
        } else {
            log.warning("Unable to register \(guest) with receptionist, unknown identity type?", metadata: [
                "guest/id": "\(guest.id)",
                "reception/key": "\(key)",
            ])
        }

        // Replication of is done in periodic tics, thus we do not perform a push here.

        // TODO: reply "registered"?
    }