1 /* 2 * hunt-proton: AMQP Protocol library for D programming language. 3 * 4 * Copyright (C) 2018-2019 HuntLabs 5 * 6 * Website: https://www.huntlabs.net/ 7 * 8 * Licensed under the Apache-2.0 License. 9 * 10 */ 11 12 module hunt.proton.engine.Connection; 13 14 import hunt.collection.Set; 15 import hunt.collection.Map; 16 17 import hunt.proton.amqp.Symbol; 18 import hunt.proton.engine.impl.ConnectionImpl; 19 import hunt.proton.engine.Reactor; 20 import hunt.proton.engine.ReactorChild; 21 import hunt.proton.engine.Endpoint; 22 import hunt.proton.engine.Session; 23 import hunt.proton.engine.EndpointState; 24 import hunt.proton.engine.Link; 25 import hunt.proton.engine.Delivery; 26 import hunt.proton.engine.Collector; 27 import hunt.proton.engine.Transport; 28 /** 29 * Maintains lists of sessions, links and deliveries in a state 30 * that is interesting to the application. 31 * 32 * These are exposed by returning the head of those lists via 33 * {@link #sessionHead(EnumSet, EnumSet)}, {@link #linkHead(EnumSet, EnumSet)} 34 * {@link #getWorkHead()} respectively. 35 */ 36 interface Connection : Endpoint, ReactorChild 37 { 38 39 public static class Factory 40 { 41 public static Connection create() { 42 return new ConnectionImpl(); 43 } 44 } 45 46 /** 47 * Returns a newly created session 48 * 49 * TODO does the Connection's channel-max property limit how many sessions can be created, 50 * or opened, or neither? 51 */ 52 public Session session(); 53 54 /** 55 * Returns the head of the list of sessions in the specified states. 56 * 57 * Typically used to discover sessions whose remote state has acquired 58 * particular values, e.g. sessions that have been remotely opened or closed. 59 * 60 * TODO what ordering guarantees on the returned "linked list" are provided? 61 * 62 * @see Session#next(EnumSet, EnumSet) 63 */ 64 public Session sessionHead(Set!EndpointState local, Set!EndpointState remote); 65 66 /** 67 * Returns the head of the list of links in the specified states. 68 * 69 * Typically used to discover links whose remote state has acquired 70 * particular values, e.g. links that have been remotely opened or closed. 71 * 72 * @see Link#next(EnumSet, EnumSet) 73 */ 74 public Link linkHead(Set!EndpointState local, Set!EndpointState remote); 75 76 /** 77 * Returns the head of the delivery work list. The delivery work list consists of 78 * unsettled deliveries whose state has been changed by the other container 79 * and not yet locally processed. 80 * 81 * @see Receiver#recv(byte[], int, int) 82 * @see Delivery#settle() 83 * @see Delivery#getWorkNext() 84 */ 85 public Delivery getWorkHead(); 86 87 public void setContainer(string container); 88 89 public string getContainer(); 90 91 /** 92 * Set the name of the host (either fully qualified or relative) to which 93 * this connection is connecting to. This information may be used by the 94 * remote peer to determine the correct back-end service to connect the 95 * client to. This value will be sent in the Open performative. 96 * 97 * <b>Note that it is illegal to set the hostname to a numeric IP 98 * address or include a port number.</b> 99 * 100 * @param hostname the RFC1035 compliant host name. 101 */ 102 public void setHostname(string hostname); 103 104 public string getHostname(); 105 106 public string getRemoteContainer(); 107 108 public string getRemoteHostname(); 109 110 void setOfferedCapabilities(Symbol[] capabilities); 111 112 void setDesiredCapabilities(Symbol[] capabilities); 113 114 Symbol[] getRemoteOfferedCapabilities(); 115 116 Symbol[] getRemoteDesiredCapabilities(); 117 118 Map!(Symbol,Object) getRemoteProperties(); 119 120 void setProperties(Map!(Symbol,Object) properties); 121 122 Object getContext(); 123 124 void setContext(Object context); 125 126 void collect(Collector collector); 127 128 Transport getTransport(); 129 130 Reactor getReactor(); 131 }