Linkit icon indicating copy to clipboard operation
Linkit copied to clipboard

GNOM/persistence Unknown Types and error handling

Open Override-6 opened this issue 4 years ago • 0 comments

Summary

Be able to configure in the PersistenceConfig how different error or situation occurred during an object serialisation or deserialization should be handled

Goals

  • Enhance the flexibility of the program
  • Enhance the user's control over security
  • Help the user to write an application that can communicate with applications of another version.

Motivations

The feature can be very interesting for runtime-added classes (Java modules, plugins) or for engines that runs an application with different versions (ex: Server/Client).

Classes that does not exists on the current engine

If an engine receives a packet that contains

val config = new PersistenceConfigBuilder {
     on unknownType "org.myapp.component.*"            λ (tpe, remote) => null //null will be used instead
     on unknownType "org.myapp.player.*"               λ (tpe, remote) => UnknownObject(args) //UnknownObject alternative will be used instead
     on unknownImplementation[MyInterface]             λ (tpe, remote) => StubImplementation(args) //use a custom alternative
     on unknownTypePersistence "org.myapp.component.*" λ (tpe, args, remote) => remote.askPersistence[UnsafeTypePersistence] //We will ask to the sender if it can send a version of the serialised object, serialised with an UnsafeTypePersistence
     on failedObjectPersistence "org.myapp.*"          λ (tpe, args, failure, remote) => throw failure.exception //throw the catched exception
     on reference[TrafficReference] containedIn[ContainerObject] λ (obj, remote) => new Alternative() //all network objects referenced by a TrafficReference that are contained in any objects of type `ContainerObject` are to be replaced by an alternative
}

Override-6 avatar Oct 08 '21 20:10 Override-6