Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bank ¶
type Bank struct {
// contains filtered or unexported fields
}
Here we use a mutex for Withdraw and Deposit as there is a possible race condition between checking if the account exists and depositing. This assignment doesn't have us deleting user acctions, but for scalability reasons it is used.
func (*Bank) Deposit ¶
func (b *Bank) Deposit(t, reply *Transaction) error
func (*Bank) Withdraw ¶
func (b *Bank) Withdraw(t, reply *Transaction) error
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
The server contains an instance of bank, and the net.Listener interface. As of now, this server isn't stoppable; but could be by implementing a stoppable listener.
type Storage ¶
type Storage interface { PutAccount(account *Account) error GetAccount(id int) (*Account, error) Exists(id int) (bool, error) }
Here we define the Storage interface which is used by the server's package main to implement server specific storage.
type Transaction ¶
type Transaction struct {
ID, Amount int
}
This is the object that is passed as both a request and a reply, it could be abstracted further to have a seperate reply object for each RPC method, but that wasn't needed for this assignment.