Server describes a single process listening for client requests. The DSL defines the set of services that the server exposes as well as host details. Not defining a server in a design has the same effect as defining a single server that exposes all of the services defined in the design in a single h
(name string, fn ...func())
| 57 | // }) |
| 58 | // }) |
| 59 | func Server(name string, fn ...func()) *expr.ServerExpr { |
| 60 | server := &expr.ServerExpr{Name: name} |
| 61 | if len(fn) > 1 { |
| 62 | eval.TooManyArgError() |
| 63 | return server |
| 64 | } |
| 65 | api, ok := eval.Current().(*expr.APIExpr) |
| 66 | if !ok { |
| 67 | eval.IncompatibleDSL() |
| 68 | } |
| 69 | if len(fn) > 0 { |
| 70 | eval.Execute(fn[0], server) |
| 71 | } |
| 72 | api.Servers = append(api.Servers, server) |
| 73 | return server |
| 74 | } |
| 75 | |
| 76 | // Services sets the list of services implemented by a server. |
| 77 | // |