- java.lang.Object
-
- aeonics.entity.Entity
-
- aeonics.entity.Step.Type
-
- aeonics.entity.Step.Origin.Type
-
- aeonics.entity.Step.Origin.NetworkClient
-
- All Implemented Interfaces:
Exportable
,Snapshotable
,java.io.Closeable
,java.lang.AutoCloseable
- Enclosing class:
- Step.Origin
public static class Step.Origin.NetworkClient extends Step.Origin.Type
This class represents a data Origin that connects to a remote network endpoint to fetch data.If the connection is interrupted, this endpoint will attempt to reconnect every second (unless it is stopped).
You should implement the
connect()
method and call theStep.Origin.Type.produce(Message, String)
method to inject data in the system.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface aeonics.util.Snapshotable
Snapshotable.SnapshotMode
-
-
Constructor Summary
Constructors Constructor Description NetworkClient()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Network.Connection
connect()
Returns a server network connection.<T extends Step.Origin.NetworkClient>
Tconnect(java.util.function.Supplier<Network.Connection> connecter)
Sets the connect function as an alternative toconnect()
.void
start()
Starts this Origin entity.void
stop()
Stops this Origin entity.-
Methods inherited from class aeonics.entity.Step.Origin.Type
close, produce, start, started, started, starting, starting, stop, stopped, stopped, stopping, stopping
-
Methods inherited from class aeonics.entity.Entity
addRelation, addRelation, addRelation, cast, clearRelation, config, context, countRelations, countRelations, defineRelation, equals, export, firstRelation, hashCode, hasRelation, id, internal, internal, name, name, onCreate, onRemove, onUpdate, parameter, relations, relationships, removeRelation, snapshot, snapshotMode, template, type, valueOf, valueOf
-
-
-
-
Method Detail
-
connect
public Network.Connection connect() throws java.lang.Exception
Returns a server network connection.- Returns:
- a server network connection
- Throws:
java.lang.Exception
- if an error happens while establishing the connection
-
connect
public <T extends Step.Origin.NetworkClient> T connect(java.util.function.Supplier<Network.Connection> connecter)
Sets the connect function as an alternative toconnect()
.- Type Parameters:
T
- this- Parameters:
connecter
- the connect function- Returns:
- this
-
start
public void start()
Description copied from class:Step.Origin.Type
Starts this Origin entity. The Origin can only be started if it is currently stopped, otherwise it does nothing. Implementations are responsible to set and maintain the internal state.- Overrides:
start
in classStep.Origin.Type
-
stop
public void stop()
Description copied from class:Step.Origin.Type
Stops this Origin entity. The Origin can only be stopped if it is currently running, otherwise it does nothing. Implementations are responsible to set and maintain the internal state.- Overrides:
stop
in classStep.Origin.Type
-
-